@tanstack/router-core 0.0.1-alpha.7 → 0.0.1-alpha.8

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.
@@ -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 n=arguments[e];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(t[a]=n[a])}return t},e.apply(this,arguments)}var n;!function(t){t.Pop="POP",t.Push="PUSH",t.Replace="REPLACE"}(n||(n={}));var a="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,n=t.search,a=t.hash,o=s.state||{};return[o.idx,{pathname:e,search:n,hash:a,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=n.Pop,e=p(),a=e[0],o=e[1];if(P.length){if(null!=a){var r=g-a;r&&(f={action:t,location:o,retry:function(){I(-1*r)}},I(r))}}else S(t)}}));var m=n.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,n){return void 0===n&&(n=null),e({pathname:y.pathname,hash:"",search:""},"string"==typeof t?d(t):t,{state:n,key:u()})}function L(t,e){return[{usr:t.state,key:t.key,idx:e},b(t)]}function R(t,e,n){return!P.length||(P.call({action:t,location:e,retry:n}),!1)}function S(t){m=t;var e=p();g=e[0],y=e[1],_.call({action:m,location:y})}function I(t){s.go(t)}null==g&&(g=0,s.replaceState(e({},s.state,{idx:g}),""));var A={get action(){return m},get location(){return y},createHref:b,push:function t(e,a){var o=n.Push,r=w(e,a);if(R(o,r,(function(){t(e,a)}))){var l=L(r,g+1),c=l[0],u=l[1];try{s.pushState(c,"",u)}catch(t){i.location.assign(u)}S(o)}},replace:function t(e,a){var o=n.Replace,r=w(e,a);if(R(o,r,(function(){t(e,a)}))){var i=L(r,g),l=i[0],c=i[1];s.replaceState(l,"",c),S(o)}},go:I,back:function(){I(-1)},forward:function(){I(1)},listen:function(t){return _.push(t)},block:function(t){var e=P.push(t);return 1===P.length&&i.addEventListener(a,l),function(){e(),P.length||i.removeEventListener(a,l)}}};return A}function i(t){void 0===t&&(t={});var a=t,o=a.initialEntries,r=void 0===o?["/"]:o,i=a.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=n.Pop,m=l[p],v=c(),g=c();function y(t,n){return void 0===n&&(n=null),e({pathname:m.pathname,search:"",hash:""},"string"==typeof t?d(t):t,{state:n,key:u()})}function _(t,e,n){return!g.length||(g.call({action:t,location:e,retry:n}),!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),a=n.Pop,o=l[e];_(a,o,(function(){b(t)}))&&(p=e,P(a,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,a){var o=n.Push,r=y(e,a);_(o,r,(function(){t(e,a)}))&&(p+=1,l.splice(p,l.length,r),P(o,r))},replace:function t(e,a){var o=n.Replace,r=y(e,a);_(o,r,(function(){t(e,a)}))&&(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,n){return Math.min(Math.max(t,e),n)}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,n=void 0===e?"/":e,a=t.search,o=void 0===a?"":a,r=t.hash,i=void 0===r?"":r;return o&&"?"!==o&&(n+="?"===o.charAt(0)?o:"?"+o),i&&"#"!==i&&(n+="#"===i.charAt(0)?i:"#"+i),n}function d(t){var e={};if(t){var n=t.indexOf("#");n>=0&&(e.hash=t.substr(n),t=t.substr(0,n));var a=t.indexOf("?");a>=0&&(e.search=t.substr(a),t=t.substr(0,a)),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 n=Array.isArray(t)&&Array.isArray(e);if(n||m(t)&&m(e)){const a=n?t.length:Object.keys(t).length,o=n?e:Object.keys(e),r=o.length,i=n?[]:{};let s=0;for(let a=0;a<r;a++){const r=n?a:o[a];i[r]=f(t[r],e[r]),i[r]===t[r]&&s++}return a===r&&s===a?t:i}return e}function m(t){if(!v(t))return!1;const e=t.constructor;if(void 0===e)return!0;const n=e.prototype;return!!v(n)&&!!n.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 L(t){return w(b(t))}function R(t,e,n){e=e.replace(new RegExp("^"+t),"/"),n=n.replace(new RegExp("^"+t),"/");let a=S(e);const o=S(n);o.forEach(((t,e)=>{if("/"===t.value)e?e===o.length-1&&a.push(t):a=[t];else if(".."===t.value){var n;a.length>1&&"/"===(null==(n=g(a))?void 0:n.value)&&a.pop(),a.pop()}else{if("."===t.value)return;a.push(t)}}));return P(_([t,...a.map((t=>t.value))]))}function S(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 n=t.split("/").filter(Boolean);return e.push(...n.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 I(t,e,n){return _(S(t).map((t=>{return"*"!==t.value||n?"param"===t.type?null!=(a=e[t.value.substring(1)])?a:"":t.value:"";var a})))}function A(t,e){const n=E(t,e);if(!e.to||n)return null!=n?n:{}}function E(t,e){var n;const a=S(t),o=S(""+(null!=(n=e.to)?n:"*")),r={};return(()=>{for(let t=0;t<Math.max(a.length,o.length);t++){const n=a[t],i=o[t],s=t===o.length-1,l=t===a.length-1;if(i){if("wildcard"===i.type)return!(null==n||!n.value)&&(r["*"]=_(a.slice(t).map((t=>t.value))),!0);if("pathname"===i.type){if("/"===i.value&&(null==n||!n.value))return!0;if(n)if(e.caseSensitive){if(i.value!==n.value)return!1}else if(i.value.toLowerCase()!==n.value.toLowerCase())return!1}if(!n)return!1;if("param"===i.type){if("/"===(null==n?void 0:n.value))return!1;n.value.startsWith(":")||(r[i.value.substring(1)]=n.value)}}if(s&&!l)return!!e.fuzzy}return!0})()?r:void 0}function x(t,e){var n,a,o,r="";for(n in t)if(void 0!==(o=t[n]))if(Array.isArray(o))for(a=0;a<o.length;a++)r&&(r+="&"),r+=encodeURIComponent(n)+"="+encodeURIComponent(o[a]);else r&&(r+="&"),r+=encodeURIComponent(n)+"="+encodeURIComponent(o);return(e||"")+r}function M(t){if(!t)return"";var e=decodeURIComponent(t);return"false"!==e&&("true"===e||(0*+e==0?+e:e))}function k(t){for(var e,n,a={},o=t.split("&");e=o.shift();)void 0!==a[n=(e=e.split("=")).shift()]?a[n]=[].concat(a[n],M(e.shift())):a[n]=M(e.shift());return a}function C(){return C=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(t[a]=n[a])}return t},C.apply(this,arguments)}function T(t,e,n,a){const{id:o,routeId:r,path:i,fullPath:s}=t,l=a.state.actions[o]||(a.state.actions[o]={pending:[],submit:async(t,e)=>{var n;if(!c)return;const o=null==(n=null==e?void 0:e.invalidate)||n,r={submittedAt:Date.now(),status:"pending",submission:t};l.current=r,l.latest=r,l.pending.push(r),a.state=C({},a.state,{currentAction:r,latestAction:r}),a.notify();try{const e=await(null==c.options.action?void 0:c.options.action(t));return r.data=e,o&&(a.invalidateRoute({to:".",fromCurrent:!0}),await a.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)),a.removeActionQueue.push({action:l,actionState:r}),a.notify()}}},a.state.actions[o]);let c={routeId:o,routeRouteId:r,routePath:i,fullPath:s,options:e,router:a,childRoutes:void 0,parentRoute:n,action:l,buildLink:t=>a.buildLink(C({},t,{from:s})),navigate:t=>a.navigate(C({},t,{from:s})),matchRoute:(t,e)=>a.matchRoute(C({},t,{from:s}),e)};return null==a.options.createRoute||a.options.createRoute({router:a,route:c}),c}function D(t){t.forEach(((e,n)=>{const a=t[n-1];a&&(e.loaderData=f(e.loaderData,C({},a.loaderData,e.routeLoaderData)))}))}const O="__root__",F=["element","errorElement","catchElement","pendingElement"];function j(t,e,n){const a=C({},e,n,{router:t,routeSearch:{},search:{},childMatches:[],status:"idle",routeLoaderData:{},loaderData:{},isPending:!1,isFetching:!1,isInvalid:!1,getIsInvalid:()=>{var e,n;const o=Date.now(),r=null!=(e=null!=(n=a.options.loaderMaxAge)?n:t.options.defaultLoaderMaxAge)?e:0;return a.isInvalid||a.updatedAt+r<o},__:{abortController:new AbortController,latestId:"",resolve:()=>{},notify:()=>{a.__.resolve(),a.router.notify()},startPending:()=>{var e,n;const o=null!=(e=a.options.pendingMs)?e:t.options.defaultPendingMs,r=null!=(n=a.options.pendingMinMs)?n:t.options.defaultPendingMinMs;a.__.pendingTimeout||"loading"!==a.status||void 0===o||(a.__.pendingTimeout=setTimeout((()=>{a.isPending=!0,a.__.resolve(),void 0!==r&&(a.__.pendingMinPromise=new Promise((t=>a.__.pendingMinTimeout=setTimeout(t,r))))}),o))},cancelPending:()=>{a.isPending=!1,clearTimeout(a.__.pendingTimeout),clearTimeout(a.__.pendingMinTimeout),delete a.__.pendingMinPromise},validate:()=>{var e,n;const o=null!=(e=null==(n=a.parentMatch)?void 0:n.search)?e:t.location.search;try{const t=a.routeSearch,e="object"==typeof a.options.validateSearch?a.options.validateSearch.parse:a.options.validateSearch;let n=f(t,null==e?void 0:e(o));t!==n&&(a.isInvalid=!0),a.routeSearch=n,a.search=f(o,C({},o,n))}catch(t){console.error(t);const e=new Error("Invalid search params found",{cause:t});return e.code="INVALID_SEARCH_PARAMS",a.status="error",void(a.error=e)}}},cancel:()=>{var t;null==(t=a.__.abortController)||t.abort(),a.__.cancelPending()},invalidate:()=>{a.isInvalid=!0},hasLoaders:()=>!!(e.options.loader||e.options.import||F.some((t=>"function"==typeof e.options[t]))),load:async()=>{const t=""+Date.now()+Math.random();return a.__.latestId=t,"idle"===a.status&&(a.status="loading"),a.isInvalid=!1,a.__.loadPromise=new Promise((async e=>{a.isFetching=!0,a.__.resolve=e;const n=(async()=>{const e=a.options.import;e&&(a.__.importPromise=e({params:a.params}).then((t=>{a.__=C({},a.__,t)}))),await a.__.importPromise,a.__.elementsPromise=(async()=>{await Promise.all(F.map((async t=>{const e=a.options[t];if(!a.__[t])if("function"==typeof e){const n=await e(a);a.__[t]=n}else a.__[t]=a.options[t]})))})(),a.__.dataPromise=Promise.resolve().then((async()=>{try{if(a.options.loader){const e=await a.options.loader({params:a.params,search:a.routeSearch,signal:a.__.abortController.signal});if(t!==a.__.latestId)return a.__.loaderPromise;a.routeLoaderData=f(a.routeLoaderData,e)}a.error=void 0,a.status="success",a.updatedAt=Date.now()}catch(e){if(t!==a.__.latestId)return a.__.loaderPromise;a.error=e,a.status="error",a.updatedAt=Date.now()}}));try{if(await Promise.all([a.__.elementsPromise,a.__.dataPromise]),t!==a.__.latestId)return a.__.loaderPromise;a.__.pendingMinPromise&&(await a.__.pendingMinPromise,delete a.__.pendingMinPromise)}finally{if(t!==a.__.latestId)return a.__.loaderPromise;a.__.cancelPending(),a.isPending=!1,a.isFetching=!1,a.__.notify()}})();if(a.__.loaderPromise=n,await n,t!==a.__.latestId)return a.__.loaderPromise;delete a.__.loaderPromise})),await a.__.loadPromise}});return a.hasLoaders()||(a.status="success"),a}const N=H(JSON.parse),B=U(JSON.stringify);function H(t){return e=>{"?"===e.substring(0,1)&&(e=e.substring(1));let n=k(e);for(let e in n){const a=n[e];if("string"==typeof a)try{n[e]=t(a)}catch(t){}}return n}}function U(t){return e=>{(e=C({},e))&&Object.keys(e).forEach((n=>{const a=e[n];if(void 0===a||void 0===a)delete e[n];else if(a&&"object"==typeof a&&null!==a)try{e[n]=t(a)}catch(t){}}));const n=x(e).toString();return n?"?"+n:""}}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,n=void 0===e?"/":e,a=t.search,o=void 0===a?"":a,r=t.hash,l=void 0===r?"":r,c=s.state||{};return[c.idx,{pathname:n,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=n.Pop,e=p(),a=e[0],o=e[1];if(b.length){if(null!=a){var r=y-a;r&&(f={action:t,location:o,retry:function(){A(-1*r)}},A(r))}}else I(t)}}i.addEventListener(o,m),i.addEventListener("hashchange",(function(){h(p()[1])!==h(_)&&m()}));var v=n.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 n=i.location.href,a=n.indexOf("#");e=-1===a?n:n.slice(0,a)}return e}()+"#"+("string"==typeof t?t:h(t))}function L(t,n){return void 0===n&&(n=null),e({pathname:_.pathname,hash:"",search:""},"string"==typeof t?d(t):t,{state:n,key:u()})}function R(t,e){return[{usr:t.state,key:t.key,idx:e},w(t)]}function S(t,e,n){return!b.length||(b.call({action:t,location:e,retry:n}),!1)}function I(t){v=t;var e=p();y=e[0],_=e[1],P.call({action:v,location:_})}function A(t){s.go(t)}null==y&&(y=0,s.replaceState(e({},s.state,{idx:y}),""));var E={get action(){return v},get location(){return _},createHref:w,push:function t(e,a){var o=n.Push,r=L(e,a);if(S(o,r,(function(){t(e,a)}))){var l=R(r,y+1),c=l[0],u=l[1];try{s.pushState(c,"",u)}catch(t){i.location.assign(u)}I(o)}},replace:function t(e,a){var o=n.Replace,r=L(e,a);if(S(o,r,(function(){t(e,a)}))){var i=R(r,y),l=i[0],c=i[1];s.replaceState(l,"",c),I(o)}},go:A,back:function(){A(-1)},forward:function(){A(1)},listen:function(t){return P.push(t)},block:function(t){var e=b.push(t);return 1===b.length&&i.addEventListener(a,l),function(){e(),b.length||i.removeEventListener(a,l)}}};return E},t.createMemoryHistory=i,t.createRoute=T,t.createRouteConfig=function t(e,n,a,o,r){void 0===e&&(e={}),void 0===a&&(a=!0),a&&(e.path=O),o===O&&(o="");let i=a?O:e.path;i&&"/"!==i&&(i=L(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:n,createChildren:n=>t(e,n((e=>t(e,void 0,!1,l,c))),!1,o,r),addChildren:n=>t(e,n,!1,o,r),createRoute:e=>t(e,void 0,!1,l,c)}},t.createRouteMatch=j,t.createRouter=function(t){var e,n;const a=(null==t?void 0:t.history)||(z?i():r());let o={options:C({defaultLoaderGcMaxAge:3e5,defaultLoaderMaxAge:0,defaultLinkPreloadDelay:50},t,{stringifySearch:null!=(e=null==t?void 0:t.stringifySearch)?e:B,parseSearch:null!=(n=null==t?void 0:t.parseSearch)?n:N}),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:{},loaderData:{},lastUpdated:Date.now(),isFetching:!1,isPreloading:!1},startedLoadingAt:Date.now(),subscribe:t=>(o.listeners.push(t),()=>{o.listeners=o.listeners.filter((e=>e!==t))}),getRoute:t=>o.routesById[t],notify:()=>{o.state=C({},o.state,{isFetching:"loading"===o.state.status||o.state.matches.some((t=>t.isFetching)),isPreloading:Object.values(o.matchCache).some((t=>t.match.isFetching&&!o.state.matches.find((e=>e.matchId===t.match.matchId))))}),D(o.state.matches),o.listeners.forEach((t=>t()))},mount:()=>{const t=o.buildLocation({to:".",search:!0,hash:!0});t.href!==o.location.href?o.commitLocation(t,!0):o.loadLocation();const e=a.listen((t=>{o.loadLocation(o.parseLocation(t.location,o.location))}));return!z&&window.addEventListener&&(window.addEventListener("visibilitychange",o.onFocus,!1),window.addEventListener("focus",o.onFocus,!1)),()=>{e(),window.removeEventListener("visibilitychange",o.onFocus),window.removeEventListener("focus",o.onFocus)}},onFocus:()=>{o.loadLocation()},update:t=>{Object.assign(o.options,t);const{basepath:e,routeConfig:n}=o.options;return o.basepath=P("/"+(null!=e?e:"")),n&&(o.routesById={},o.routeTree=o.buildRouteTree(n)),o},buildRouteTree:t=>{const e=(t,n)=>t.map((t=>{const a=T(t,t.options,n,o);if(o.routesById[a.routeId])throw new Error;o.routesById[a.routeId]=a;const r=t.children;return a.childRoutes=null!=r&&r.length?e(r,a):void 0,a}));return e([t])[0]},parseLocation:(t,e)=>{var n;const a=o.options.parseSearch(t.search);return{pathname:t.pathname,searchStr:t.search,search:f(null==e?void 0:e.search,a),hash:null!=(n=t.hash.split("#").reverse()[0])?n:"",href:""+t.pathname+t.search+t.hash,state:t.state,key:t.key}},buildLocation:function(t){var e,n,a,r,i,s,l,c,u;void 0===t&&(t={});const h=t.fromCurrent?o.location.pathname:null!=(e=t.from)?e:o.location.pathname;let d=R(null!=(n=o.basepath)?n:"/",h,""+(null!=(a=t.to)?a:"."));const p=o.matchRoutes(o.location.pathname,{strictParseParams:!0}),m=o.matchRoutes(d),v=C({},null==(r=g(p))?void 0:r.params);let _=!0===(null==(i=t.params)||i)?v:y(t.params,v);_&&m.map((t=>t.options.stringifyParams)).filter(Boolean).forEach((t=>{Object.assign({},_,t(_))})),d=I(d,null!=_?_:{});const P=null!=(s=t.__preSearchFilters)&&s.length?t.__preSearchFilters.reduce(((t,e)=>e(t)),o.location.search):o.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,L=f(o.location.search,w),S=o.options.stringifySearch(L);let A=!0===t.hash?o.location.hash:y(t.hash,o.location.hash);return A=A?"#"+A:"",{pathname:d,search:L,searchStr:S,state:o.location.state,hash:A,href:""+d+S+A,key:t.key}},commitLocation:(t,e)=>{const n=""+Date.now()+Math.random();o.navigateTimeout&&clearTimeout(o.navigateTimeout);let r="replace";e||(r="push");return o.parseLocation(a.location).href===t.href&&!t.key&&(r="replace"),"replace"===r?a.replace({pathname:t.pathname,hash:t.hash,search:t.searchStr},{id:n}):a.push({pathname:t.pathname,hash:t.hash,search:t.searchStr},{id:n}),o.navigationPromise=new Promise((t=>{const e=o.resolveNavigation;o.resolveNavigation=()=>{e(),t()}})),o.navigationPromise},buildNext:t=>{const e=o.buildLocation(t),n=o.matchRoutes(e.pathname),a=n.map((t=>{var e;return null!=(e=t.options.preSearchFilters)?e:[]})).flat().filter(Boolean),r=n.map((t=>{var e;return null!=(e=t.options.postSearchFilters)?e:[]})).flat().filter(Boolean);return o.buildLocation(C({},t,{__preSearchFilters:a,__postSearchFilters:r}))},cancelMatches:()=>{var t,e;[...o.state.matches,...null!=(t=null==(e=o.state.pending)?void 0:e.matches)?t:[]].forEach((t=>{t.cancel()}))},loadLocation:async t=>{const e=Math.random();o.startedLoadingAt=e,t&&(o.location=t),o.removeActionQueue.forEach((t=>{let{action:e,actionState:n}=t;o.state.currentAction===n&&(o.state.currentAction=void 0),e.current===n&&(e.current=void 0)})),o.removeActionQueue=[],o.cancelMatches();const n=o.matchRoutes(location.pathname,{strictParseParams:!0});if(o.state=C({},o.state,{pending:{matches:n,location:o.location},status:"loading"}),o.notify(),await o.loadMatches(n,{withPending:!0}),o.startedLoadingAt!==e)return o.navigationPromise;const a=o.state.matches,r=[],i=[];a.forEach((t=>{n.find((e=>e.matchId===t.matchId))?i.push(t):r.push(t)}));const s=Date.now();r.forEach((t=>{var e,n,a,r;null==t.__.onExit||t.__.onExit({params:t.params,search:t.routeSearch}),"error"!==t.status||t.isFetching||(t.status="idle",t.error=void 0);const i=Math.max(null!=(e=null!=(n=t.options.loaderGcMaxAge)?n:o.options.defaultLoaderGcMaxAge)?e:0,null!=(a=null!=(r=t.options.loaderMaxAge)?r:o.options.defaultLoaderMaxAge)?a:0);i>0&&(o.matchCache[t.matchId]={gc:i==1/0?Number.MAX_SAFE_INTEGER:s+i,match:t})})),i.forEach((t=>{null==t.options.onTransition||t.options.onTransition({params:t.params,search:t.routeSearch})}));n.filter((t=>!a.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})})),n.some((t=>"loading"===t.status))&&(o.notify(),await Promise.all(n.map((t=>t.__.loaderPromise||Promise.resolve())))),o.startedLoadingAt===e&&(o.state=C({},o.state,{location:o.location,matches:n,pending:void 0,status:"idle"}),o.notify(),o.resolveNavigation())},cleanMatchCache:()=>{const t=Date.now();Object.keys(o.matchCache).forEach((e=>{const n=o.matchCache[e];"loading"!==n.match.status&&(n.gc>0&&n.gc>t||delete o.matchCache[e])}))},loadRoute:async function(t,e){void 0===t&&(t=o.location);const n=o.buildNext(t),a=o.matchRoutes(n.pathname,{strictParseParams:!0});return await o.loadMatches(a,{preload:!0,maxAge:e.maxAge}),a},matchRoutes:(t,e)=>{var n,a;o.cleanMatchCache();const r=[];if(!o.routeTree)return r;const i=[...o.state.matches,...null!=(n=null==(a=o.state.pending)?void 0:a.matches)?n:[]],s=async n=>{var a,l,c;const u=g(r);let h=null!=(a=null==u?void 0:u.params)?a:{};const d=null!=(l=null==o.options.filterRoutes?void 0:o.options.filterRoutes(n))?l:n;let p=[];const f=(n,a)=>(a.some((a=>{var r,i,s;if(!a.routePath&&null!=(r=a.childRoutes)&&r.length)return f([...p,a],a.childRoutes);const l=!!("/"!==a.routePath||null!=(i=a.childRoutes)&&i.length),c=A(t,{to:a.fullPath,fuzzy:l,caseSensitive:null!=(s=a.options.caseSensitive)?s:o.options.caseSensitive});if(c){let t;try{var u;t=null!=(u=null==a.options.parseParams?void 0:a.options.parseParams(c))?u:c}catch(t){if(null!=e&&e.strictParseParams)throw t}h=C({},h,t)}return c&&(p=[...n,a]),!!p.length})),!!p.length);if(f([],d),!p.length)return;p.forEach((e=>{var n;const a=I(e.routePath,h),s=I(e.routeId,h,!0),l=i.find((t=>t.matchId===s))||(null==(n=o.matchCache[s])?void 0:n.match)||j(o,e,{matchId:s,params:h,pathname:_([t,a])});r.push(l)}));const m=g(p);null!=(c=m.childRoutes)&&c.length&&s(m.childRoutes)};return s([o.routeTree]),D(r),r},loadMatches:async(t,e)=>{const n=Date.now(),a=t.map((async t=>{if(t.__.validate(),t.hasLoaders()){if(null!=e&&e.preload&&(null==e?void 0:e.maxAge)>0){if(o.state.matches.find((e=>e.matchId===t.matchId)))return;o.matchCache[t.matchId]={gc:n+e.maxAge,match:t}}("success"===t.status&&t.getIsInvalid()||"error"===t.status||"idle"===t.status)&&t.load(),"loading"===t.status&&(null!=e&&e.withPending&&t.__.startPending(),await t.__.loadPromise)}}));o.notify(),await Promise.all(a)},invalidateRoute:t=>{var e,n;const a=o.buildNext(t),r=o.matchRoutes(a.pathname).map((t=>t.matchId));[...o.state.matches,...null!=(e=null==(n=o.state.pending)?void 0:n.matches)?e:[]].forEach((t=>{r.includes(t.matchId)&&t.invalidate()}))},reload:()=>o._navigate({fromCurrent:!0,replace:!0,search:!0}),resolvePath:(t,e)=>R(o.basepath,t,P(e)),matchRoute:(t,e)=>{var n;t=C({},t,{to:t.to?o.resolvePath(null!=(n=t.from)?n:"",t.to):void 0});const a=o.buildNext(t);var r;return null!=e&&e.pending?!(null==(r=o.state.pending)||!r.location)&&!!A(o.state.pending.location.pathname,C({},e,{to:a.pathname})):!!A(o.state.location.pathname,C({},e,{to:a.pathname}))},_navigate:t=>{const e=o.buildNext(t);return o.commitLocation(e,t.replace)},navigate:async t=>{let{from:e,to:n=".",search:a,hash:r,replace:i,params:s}=t;const l=String(n),c=String(e);let u;try{new URL(""+l),u=!0}catch(t){}return p(!u),o._navigate({from:c,to:l,search:a,hash:r,replace:i,params:s})},buildLink:t=>{var e,n,a,r;let{from:i,to:s=".",search:l,params:c,hash:u,target:h,replace:d,activeOptions:p,preload:f,preloadMaxAge:m,preloadDelay:v,disabled:g}=t;try{return new URL(""+s),{type:"external",href:s}}catch(t){}const y={from:i,to:s,search:l,params:c,hash:u,replace:d},_=o.buildNext(y);f=null!=(e=f)?e:o.options.defaultLinkPreload;const P=null!=(n=null!=(a=null!=m?m:o.options.defaultLinkPreloadMaxAge)?a:o.options.defaultLoaderGcMaxAge)?n:0,b=null!=(r=null!=v?v:o.options.defaultLinkPreloadDelay)?r:0,w=o.state.location.pathname===_.pathname,L=o.state.location.pathname.split("/"),R=_.pathname.split("/").every(((t,e)=>t===L[e])),S=o.state.location.hash===_.hash,I=null!=p&&p.exact?w:R,A=null==p||!p.includeHash||S;return{type:"internal",next:_,handleFocus:t=>{f&&P>0&&o.loadRoute(y,{maxAge:P})},handleClick:t=>{g||function(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}(t)||t.defaultPrevented||h&&"_self"!==h||0!==t.button||(t.preventDefault(),!w||l||u||o.invalidateRoute(y),o._navigate(y))},handleEnter:t=>{const e=t.target||{};if(f&&P>0){if(e.preloadTimeout)return;e.preloadTimeout=setTimeout((()=>{e.preloadTimeout=null,o.loadRoute(y,{maxAge:P})}),b)}},handleLeave:t=>{const e=t.target||{};e.preloadTimeout&&(clearTimeout(e.preloadTimeout),e.preloadTimeout=null)},isActive:I&&A,disabled:g}}};return o.location=o.parseLocation(a.location),o.state.location=o.location,o.update(t),null==o.options.createRouter||o.options.createRouter(o),o},t.decode=k,t.defaultParseSearch=N,t.defaultStringifySearch=B,t.encode=x,t.functionalUpdate=y,t.interpolatePath=I,t.invariant=p,t.joinPaths=_,t.last=g,t.matchByPath=E,t.matchPathname=A,t.parsePathname=S,t.parseSearchWith=H,t.replaceEqualDeep=f,t.resolvePath=R,t.rootRouteId=O,t.stringifySearchWith=U,t.trimPath=L,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(){return e=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(t[a]=n[a])}return t},e.apply(this,arguments)}var n;!function(t){t.Pop="POP",t.Push="PUSH",t.Replace="REPLACE"}(n||(n={}));var a="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,n=t.search,a=t.hash,o=s.state||{};return[o.idx,{pathname:e,search:n,hash:a,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=n.Pop,e=p(),a=e[0],o=e[1];if(P.length){if(null!=a){var r=g-a;r&&(f={action:t,location:o,retry:function(){I(-1*r)}},I(r))}}else S(t)}}));var m=n.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,n){return void 0===n&&(n=null),e({pathname:y.pathname,hash:"",search:""},"string"==typeof t?d(t):t,{state:n,key:u()})}function R(t,e){return[{usr:t.state,key:t.key,idx:e},b(t)]}function L(t,e,n){return!P.length||(P.call({action:t,location:e,retry:n}),!1)}function S(t){m=t;var e=p();g=e[0],y=e[1],_.call({action:m,location:y})}function I(t){s.go(t)}null==g&&(g=0,s.replaceState(e({},s.state,{idx:g}),""));var A={get action(){return m},get location(){return y},createHref:b,push:function t(e,a){var o=n.Push,r=w(e,a);if(L(o,r,(function(){t(e,a)}))){var l=R(r,g+1),c=l[0],u=l[1];try{s.pushState(c,"",u)}catch(t){i.location.assign(u)}S(o)}},replace:function t(e,a){var o=n.Replace,r=w(e,a);if(L(o,r,(function(){t(e,a)}))){var i=R(r,g),l=i[0],c=i[1];s.replaceState(l,"",c),S(o)}},go:I,back:function(){I(-1)},forward:function(){I(1)},listen:function(t){return _.push(t)},block:function(t){var e=P.push(t);return 1===P.length&&i.addEventListener(a,l),function(){e(),P.length||i.removeEventListener(a,l)}}};return A}function i(t){void 0===t&&(t={});var a=t,o=a.initialEntries,r=void 0===o?["/"]:o,i=a.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=n.Pop,m=l[p],v=c(),g=c();function y(t,n){return void 0===n&&(n=null),e({pathname:m.pathname,search:"",hash:""},"string"==typeof t?d(t):t,{state:n,key:u()})}function _(t,e,n){return!g.length||(g.call({action:t,location:e,retry:n}),!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),a=n.Pop,o=l[e];_(a,o,(function(){b(t)}))&&(p=e,P(a,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,a){var o=n.Push,r=y(e,a);_(o,r,(function(){t(e,a)}))&&(p+=1,l.splice(p,l.length,r),P(o,r))},replace:function t(e,a){var o=n.Replace,r=y(e,a);_(o,r,(function(){t(e,a)}))&&(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,n){return Math.min(Math.max(t,e),n)}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,n=void 0===e?"/":e,a=t.search,o=void 0===a?"":a,r=t.hash,i=void 0===r?"":r;return o&&"?"!==o&&(n+="?"===o.charAt(0)?o:"?"+o),i&&"#"!==i&&(n+="#"===i.charAt(0)?i:"#"+i),n}function d(t){var e={};if(t){var n=t.indexOf("#");n>=0&&(e.hash=t.substr(n),t=t.substr(0,n));var a=t.indexOf("?");a>=0&&(e.search=t.substr(a),t=t.substr(0,a)),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 n=Array.isArray(t)&&Array.isArray(e);if(n||m(t)&&m(e)){const a=n?t.length:Object.keys(t).length,o=n?e:Object.keys(e),r=o.length,i=n?[]:{};let s=0;for(let a=0;a<r;a++){const r=n?a:o[a];i[r]=f(t[r],e[r]),i[r]===t[r]&&s++}return a===r&&s===a?t:i}return e}function m(t){if(!v(t))return!1;const e=t.constructor;if(void 0===e)return!0;const n=e.prototype;return!!v(n)&&!!n.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 R(t){return w(b(t))}function L(t,e,n){e=e.replace(new RegExp("^"+t),"/"),n=n.replace(new RegExp("^"+t),"/");let a=S(e);const o=S(n);o.forEach(((t,e)=>{if("/"===t.value)e?e===o.length-1&&a.push(t):a=[t];else if(".."===t.value){var n;a.length>1&&"/"===(null==(n=g(a))?void 0:n.value)&&a.pop(),a.pop()}else{if("."===t.value)return;a.push(t)}}));return P(_([t,...a.map((t=>t.value))]))}function S(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 n=t.split("/").filter(Boolean);return e.push(...n.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 I(t,e,n){return _(S(t).map((t=>{return"*"!==t.value||n?"param"===t.type?null!=(a=e[t.value.substring(1)])?a:"":t.value:"";var a})))}function A(t,e){const n=E(t,e);if(!e.to||n)return null!=n?n:{}}function E(t,e){var n;const a=S(t),o=S(""+(null!=(n=e.to)?n:"*")),r={};return(()=>{for(let t=0;t<Math.max(a.length,o.length);t++){const n=a[t],i=o[t],s=t===o.length-1,l=t===a.length-1;if(i){if("wildcard"===i.type)return!(null==n||!n.value)&&(r["*"]=_(a.slice(t).map((t=>t.value))),!0);if("pathname"===i.type){if("/"===i.value&&(null==n||!n.value))return!0;if(n)if(e.caseSensitive){if(i.value!==n.value)return!1}else if(i.value.toLowerCase()!==n.value.toLowerCase())return!1}if(!n)return!1;if("param"===i.type){if("/"===(null==n?void 0:n.value))return!1;n.value.startsWith(":")||(r[i.value.substring(1)]=n.value)}}if(s&&!l)return!!e.fuzzy}return!0})()?r:void 0}function x(t,e){var n,a,o,r="";for(n in t)if(void 0!==(o=t[n]))if(Array.isArray(o))for(a=0;a<o.length;a++)r&&(r+="&"),r+=encodeURIComponent(n)+"="+encodeURIComponent(o[a]);else r&&(r+="&"),r+=encodeURIComponent(n)+"="+encodeURIComponent(o);return(e||"")+r}function M(t){if(!t)return"";var e=decodeURIComponent(t);return"false"!==e&&("true"===e||(0*+e==0?+e:e))}function k(t){for(var e,n,a={},o=t.split("&");e=o.shift();)void 0!==a[n=(e=e.split("=")).shift()]?a[n]=[].concat(a[n],M(e.shift())):a[n]=M(e.shift());return a}function C(){return C=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(t[a]=n[a])}return t},C.apply(this,arguments)}function T(t,e,n,a){const{id:o,routeId:r,path:i,fullPath:s}=t,l=a.state.actions[o]||(a.state.actions[o]={pending:[],submit:async(t,e)=>{var n;if(!c)return;const o=null==(n=null==e?void 0:e.invalidate)||n,r={submittedAt:Date.now(),status:"pending",submission:t};l.current=r,l.latest=r,l.pending.push(r),a.state=C({},a.state,{currentAction:r,latestAction:r}),a.notify();try{const e=await(null==c.options.action?void 0:c.options.action(t));return r.data=e,o&&(a.invalidateRoute({to:".",fromCurrent:!0}),await a.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)),a.removeActionQueue.push({action:l,actionState:r}),a.notify()}}},a.state.actions[o]);let c={routeId:o,routeRouteId:r,routePath:i,fullPath:s,options:e,router:a,childRoutes:void 0,parentRoute:n,action:l,buildLink:t=>a.buildLink(C({},t,{from:s})),navigate:t=>a.navigate(C({},t,{from:s})),matchRoute:(t,e)=>a.matchRoute(C({},t,{from:s}),e)};return null==a.options.createRoute||a.options.createRoute({router:a,route:c}),c}function D(t){t.forEach(((e,n)=>{const a=t[n-1];a&&(e.loaderData=f(e.loaderData,C({},a.loaderData,e.routeLoaderData)))}))}const O="__root__",F=["element","errorElement","catchElement","pendingElement"];function j(t,e,n){const a=C({},e,n,{router:t,routeSearch:{},search:{},childMatches:[],status:"idle",routeLoaderData:{},loaderData:{},isPending:!1,isFetching:!1,isInvalid:!1,getIsInvalid:()=>{var e,n;const o=Date.now(),r=null!=(e=null!=(n=a.options.loaderMaxAge)?n:t.options.defaultLoaderMaxAge)?e:0;return a.isInvalid||a.updatedAt+r<o},__:{abortController:new AbortController,latestId:"",resolve:()=>{},notify:()=>{a.__.resolve(),a.router.notify()},startPending:()=>{var e,n;const o=null!=(e=a.options.pendingMs)?e:t.options.defaultPendingMs,r=null!=(n=a.options.pendingMinMs)?n:t.options.defaultPendingMinMs;a.__.pendingTimeout||"loading"!==a.status||void 0===o||(a.__.pendingTimeout=setTimeout((()=>{a.isPending=!0,a.__.resolve(),void 0!==r&&(a.__.pendingMinPromise=new Promise((t=>a.__.pendingMinTimeout=setTimeout(t,r))))}),o))},cancelPending:()=>{a.isPending=!1,clearTimeout(a.__.pendingTimeout),clearTimeout(a.__.pendingMinTimeout),delete a.__.pendingMinPromise},validate:()=>{var e,n;const o=null!=(e=null==(n=a.parentMatch)?void 0:n.search)?e:t.location.search;try{const t=a.routeSearch,e="object"==typeof a.options.validateSearch?a.options.validateSearch.parse:a.options.validateSearch;let n=f(t,null==e?void 0:e(o));t!==n&&(a.isInvalid=!0),a.routeSearch=n,a.search=f(o,C({},o,n))}catch(t){console.error(t);const e=new Error("Invalid search params found",{cause:t});return e.code="INVALID_SEARCH_PARAMS",a.status="error",void(a.error=e)}}},cancel:()=>{var t;null==(t=a.__.abortController)||t.abort(),a.__.cancelPending()},invalidate:()=>{a.isInvalid=!0},hasLoaders:()=>!!(e.options.loader||e.options.import||F.some((t=>"function"==typeof e.options[t]))),load:async()=>{const t=""+Date.now()+Math.random();return a.__.latestId=t,"idle"===a.status&&(a.status="loading"),a.isInvalid=!1,a.__.loadPromise=new Promise((async e=>{a.isFetching=!0,a.__.resolve=e;const n=(async()=>{const e=a.options.import;e&&(a.__.importPromise=e({params:a.params}).then((t=>{a.__=C({},a.__,t)}))),await a.__.importPromise,a.__.elementsPromise=(async()=>{await Promise.all(F.map((async t=>{const e=a.options[t];if(!a.__[t])if("function"==typeof e){const n=await e(a);a.__[t]=n}else a.__[t]=a.options[t]})))})(),a.__.dataPromise=Promise.resolve().then((async()=>{try{if(a.options.loader){const e=await a.options.loader({params:a.params,search:a.routeSearch,signal:a.__.abortController.signal});if(t!==a.__.latestId)return a.__.loaderPromise;a.routeLoaderData=f(a.routeLoaderData,e)}a.error=void 0,a.status="success",a.updatedAt=Date.now()}catch(e){if(t!==a.__.latestId)return a.__.loaderPromise;a.error=e,a.status="error",a.updatedAt=Date.now()}}));try{if(await Promise.all([a.__.elementsPromise,a.__.dataPromise]),t!==a.__.latestId)return a.__.loaderPromise;a.__.pendingMinPromise&&(await a.__.pendingMinPromise,delete a.__.pendingMinPromise)}finally{if(t!==a.__.latestId)return a.__.loaderPromise;a.__.cancelPending(),a.isPending=!1,a.isFetching=!1,a.__.notify()}})();if(a.__.loaderPromise=n,await n,t!==a.__.latestId)return a.__.loaderPromise;delete a.__.loaderPromise})),await a.__.loadPromise}});return a.hasLoaders()||(a.status="success"),a}const N=H(JSON.parse),B=U(JSON.stringify);function H(t){return e=>{"?"===e.substring(0,1)&&(e=e.substring(1));let n=k(e);for(let e in n){const a=n[e];if("string"==typeof a)try{n[e]=t(a)}catch(t){}}return n}}function U(t){return e=>{(e=C({},e))&&Object.keys(e).forEach((n=>{const a=e[n];if(void 0===a||void 0===a)delete e[n];else if(a&&"object"==typeof a&&null!==a)try{e[n]=t(a)}catch(t){}}));const n=x(e).toString();return n?"?"+n:""}}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,n=void 0===e?"/":e,a=t.search,o=void 0===a?"":a,r=t.hash,l=void 0===r?"":r,c=s.state||{};return[c.idx,{pathname:n,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=n.Pop,e=p(),a=e[0],o=e[1];if(b.length){if(null!=a){var r=y-a;r&&(f={action:t,location:o,retry:function(){A(-1*r)}},A(r))}}else I(t)}}i.addEventListener(o,m),i.addEventListener("hashchange",(function(){h(p()[1])!==h(_)&&m()}));var v=n.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 n=i.location.href,a=n.indexOf("#");e=-1===a?n:n.slice(0,a)}return e}()+"#"+("string"==typeof t?t:h(t))}function R(t,n){return void 0===n&&(n=null),e({pathname:_.pathname,hash:"",search:""},"string"==typeof t?d(t):t,{state:n,key:u()})}function L(t,e){return[{usr:t.state,key:t.key,idx:e},w(t)]}function S(t,e,n){return!b.length||(b.call({action:t,location:e,retry:n}),!1)}function I(t){v=t;var e=p();y=e[0],_=e[1],P.call({action:v,location:_})}function A(t){s.go(t)}null==y&&(y=0,s.replaceState(e({},s.state,{idx:y}),""));var E={get action(){return v},get location(){return _},createHref:w,push:function t(e,a){var o=n.Push,r=R(e,a);if(S(o,r,(function(){t(e,a)}))){var l=L(r,y+1),c=l[0],u=l[1];try{s.pushState(c,"",u)}catch(t){i.location.assign(u)}I(o)}},replace:function t(e,a){var o=n.Replace,r=R(e,a);if(S(o,r,(function(){t(e,a)}))){var i=L(r,y),l=i[0],c=i[1];s.replaceState(l,"",c),I(o)}},go:A,back:function(){A(-1)},forward:function(){A(1)},listen:function(t){return P.push(t)},block:function(t){var e=b.push(t);return 1===b.length&&i.addEventListener(a,l),function(){e(),b.length||i.removeEventListener(a,l)}}};return E},t.createMemoryHistory=i,t.createRoute=T,t.createRouteConfig=function t(e,n,a,o,r){void 0===e&&(e={}),void 0===a&&(a=!0),a&&(e.path=O),o===O&&(o="");let i=a?O:e.path;i&&"/"!==i&&(i=R(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:n,createChildren:n=>t(e,n((e=>t(e,void 0,!1,l,c))),!1,o,r),addChildren:n=>t(e,n,!1,o,r),createRoute:e=>t(e,void 0,!1,l,c)}},t.createRouteMatch=j,t.createRouter=function(t){var e,n;const a=(null==t?void 0:t.history)||(z?i():r());let o={options:C({defaultLoaderGcMaxAge:3e5,defaultLoaderMaxAge:0,defaultLinkPreloadDelay:50},t,{stringifySearch:null!=(e=null==t?void 0:t.stringifySearch)?e:B,parseSearch:null!=(n=null==t?void 0:t.parseSearch)?n:N}),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:{},loaderData:{},lastUpdated:Date.now(),isFetching:!1,isPreloading:!1},startedLoadingAt:Date.now(),subscribe:t=>(o.listeners.push(t),()=>{o.listeners=o.listeners.filter((e=>e!==t))}),getRoute:t=>o.routesById[t],notify:()=>{o.state=C({},o.state,{isFetching:"loading"===o.state.status||o.state.matches.some((t=>t.isFetching)),isPreloading:Object.values(o.matchCache).some((t=>t.match.isFetching&&!o.state.matches.find((e=>e.matchId===t.match.matchId))))}),D(o.state.matches),o.listeners.forEach((t=>t()))},mount:()=>{const t=o.buildLocation({to:".",search:!0,hash:!0});t.href!==o.location.href?o.commitLocation(t,!0):o.loadLocation();const e=a.listen((t=>{o.loadLocation(o.parseLocation(t.location,o.location))}));return!z&&window.addEventListener&&(window.addEventListener("visibilitychange",o.onFocus,!1),window.addEventListener("focus",o.onFocus,!1)),()=>{e(),window.removeEventListener("visibilitychange",o.onFocus),window.removeEventListener("focus",o.onFocus)}},onFocus:()=>{o.loadLocation()},update:t=>{Object.assign(o.options,t);const{basepath:e,routeConfig:n}=o.options;return o.basepath=P("/"+(null!=e?e:"")),n&&(o.routesById={},o.routeTree=o.buildRouteTree(n)),o},buildRouteTree:t=>{const e=(t,n)=>t.map((t=>{const a=T(t,t.options,n,o);if(o.routesById[a.routeId])throw new Error;o.routesById[a.routeId]=a;const r=t.children;return a.childRoutes=null!=r&&r.length?e(r,a):void 0,a}));return e([t])[0]},parseLocation:(t,e)=>{var n;const a=o.options.parseSearch(t.search);return{pathname:t.pathname,searchStr:t.search,search:f(null==e?void 0:e.search,a),hash:null!=(n=t.hash.split("#").reverse()[0])?n:"",href:""+t.pathname+t.search+t.hash,state:t.state,key:t.key}},buildLocation:function(t){var e,n,a,r,i,s,l,c,u;void 0===t&&(t={});const h=t.fromCurrent?o.location.pathname:null!=(e=t.from)?e:o.location.pathname;let d=L(null!=(n=o.basepath)?n:"/",h,""+(null!=(a=t.to)?a:"."));const p=o.matchRoutes(o.location.pathname,{strictParseParams:!0}),m=o.matchRoutes(d),v=C({},null==(r=g(p))?void 0:r.params);let _=!0===(null==(i=t.params)||i)?v:y(t.params,v);_&&m.map((t=>t.options.stringifyParams)).filter(Boolean).forEach((t=>{Object.assign({},_,t(_))})),d=I(d,null!=_?_:{});const P=null!=(s=t.__preSearchFilters)&&s.length?t.__preSearchFilters.reduce(((t,e)=>e(t)),o.location.search):o.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,R=f(o.location.search,w),S=o.options.stringifySearch(R);let A=!0===t.hash?o.location.hash:y(t.hash,o.location.hash);return A=A?"#"+A:"",{pathname:d,search:R,searchStr:S,state:o.location.state,hash:A,href:""+d+S+A,key:t.key}},commitLocation:(t,e)=>{const n=""+Date.now()+Math.random();o.navigateTimeout&&clearTimeout(o.navigateTimeout);let r="replace";e||(r="push");return o.parseLocation(a.location).href===t.href&&!t.key&&(r="replace"),"replace"===r?a.replace({pathname:t.pathname,hash:t.hash,search:t.searchStr},{id:n}):a.push({pathname:t.pathname,hash:t.hash,search:t.searchStr},{id:n}),o.navigationPromise=new Promise((t=>{const e=o.resolveNavigation;o.resolveNavigation=()=>{e(),t()}})),o.navigationPromise},buildNext:t=>{const e=o.buildLocation(t),n=o.matchRoutes(e.pathname),a=n.map((t=>{var e;return null!=(e=t.options.preSearchFilters)?e:[]})).flat().filter(Boolean),r=n.map((t=>{var e;return null!=(e=t.options.postSearchFilters)?e:[]})).flat().filter(Boolean);return o.buildLocation(C({},t,{__preSearchFilters:a,__postSearchFilters:r}))},cancelMatches:()=>{var t,e;[...o.state.matches,...null!=(t=null==(e=o.state.pending)?void 0:e.matches)?t:[]].forEach((t=>{t.cancel()}))},loadLocation:async t=>{const e=Math.random();o.startedLoadingAt=e,t&&(o.location=t),o.removeActionQueue.forEach((t=>{let{action:e,actionState:n}=t;o.state.currentAction===n&&(o.state.currentAction=void 0),e.current===n&&(e.current=void 0)})),o.removeActionQueue=[],o.cancelMatches();const n=o.matchRoutes(location.pathname,{strictParseParams:!0});if(o.state=C({},o.state,{pending:{matches:n,location:o.location},status:"loading"}),o.notify(),await o.loadMatches(n,{withPending:!0}),o.startedLoadingAt!==e)return o.navigationPromise;const a=o.state.matches,r=[],i=[];a.forEach((t=>{n.find((e=>e.matchId===t.matchId))?i.push(t):r.push(t)}));const s=Date.now();r.forEach((t=>{var e,n,a,r;null==t.__.onExit||t.__.onExit({params:t.params,search:t.routeSearch}),"error"!==t.status||t.isFetching||(t.status="idle",t.error=void 0);const i=Math.max(null!=(e=null!=(n=t.options.loaderGcMaxAge)?n:o.options.defaultLoaderGcMaxAge)?e:0,null!=(a=null!=(r=t.options.loaderMaxAge)?r:o.options.defaultLoaderMaxAge)?a:0);i>0&&(o.matchCache[t.matchId]={gc:i==1/0?Number.MAX_SAFE_INTEGER:s+i,match:t})})),i.forEach((t=>{null==t.options.onTransition||t.options.onTransition({params:t.params,search:t.routeSearch})}));n.filter((t=>!a.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})})),n.some((t=>"loading"===t.status))&&(o.notify(),await Promise.all(n.map((t=>t.__.loaderPromise||Promise.resolve())))),o.startedLoadingAt===e&&(o.state=C({},o.state,{location:o.location,matches:n,pending:void 0,status:"idle"}),o.notify(),o.resolveNavigation())},cleanMatchCache:()=>{const t=Date.now();Object.keys(o.matchCache).forEach((e=>{const n=o.matchCache[e];"loading"!==n.match.status&&(n.gc>0&&n.gc>t||delete o.matchCache[e])}))},loadRoute:async function(t,e){void 0===t&&(t=o.location);const n=o.buildNext(t),a=o.matchRoutes(n.pathname,{strictParseParams:!0});return await o.loadMatches(a,{preload:!0,maxAge:e.maxAge}),a},matchRoutes:(t,e)=>{var n,a;o.cleanMatchCache();const r=[];if(!o.routeTree)return r;const i=[...o.state.matches,...null!=(n=null==(a=o.state.pending)?void 0:a.matches)?n:[]],s=async n=>{var a,l,c;const u=g(r);let h=null!=(a=null==u?void 0:u.params)?a:{};const d=null!=(l=null==o.options.filterRoutes?void 0:o.options.filterRoutes(n))?l:n;let p=[];const f=(n,a)=>(a.some((a=>{var r,i,s;if(!a.routePath&&null!=(r=a.childRoutes)&&r.length)return f([...p,a],a.childRoutes);const l=!!("/"!==a.routePath||null!=(i=a.childRoutes)&&i.length),c=A(t,{to:a.fullPath,fuzzy:l,caseSensitive:null!=(s=a.options.caseSensitive)?s:o.options.caseSensitive});if(c){let t;try{var u;t=null!=(u=null==a.options.parseParams?void 0:a.options.parseParams(c))?u:c}catch(t){if(null!=e&&e.strictParseParams)throw t}h=C({},h,t)}return c&&(p=[...n,a]),!!p.length})),!!p.length);if(f([],d),!p.length)return;p.forEach((e=>{var n;const a=I(e.routePath,h),s=I(e.routeId,h,!0),l=i.find((t=>t.matchId===s))||(null==(n=o.matchCache[s])?void 0:n.match)||j(o,e,{matchId:s,params:h,pathname:_([t,a])});r.push(l)}));const m=g(p);null!=(c=m.childRoutes)&&c.length&&s(m.childRoutes)};return s([o.routeTree]),D(r),r},loadMatches:async(t,e)=>{const n=Date.now(),a=t.map((async t=>{if(t.__.validate(),null!=e&&e.preload&&(null==e?void 0:e.maxAge)>0){if(o.state.matches.find((e=>e.matchId===t.matchId)))return;o.matchCache[t.matchId]={gc:n+e.maxAge,match:t}}("success"===t.status&&t.getIsInvalid()||"error"===t.status||"idle"===t.status)&&t.load(),"loading"===t.status&&(null!=e&&e.withPending&&t.__.startPending(),await t.__.loadPromise)}));o.notify(),await Promise.all(a)},invalidateRoute:t=>{var e,n;const a=o.buildNext(t),r=o.matchRoutes(a.pathname).map((t=>t.matchId));[...o.state.matches,...null!=(e=null==(n=o.state.pending)?void 0:n.matches)?e:[]].forEach((t=>{r.includes(t.matchId)&&t.invalidate()}))},reload:()=>o._navigate({fromCurrent:!0,replace:!0,search:!0}),resolvePath:(t,e)=>L(o.basepath,t,P(e)),matchRoute:(t,e)=>{var n;t=C({},t,{to:t.to?o.resolvePath(null!=(n=t.from)?n:"",t.to):void 0});const a=o.buildNext(t);var r;return null!=e&&e.pending?!(null==(r=o.state.pending)||!r.location)&&!!A(o.state.pending.location.pathname,C({},e,{to:a.pathname})):!!A(o.state.location.pathname,C({},e,{to:a.pathname}))},_navigate:t=>{const e=o.buildNext(t);return o.commitLocation(e,t.replace)},navigate:async t=>{let{from:e,to:n=".",search:a,hash:r,replace:i,params:s}=t;const l=String(n),c=String(e);let u;try{new URL(""+l),u=!0}catch(t){}return p(!u),o._navigate({from:c,to:l,search:a,hash:r,replace:i,params:s})},buildLink:t=>{var e,n,a,r;let{from:i,to:s=".",search:l,params:c,hash:u,target:h,replace:d,activeOptions:p,preload:f,preloadMaxAge:m,preloadDelay:v,disabled:g}=t;try{return new URL(""+s),{type:"external",href:s}}catch(t){}const y={from:i,to:s,search:l,params:c,hash:u,replace:d},_=o.buildNext(y);f=null!=(e=f)?e:o.options.defaultLinkPreload;const P=null!=(n=null!=(a=null!=m?m:o.options.defaultLinkPreloadMaxAge)?a:o.options.defaultLoaderGcMaxAge)?n:0,b=null!=(r=null!=v?v:o.options.defaultLinkPreloadDelay)?r:0,w=o.state.location.pathname===_.pathname,R=o.state.location.pathname.split("/"),L=_.pathname.split("/").every(((t,e)=>t===R[e])),S=o.state.location.hash===_.hash,I=null!=p&&p.exact?w:L,A=null==p||!p.includeHash||S;return{type:"internal",next:_,handleFocus:t=>{f&&P>0&&o.loadRoute(y,{maxAge:P})},handleClick:t=>{g||function(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}(t)||t.defaultPrevented||h&&"_self"!==h||0!==t.button||(t.preventDefault(),!w||l||u||o.invalidateRoute(y),o._navigate(y))},handleEnter:t=>{const e=t.target||{};if(f&&P>0){if(e.preloadTimeout)return;e.preloadTimeout=setTimeout((()=>{e.preloadTimeout=null,o.loadRoute(y,{maxAge:P})}),b)}},handleLeave:t=>{const e=t.target||{};e.preloadTimeout&&(clearTimeout(e.preloadTimeout),e.preloadTimeout=null)},isActive:I&&A,disabled:g}}};return o.location=o.parseLocation(a.location),o.state.location=o.location,o.update(t),null==o.options.createRouter||o.options.createRouter(o),o},t.decode=k,t.defaultParseSearch=N,t.defaultStringifySearch=B,t.encode=x,t.functionalUpdate=y,t.interpolatePath=I,t.invariant=p,t.joinPaths=_,t.last=g,t.matchByPath=E,t.matchPathname=A,t.parsePathname=S,t.parseSearchWith=H,t.replaceEqualDeep=f,t.resolvePath=L,t.rootRouteId=O,t.stringifySearchWith=U,t.trimPath=R,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})}));
12
12
  //# sourceMappingURL=index.production.js.map