@tanstack/router-core 0.0.1-beta.36 → 0.0.1-beta.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/index.js +2 -1
- package/build/cjs/index.js.map +1 -1
- package/build/cjs/path.js +5 -7
- package/build/cjs/path.js.map +1 -1
- package/build/cjs/route.js +112 -95
- package/build/cjs/route.js.map +1 -1
- package/build/cjs/routeConfig.js +2 -2
- package/build/cjs/routeConfig.js.map +1 -1
- package/build/cjs/routeMatch.js +107 -65
- package/build/cjs/routeMatch.js.map +1 -1
- package/build/cjs/router.js +320 -351
- package/build/cjs/router.js.map +1 -1
- package/build/cjs/searchParams.js +4 -3
- package/build/cjs/searchParams.js.map +1 -1
- package/build/cjs/sharedClone.js +122 -0
- package/build/cjs/sharedClone.js.map +1 -0
- package/build/cjs/utils.js +1 -59
- package/build/cjs/utils.js.map +1 -1
- package/build/esm/index.js +654 -592
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +183 -158
- package/build/types/index.d.ts +54 -68
- package/build/umd/index.development.js +1000 -595
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +1 -1
- package/build/umd/index.production.js.map +1 -1
- package/package.json +2 -1
- package/src/index.ts +1 -0
- package/src/link.ts +20 -12
- package/src/route.ts +160 -139
- package/src/routeMatch.ts +144 -99
- package/src/router.ts +402 -491
- package/src/sharedClone.ts +118 -0
- package/src/utils.ts +0 -65
- package/build/cjs/_virtual/_rollupPluginBabelHelpers.js +0 -31
- package/build/cjs/_virtual/_rollupPluginBabelHelpers.js.map +0 -1
|
@@ -8,5 +8,5 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
11
|
-
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).RouterCore={})}(this,(function(t){"use strict";function e(){return e=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var a=arguments[e];for(var n in a)Object.prototype.hasOwnProperty.call(a,n)&&(t[n]=a[n])}return t},e.apply(this,arguments)}var a;!function(t){t.Pop="POP",t.Push="PUSH",t.Replace="REPLACE"}(a||(a={}));var n="beforeunload",o="popstate";function r(t){void 0===t&&(t={});var r=t.window,s=void 0===r?document.defaultView:r,i=s.history;function p(){var t=s.location,e=t.pathname,a=t.search,n=t.hash,o=i.state||{};return[o.idx,{pathname:e,search:a,hash:n,state:o.usr||null,key:o.key||"default"}]}var f=null;s.addEventListener(o,(function(){if(f)L.call(f),f=null;else{var t=a.Pop,e=p(),n=e[0],o=e[1];if(L.length){if(null!=n){var r=g-n;r&&(f={action:t,location:o,retry:function(){A(-1*r)}},A(r))}}else x(t)}}));var v=a.Pop,m=p(),g=m[0],y=m[1],_=l(),L=l();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 P(t,e){return[{usr:t.state,key:t.key,idx:e},b(t)]}function M(t,e,a){return!L.length||(L.call({action:t,location:e,retry:a}),!1)}function x(t){v=t;var e=p();g=e[0],y=e[1],_.call({action:v,location:y})}function A(t){i.go(t)}null==g&&(g=0,i.replaceState(e({},i.state,{idx:g}),""));var R={get action(){return v},get location(){return y},createHref:b,push:function t(e,n){var o=a.Push,r=w(e,n);if(M(o,r,(function(){t(e,n)}))){var c=P(r,g+1),l=c[0],u=c[1];try{i.pushState(l,"",u)}catch(t){s.location.assign(u)}x(o)}},replace:function t(e,n){var o=a.Replace,r=w(e,n);if(M(o,r,(function(){t(e,n)}))){var s=P(r,g),c=s[0],l=s[1];i.replaceState(c,"",l),x(o)}},go:A,back:function(){A(-1)},forward:function(){A(1)},listen:function(t){return _.push(t)},block:function(t){var e=L.push(t);return 1===L.length&&s.addEventListener(n,c),function(){e(),L.length||s.removeEventListener(n,c)}}};return R}function s(t){void 0===t&&(t={});var n=t,o=n.initialEntries,r=void 0===o?["/"]:o,s=n.initialIndex,c=r.map((function(t){return e({pathname:"/",search:"",hash:"",state:null,key:u()},"string"==typeof t?d(t):t)})),p=i(null==s?c.length-1:s,0,c.length-1),f=a.Pop,v=c[p],m=l(),g=l();function y(t,a){return void 0===a&&(a=null),e({pathname:v.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 L(t,e){f=t,v=e,m.call({action:f,location:v})}function b(t){var e=i(p+t,0,c.length-1),n=a.Pop,o=c[e];_(n,o,(function(){b(t)}))&&(p=e,L(n,o))}var w={get index(){return p},get action(){return f},get location(){return v},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,c.splice(p,c.length,r),L(o,r))},replace:function t(e,n){var o=a.Replace,r=y(e,n);_(o,r,(function(){t(e,n)}))&&(c[p]=r,L(o,r))},go:b,back:function(){b(-1)},forward:function(){b(1)},listen:function(t){return m.push(t)},block:function(t){return g.push(t)}};return w}function i(t,e,a){return Math.min(Math.max(t,e),a)}function c(t){t.preventDefault(),t.returnValue=""}function l(){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,s=void 0===r?"":r;return o&&"?"!==o&&(a+="?"===o.charAt(0)?o:"?"+o),s&&"#"!==s&&(a+="#"===s.charAt(0)?s:"#"+s),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||v(t)&&v(e)){const n=a?t.length:Object.keys(t).length,o=a?e:Object.keys(e),r=o.length,s=a?[]:{};let i=0;for(let n=0;n<r;n++){const r=a?n:o[n];s[r]=f(t[r],e[r]),s[r]===t[r]&&i++}return n===r&&i===n?t:s}return e}function v(t){if(!m(t))return!1;const e=t.constructor;if(void 0===e)return!0;const a=e.prototype;return!!m(a)&&!!a.hasOwnProperty("isPrototypeOf")}function m(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,e){return e.reduce(((e,a)=>(e[a]=t[a],e)),{})}function L(t){return b(t.filter(Boolean).join("/"))}function b(t){return t.replace(/\/{2,}/g,"/")}function w(t){return"/"===t?t:t.replace(/^\/{1,}/,"")}function P(t){return"/"===t?t:t.replace(/\/{1,}$/,"")}function M(t){return P(w(t))}function x(t,e,a){e=e.replace(new RegExp("^"+t),"/"),a=a.replace(new RegExp("^"+t),"/");let n=A(e);const o=A(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 b(L([t,...n.map((t=>t.value))]))}function A(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 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 R(t,e,a){return L(A(t).map((t=>{return"*"!==t.value||a?"param"===t.type?null!=(n=e[t.value.substring(1)])?n:"":t.value:"";var n})))}function I(t,e,a){const n=E(t,e,a);if(!a.to||n)return null!=n?n:{}}function E(t,e,a){var n;if(!e.startsWith(t))return;const o=A(e="/"!=t?e.substring(t.length):e),r=A(""+(null!=(n=a.to)?n:"*")),s={};return(()=>{for(let t=0;t<Math.max(o.length,r.length);t++){const e=o[t],n=r[t],i=t===r.length-1,c=t===o.length-1;if(n){if("wildcard"===n.type)return!(null==e||!e.value)&&(s["*"]=L(o.slice(t).map((t=>t.value))),!0);if("pathname"===n.type){if("/"===n.value&&(null==e||!e.value))return!0;if(e)if(a.caseSensitive){if(n.value!==e.value)return!1}else if(n.value.toLowerCase()!==e.value.toLowerCase())return!1}if(!e)return!1;if("param"===n.type){if("/"===(null==e?void 0:e.value))return!1;"$"!==e.value.charAt(0)&&(s[n.value.substring(1)]=e.value)}}if(i&&!c)return!!a.fuzzy}return!0})()?s:void 0}function S(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 C(t){if(!t)return"";var e=decodeURIComponent(t);return"false"!==e&&("true"===e||("0"===e.charAt(0)?e:0*+e==0?+e:e))}function k(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],C(e.shift())):n[a]=C(e.shift());return n}function D(){return D=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},D.apply(this,arguments)}function O(t,e,a,n){const{id:o,routeId:r,path:s,fullPath:i}=t,c=n.state.actions[o]||(n.state.actions[o]={submissions:[],submit:async(t,e)=>{var a;if(!u)return;const o=null==(a=null==e?void 0:e.invalidate)||a;null!=e&&e.multi||(c.submissions=c.submissions.filter((t=>t.isMulti)));const r={submittedAt:Date.now(),status:"pending",submission:t,isMulti:!(null==e||!e.multi)};c.current=r,c.latest=r,c.submissions.push(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{n.notify()}}},n.state.actions[o]),l=n.state.loaders[o]||(n.state.loaders[o]={pending:[],fetch:async t=>{if(!u)return;const e={loadedAt:Date.now(),loaderContext:t};l.current=e,l.latest=e,l.pending.push(e),n.notify();try{return await(null==u.options.loader?void 0:u.options.loader(t))}finally{l.pending=l.pending.filter((t=>t!==e)),n.notify()}}},n.state.loaders[o]);let u={routeInfo:void 0,routeId:o,routeRouteId:r,routePath:s,fullPath:i,options:e,router:n,childRoutes:void 0,parentRoute:a,action:c,loader:l,buildLink:t=>n.buildLink(D({},t,{from:i})),navigate:t=>n.navigate(D({},t,{from:i})),matchRoute:(t,e)=>n.matchRoute(D({},t,{from:i}),e)};return null==n.options.createRoute||n.options.createRoute({router:n,route:u}),u}const F="__root__",j=["component","errorComponent","pendingComponent"];function T(t,e,a){const n=D({},e,a,{router:t,routeSearch:{},search:{},childMatches:[],status:"idle",routeLoaderData:{},loaderData:{},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()},validate:()=>{var e,a;const o=null!=(e=null==(a=n.parentMatch)?void 0:a.search)?e:t.state.currentLocation.search;try{var r;const t=n.routeSearch,e="object"==typeof n.options.validateSearch?n.options.validateSearch.parse:n.options.validateSearch;let a=f(t,null!=(r=null==e?void 0:e(o))?r:{});t!==a&&(n.isInvalid=!0),n.routeSearch=a,n.search=f(o,D({},o,a)),j.map((async t=>{const e=n.options[t];"function"!=typeof n.__[t]&&(n.__[t]=e)}))}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()},invalidate:()=>{n.isInvalid=!0},hasLoaders:()=>!(!e.options.loader&&!j.some((t=>{var a;return null==(a=e.options[t])?void 0:a.preload}))),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.currentMatches.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;await n.fetch({maxAge:t})}},fetch:async e=>{const a=""+Date.now()+Math.random();n.__.latestId=a;const o=async()=>{if(a!==n.__.latestId)return new Promise((()=>{}))};"idle"===n.status&&(n.status="loading"),n.isInvalid=!1,n.__.loadPromise=new Promise((async a=>{n.isFetching=!0,n.__.resolve=a,n.__.componentsPromise=(async()=>{await Promise.all(j.map((async e=>{var a;const o=n.options[e];null!=(a=n.__[e])&&a.preload&&(n.__[e]=await t.options.loadComponent(o))})))})(),n.__.dataPromise=Promise.resolve().then((async()=>{try{var a,r,s;if(n.options.loader){const e=await t.loadMatchData(n);await o(),n.routeLoaderData=f(n.routeLoaderData,e)}return n.error=void 0,n.status="success",n.updatedAt=Date.now(),n.invalidAt=n.updatedAt+(null!=(a=null!=(r=null!=(s=null==e?void 0:e.maxAge)?s:n.options.loaderMaxAge)?r:t.options.defaultLoaderMaxAge)?a:0),n.routeLoaderData}catch(t){throw await o(),n.error=t,n.status="error",n.updatedAt=Date.now(),t}}));const r=async()=>{await o(),n.isFetching=!1,delete n.__.loadPromise,n.__.notify()};try{await Promise.all([n.__.componentsPromise,n.__.dataPromise.catch((()=>{}))]),r()}catch(t){r()}})),await n.__.loadPromise,await o()}});return n.hasLoaders()||(n.status="success"),n}const N=U(JSON.parse),B=H(JSON.stringify);function U(t){return e=>{"?"===e.substring(0,1)&&(e=e.substring(1));let a=k(e);for(let e in a){const n=a[e];if("string"==typeof n)try{a[e]=t(n)}catch(t){}}return a}}function H(t){return e=>{(e=D({},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=S(e).toString();return a?"?"+a:""}}var G;const z="undefined"==typeof window||!(null!=(G=window.document)&&G.createElement);function K(){return{status:"idle",latestLocation:null,currentLocation:null,currentMatches:[],actions:{},loaders:{},lastUpdated:Date.now(),isFetching:!1,isPreloading:!1}}function V(t){t.forEach(((e,a)=>{const n=t[a-1];n&&(e.loaderData=f(e.loaderData,D({},n.loaderData,e.routeLoaderData)))}))}t.cleanPath=b,t.createBrowserHistory=r,t.createHashHistory=function(t){void 0===t&&(t={});var r=t.window,s=void 0===r?document.defaultView:r,i=s.history;function p(){var t=d(s.location.hash.substr(1)),e=t.pathname,a=void 0===e?"/":e,n=t.search,o=void 0===n?"":n,r=t.hash,c=void 0===r?"":r,l=i.state||{};return[l.idx,{pathname:a,search:o,hash:c,state:l.usr||null,key:l.key||"default"}]}var f=null;function v(){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(){R(-1*r)}},R(r))}}else A(t)}}s.addEventListener(o,v),s.addEventListener("hashchange",(function(){h(p()[1])!==h(_)&&v()}));var m=a.Pop,g=p(),y=g[0],_=g[1],L=l(),b=l();function w(t){return function(){var t=document.querySelector("base"),e="";if(t&&t.getAttribute("href")){var a=s.location.href,n=a.indexOf("#");e=-1===n?a:a.slice(0,n)}return e}()+"#"+("string"==typeof t?t:h(t))}function P(t,a){return void 0===a&&(a=null),e({pathname:_.pathname,hash:"",search:""},"string"==typeof t?d(t):t,{state:a,key:u()})}function M(t,e){return[{usr:t.state,key:t.key,idx:e},w(t)]}function x(t,e,a){return!b.length||(b.call({action:t,location:e,retry:a}),!1)}function A(t){m=t;var e=p();y=e[0],_=e[1],L.call({action:m,location:_})}function R(t){i.go(t)}null==y&&(y=0,i.replaceState(e({},i.state,{idx:y}),""));var I={get action(){return m},get location(){return _},createHref:w,push:function t(e,n){var o=a.Push,r=P(e,n);if(x(o,r,(function(){t(e,n)}))){var c=M(r,y+1),l=c[0],u=c[1];try{i.pushState(l,"",u)}catch(t){s.location.assign(u)}A(o)}},replace:function t(e,n){var o=a.Replace,r=P(e,n);if(x(o,r,(function(){t(e,n)}))){var s=M(r,y),c=s[0],l=s[1];i.replaceState(c,"",l),A(o)}},go:R,back:function(){R(-1)},forward:function(){R(1)},listen:function(t){return L.push(t)},block:function(t){var e=b.push(t);return 1===b.length&&s.addEventListener(n,c),function(){e(),b.length||s.removeEventListener(n,c)}}};return I},t.createMemoryHistory=s,t.createRoute=O,t.createRouteConfig=function t(e,a,n,o,r){void 0===e&&(e={}),void 0===n&&(n=!0),n&&(e.path=F),o===F&&(o="");let s=n?F:e.path;s&&"/"!==s&&(s=M(s));const i=s||e.id;let c=L([o,i]);s===F&&(s="/"),c!==F&&(c=L(["/",c]));const l=c===F?"/":P(L([r,s]));return{id:c,routeId:i,path:s,fullPath:l,options:e,children:a,addChildren:a=>t(e,a,!1,o,r),createRoute:e=>t(e,void 0,!1,c,l),generate:()=>{p(!1)}}},t.createRouteMatch=T,t.createRouter=function(t){var e,a;const n=(null==t?void 0:t.history)||(z?s():r()),o=D({defaultLoaderGcMaxAge:3e5,defaultLoaderMaxAge:0,defaultPreloadMaxAge:2e3,defaultPreloadDelay:50,context:void 0},t,{stringifySearch:null!=(e=null==t?void 0:t.stringifySearch)?e:B,parseSearch:null!=(a=null==t?void 0:t.parseSearch)?a:N});let i={types:void 0,history:n,options:o,listeners:[],basepath:"",routeTree:void 0,routesById:{},resolveNavigation:()=>{},matchCache:{},state:K(),reset:()=>{i.state=K(),i.notify()},startedLoadingAt:Date.now(),subscribe:t=>(i.listeners.push(t),()=>{i.listeners=i.listeners.filter((e=>e!==t))}),getRoute:t=>i.routesById[t],notify:()=>{const t="loading"===i.state.status||i.state.currentMatches.some((t=>t.isFetching)),e=Object.values(i.matchCache).some((t=>t.match.isFetching&&!i.state.currentMatches.find((e=>e.matchId===t.match.matchId))));i.state.isFetching===t&&i.state.isPreloading===e||(i.state=D({},i.state,{isFetching:t,isPreloading:e})),V(i.state.currentMatches),i.listeners.forEach((t=>t(i)))},dehydrate:()=>({state:D({},_(i.state,["latestLocation","currentLocation","status","lastUpdated"]),{currentMatches:i.state.currentMatches.map((t=>_(t,["matchId","status","routeLoaderData","loaderData","isInvalid","invalidAt"])))}),context:i.options.context}),hydrate:t=>{i.state.latestLocation=t.state.latestLocation,i.state.currentLocation=t.state.currentLocation,i.options.context=t.context;const e=i.matchRoutes(i.state.latestLocation.pathname,{strictParseParams:!0});e.forEach(((e,a)=>{const n=t.state.currentMatches[a];p(n),Object.assign(e,n)})),e.forEach((t=>t.__.validate())),i.state=D({},i.state,t,{currentMatches:e})},mount:()=>{i.state.currentMatches.length||i.load();const t=i.history.listen((t=>{i.load(i.__.parseLocation(t.location,i.state.latestLocation))}));return!z&&window.addEventListener&&(window.addEventListener("visibilitychange",i.onFocus,!1),window.addEventListener("focus",i.onFocus,!1)),()=>{t(),!z&&window.removeEventListener&&(window.removeEventListener("visibilitychange",i.onFocus),window.removeEventListener("focus",i.onFocus))}},onFocus:()=>{i.load()},update:t=>{var e;const a=(null==t?void 0:t.history)!==i.history;i.state.latestLocation&&!a||(null!=t&&t.history&&(i.history=t.history),i.state.latestLocation=i.__.parseLocation(i.history.location),i.state.currentLocation=i.state.latestLocation),Object.assign(i.options,t);const{basepath:n,routeConfig:o}=i.options;return i.basepath="/"+(null!=(e=M(null!=n?n:""))?e:""),o&&(i.routesById={},i.routeTree=i.__.buildRouteTree(o)),i},cancelMatches:()=>{var t;[...i.state.currentMatches,...null!=(t=i.state.pendingMatches)?t:[]].forEach((t=>{t.cancel()}))},load:async t=>{const e=Math.random();i.startedLoadingAt=e,t&&(i.state.latestLocation=t),i.cancelMatches();const a=i.matchRoutes(i.state.latestLocation.pathname,{strictParseParams:!0});"undefined"!=typeof document?i.state=D({},i.state,{status:"loading",pendingMatches:a,pendingLocation:i.state.latestLocation}):i.state=D({},i.state,{status:"loading",currentMatches:a,currentLocation:i.state.latestLocation}),i.notify();try{await i.loadMatches(a)}catch(t){console.log(t),p(!1)}if(i.startedLoadingAt!==e)return i.navigationPromise;const n=i.state.currentMatches,o=[],r=[];n.forEach((t=>{a.find((e=>e.matchId===t.matchId))?r.push(t):o.push(t)}));const s=a.filter((t=>!n.find((e=>e.matchId===t.matchId)))),c=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:i.options.defaultLoaderGcMaxAge)?e:0,null!=(n=null!=(o=t.options.loaderMaxAge)?o:i.options.defaultLoaderMaxAge)?n:0);r>0&&(i.matchCache[t.matchId]={gc:r==1/0?Number.MAX_SAFE_INTEGER:c+r,match:t})})),r.forEach((t=>{null==t.options.onTransition||t.options.onTransition({params:t.params,search:t.routeSearch})})),s.forEach((t=>{t.__.onExit=null==t.options.onLoaded?void 0:t.options.onLoaded({params:t.params,search:t.search}),delete i.matchCache[t.matchId]})),i.startedLoadingAt===e&&(a.forEach((t=>{t.action&&(t.action.current=void 0,t.action.submissions=[])})),i.state=D({},i.state,{status:"idle",currentLocation:i.state.latestLocation,currentMatches:a,pendingLocation:void 0,pendingMatches:void 0}),i.notify(),i.resolveNavigation())},cleanMatchCache:()=>{const t=Date.now();Object.keys(i.matchCache).forEach((e=>{const a=i.matchCache[e];"loading"!==a.match.status&&(a.gc>0&&a.gc>t||delete i.matchCache[e])}))},loadRoute:async function(t){void 0===t&&(t=i.state.latestLocation);const e=i.buildNext(t),a=i.matchRoutes(e.pathname,{strictParseParams:!0});return await i.loadMatches(a),a},preloadRoute:async function(t,e){var a,n,o,r,s,c;void 0===t&&(t=i.state.latestLocation);const l=i.buildNext(t),u=i.matchRoutes(l.pathname,{strictParseParams:!0});return await i.loadMatches(u,{preload:!0,maxAge:null!=(a=null!=(n=null!=(o=e.maxAge)?o:i.options.defaultPreloadMaxAge)?n:i.options.defaultLoaderMaxAge)?a:0,gcMaxAge:null!=(r=null!=(s=null!=(c=e.gcMaxAge)?c:i.options.defaultPreloadGcMaxAge)?s:i.options.defaultLoaderGcMaxAge)?r:0}),u},matchRoutes:(t,e)=>{var a;i.cleanMatchCache();const n=[];if(!i.routeTree)return n;const o=[...i.state.currentMatches,...null!=(a=i.state.pendingMatches)?a:[]],r=async a=>{var s,c,l;const u=g(n);let h=null!=(s=null==u?void 0:u.params)?s:{};const d=null!=(c=null==i.options.filterRoutes?void 0:i.options.filterRoutes(a))?c:a;let p=[];const f=(a,n)=>(n.some((n=>{var o,r,s;if(!n.routePath&&null!=(o=n.childRoutes)&&o.length)return f([...p,n],n.childRoutes);const c=!!("/"!==n.routePath||null!=(r=n.childRoutes)&&r.length),l=I(i.basepath,t,{to:n.fullPath,fuzzy:c,caseSensitive:null!=(s=n.options.caseSensitive)?s:i.options.caseSensitive});if(l){let t;try{var u;t=null!=(u=null==n.options.parseParams?void 0:n.options.parseParams(l))?u:l}catch(t){if(null!=e&&e.strictParseParams)throw t}h=D({},h,t)}return l&&(p=[...a,n]),!!p.length})),!!p.length);if(f([],d),!p.length)return;p.forEach((t=>{var e;const a=R(t.routePath,h),r=R(t.routeId,h,!0),s=o.find((t=>t.matchId===r))||(null==(e=i.matchCache[r])?void 0:e.match)||T(i,t,{parentMatch:u,matchId:r,params:h,pathname:L([i.basepath,a])});n.push(s)}));const v=g(p);null!=(l=v.childRoutes)&&l.length&&r(v.childRoutes)};return r([i.routeTree]),V(n),n},loadMatches:async(t,e)=>{t.forEach((async t=>{t.__.validate()})),await Promise.all(t.map((async t=>{try{await(null==t.options.beforeLoad?void 0:t.options.beforeLoad({router:i,match:t}))}catch(a){throw null!=e&&e.preload||null==t.options.onLoadError||t.options.onLoadError(a),a}})));const a=t.map((async t=>{var a;const n=t.search;null!=(a=n.__data)&&a.matchId&&n.__data.matchId!==t.matchId||(t.load(e),"success"!==t.status&&t.__.loadPromise&&await t.__.loadPromise)}));i.notify(),await Promise.all(a)},loadMatchData:async t=>{var e;if(z||!i.options.useServerData)return null!=(e=await(null==t.options.loader?void 0:t.options.loader({params:t.params,search:t.routeSearch,signal:t.__.abortController.signal})))?e:{};{const e=i.buildNext({to:".",search:e=>D({},null!=e?e:{},{__data:{matchId:t.matchId}})}),a=await fetch(e.href,{method:"GET"});if(a.ok)return a.json();throw new Error("Failed to fetch match data")}},invalidateRoute:t=>{var e;const a=i.buildNext(t),n=i.matchRoutes(a.pathname).map((t=>t.matchId));[...i.state.currentMatches,...null!=(e=i.state.pendingMatches)?e:[]].forEach((t=>{n.includes(t.matchId)&&t.invalidate()}))},reload:()=>i.__.navigate({fromCurrent:!0,replace:!0,search:!0}),resolvePath:(t,e)=>x(i.basepath,t,b(e)),matchRoute:(t,e)=>{var a;t=D({},t,{to:t.to?i.resolvePath(null!=(a=t.from)?a:"",t.to):void 0});const n=i.buildNext(t);return null!=e&&e.pending?!!i.state.pendingLocation&&!!I(i.basepath,i.state.pendingLocation.pathname,D({},e,{to:n.pathname})):!!I(i.basepath,i.state.currentLocation.pathname,D({},e,{to:n.pathname}))},navigate:async t=>{let{from:e,to:a=".",search:n,hash:o,replace:r,params:s}=t;const c=String(a),l=String(e);let u;try{new URL(""+c),u=!0}catch(t){}return p(!u),i.__.navigate({from:l,to:c,search:n,hash:o,replace:r,params:s})},buildLink:t=>{var e,a;let{from:n,to:o=".",search:r,params:s,hash:c,target:l,replace:u,activeOptions:h,preload:d,preloadMaxAge:p,preloadGcMaxAge:f,preloadDelay:v,disabled:m}=t;try{return new URL(""+o),{type:"external",href:o}}catch(t){}const g={from:n,to:o,search:r,params:s,hash:c,replace:u},y=i.buildNext(g);d=null!=(e=d)?e:i.options.defaultPreload;const _=null!=(a=null!=v?v:i.options.defaultPreloadDelay)?a:0,L=i.state.currentLocation.pathname===y.pathname,b=i.state.currentLocation.pathname.split("/"),w=y.pathname.split("/").every(((t,e)=>t===b[e])),P=i.state.currentLocation.hash===y.hash,M=null!=h&&h.exact?L:w,x=null==h||!h.includeHash||P;return{type:"internal",next:y,handleFocus:t=>{d&&i.preloadRoute(g,{maxAge:p,gcMaxAge:f}).catch((t=>{console.log(t),console.warn("Error preloading route! ☝️")}))},handleClick:t=>{m||function(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}(t)||t.defaultPrevented||l&&"_self"!==l||0!==t.button||(t.preventDefault(),!L||r||c||i.invalidateRoute(g),i.__.navigate(g))},handleEnter:t=>{const e=t.target||{};if(d){if(e.preloadTimeout)return;e.preloadTimeout=setTimeout((()=>{e.preloadTimeout=null,i.preloadRoute(g,{maxAge:p,gcMaxAge:f}).catch((t=>{console.log(t),console.warn("Error preloading route! ☝️")}))}),_)}},handleLeave:t=>{const e=t.target||{};e.preloadTimeout&&(clearTimeout(e.preloadTimeout),e.preloadTimeout=null)},isActive:M&&x,disabled:m}},buildNext:t=>{const e=i.__.buildLocation(t),a=i.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 i.__.buildLocation(D({},t,{__preSearchFilters:n,__postSearchFilters:o}))},__:{buildRouteTree:t=>{const e=(t,a)=>t.map((t=>{const n=O(t,t.options,a,i);if(i.routesById[n.routeId])throw new Error;i.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=i.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=i.buildNext(t);return i.__.commitLocation(e,t.replace)},buildLocation:function(t){var e,a,n,o,r,s,c,l,u;void 0===t&&(t={});const h=t.fromCurrent?i.state.latestLocation.pathname:null!=(e=t.from)?e:i.state.latestLocation.pathname;let d=x(null!=(a=i.basepath)?a:"/",h,""+(null!=(n=t.to)?n:"."));const p=i.matchRoutes(i.state.latestLocation.pathname,{strictParseParams:!0}),v=i.matchRoutes(d),m=D({},null==(o=g(p))?void 0:o.params);let _=!0===(null==(r=t.params)||r)?m:y(t.params,m);_&&v.map((t=>t.options.stringifyParams)).filter(Boolean).forEach((t=>{Object.assign({},_,t(_))})),d=R(d,null!=_?_:{});const L=null!=(s=t.__preSearchFilters)&&s.length?t.__preSearchFilters.reduce(((t,e)=>e(t)),i.state.latestLocation.search):i.state.latestLocation.search,b=!0===t.search?L:t.search?null!=(c=y(t.search,L))?c:{}:null!=(l=t.__preSearchFilters)&&l.length?L:{},w=null!=(u=t.__postSearchFilters)&&u.length?t.__postSearchFilters.reduce(((t,e)=>e(t)),b):b,P=f(i.state.latestLocation.search,w),M=i.options.stringifySearch(P);let A=!0===t.hash?i.state.latestLocation.hash:y(t.hash,i.state.latestLocation.hash);return A=A?"#"+A:"",{pathname:d,search:P,searchStr:M,state:i.state.latestLocation.state,hash:A,href:""+d+M+A,key:t.key}},commitLocation:(t,e)=>{const a=""+Date.now()+Math.random();i.navigateTimeout&&clearTimeout(i.navigateTimeout);let o="replace";e||(o="push");return i.__.parseLocation(n.location).href===t.href&&!t.key&&(o="replace"),"replace"===o?n.replace({pathname:t.pathname,hash:t.hash,search:t.searchStr},D({id:a},t.state)):n.push({pathname:t.pathname,hash:t.hash,search:t.searchStr},{id:a}),i.navigationPromise=new Promise((t=>{const e=i.resolveNavigation;i.resolveNavigation=()=>{e(),t(),delete i.navigationPromise}})),i.navigationPromise}}};return i.update(t),null==i.options.createRouter||i.options.createRouter(i),i},t.decode=k,t.defaultParseSearch=N,t.defaultStringifySearch=B,t.encode=S,t.functionalUpdate=y,t.interpolatePath=R,t.invariant=p,t.joinPaths=L,t.last=g,t.matchByPath=E,t.matchPathname=I,t.parsePathname=A,t.parseSearchWith=U,t.pick=_,t.replaceEqualDeep=f,t.resolvePath=x,t.rootRouteId=F,t.stringifySearchWith=H,t.trimPath=M,t.trimPathLeft=w,t.trimPathRight=P,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 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",r="popstate";function o(t){void 0===t&&(t={});var o=t.window,s=void 0===o?document.defaultView:o,i=s.history;function f(){var t=s.location,e=t.pathname,a=t.search,n=t.hash,r=i.state||{};return[r.idx,{pathname:e,search:a,hash:n,state:r.usr||null,key:r.key||"default"}]}var p=null;s.addEventListener(r,(function(){if(p)w.call(p),p=null;else{var t=a.Pop,e=f(),n=e[0],r=e[1];if(w.length){if(null!=n){var o=g-n;o&&(p={action:t,location:r,retry:function(){A(-1*o)}},A(o))}}else x(t)}}));var v=a.Pop,m=f(),g=m[0],y=m[1],b=l(),w=l();function P(t){return"string"==typeof t?t:h(t)}function _(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 L(t,e){return[{usr:t.state,key:t.key,idx:e},P(t)]}function M(t,e,a){return!w.length||(w.call({action:t,location:e,retry:a}),!1)}function x(t){v=t;var e=f();g=e[0],y=e[1],b.call({action:v,location:y})}function A(t){i.go(t)}null==g&&(g=0,i.replaceState(e({},i.state,{idx:g}),""));var S={get action(){return v},get location(){return y},createHref:P,push:function t(e,n){var r=a.Push,o=_(e,n);if(M(r,o,(function(){t(e,n)}))){var c=L(o,g+1),l=c[0],u=c[1];try{i.pushState(l,"",u)}catch(t){s.location.assign(u)}x(r)}},replace:function t(e,n){var r=a.Replace,o=_(e,n);if(M(r,o,(function(){t(e,n)}))){var s=L(o,g),c=s[0],l=s[1];i.replaceState(c,"",l),x(r)}},go:A,back:function(){A(-1)},forward:function(){A(1)},listen:function(t){return b.push(t)},block:function(t){var e=w.push(t);return 1===w.length&&s.addEventListener(n,c),function(){e(),w.length||s.removeEventListener(n,c)}}};return S}function s(t){void 0===t&&(t={});var n=t,r=n.initialEntries,o=void 0===r?["/"]:r,s=n.initialIndex,c=o.map((function(t){return e({pathname:"/",search:"",hash:"",state:null,key:u()},"string"==typeof t?d(t):t)})),f=i(null==s?c.length-1:s,0,c.length-1),p=a.Pop,v=c[f],m=l(),g=l();function y(t,a){return void 0===a&&(a=null),e({pathname:v.pathname,search:"",hash:""},"string"==typeof t?d(t):t,{state:a,key:u()})}function b(t,e,a){return!g.length||(g.call({action:t,location:e,retry:a}),!1)}function w(t,e){p=t,v=e,m.call({action:p,location:v})}function P(t){var e=i(f+t,0,c.length-1),n=a.Pop,r=c[e];b(n,r,(function(){P(t)}))&&(f=e,w(n,r))}var _={get index(){return f},get action(){return p},get location(){return v},createHref:function(t){return"string"==typeof t?t:h(t)},push:function t(e,n){var r=a.Push,o=y(e,n);b(r,o,(function(){t(e,n)}))&&(f+=1,c.splice(f,c.length,o),w(r,o))},replace:function t(e,n){var r=a.Replace,o=y(e,n);b(r,o,(function(){t(e,n)}))&&(c[f]=o,w(r,o))},go:P,back:function(){P(-1)},forward:function(){P(1)},listen:function(t){return m.push(t)},block:function(t){return g.push(t)}};return _}function i(t,e,a){return Math.min(Math.max(t,e),a)}function c(t){t.preventDefault(),t.returnValue=""}function l(){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,r=void 0===n?"":n,o=t.hash,s=void 0===o?"":o;return r&&"?"!==r&&(a+="?"===r.charAt(0)?r:"?"+r),s&&"#"!==s&&(a+="#"===s.charAt(0)?s:"#"+s),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 f(t,e){if(!t)throw new Error("Invariant failed")}function p(t){return t[t.length-1]}function v(t,e){return"function"==typeof t?t(e):t}function m(t,e){return e.reduce(((e,a)=>(e[a]=t[a],e)),{})}function g(t){return y(t.filter(Boolean).join("/"))}function y(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 P(t){return w(b(t))}function _(t,e,a){e=e.replace(new RegExp(`^${t}`),"/"),a=a.replace(new RegExp(`^${t}`),"/");let n=L(e);const r=L(a);r.forEach(((t,e)=>{if("/"===t.value)e?e===r.length-1&&n.push(t):n=[t];else if(".."===t.value){var a;n.length>1&&"/"===(null==(a=p(n))?void 0:a.value)&&n.pop(),n.pop()}else{if("."===t.value)return;n.push(t)}}));return y(g([t,...n.map((t=>t.value))]))}function L(t){if(!t)return[];const e=[];if("/"===(t=y(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 g(L(t).map((t=>"*"!==t.value||a?"param"===t.type?e[t.value.substring(1)]??"":t.value:"")))}function x(t,e,a){const n=A(t,e,a);if(!a.to||n)return n??{}}function A(t,e,a){if(!e.startsWith(t))return;const n=L(e="/"!=t?e.substring(t.length):e),r=L(`${a.to??"*"}`),o={};return(()=>{for(let t=0;t<Math.max(n.length,r.length);t++){const e=n[t],s=r[t],i=t===r.length-1,c=t===n.length-1;if(s){if("wildcard"===s.type)return!(null==e||!e.value)&&(o["*"]=g(n.slice(t).map((t=>t.value))),!0);if("pathname"===s.type){if("/"===s.value&&(null==e||!e.value))return!0;if(e)if(a.caseSensitive){if(s.value!==e.value)return!1}else if(s.value.toLowerCase()!==e.value.toLowerCase())return!1}if(!e)return!1;if("param"===s.type){if("/"===(null==e?void 0:e.value))return!1;"$"!==e.value.charAt(0)&&(o[s.value.substring(1)]=e.value)}}if(i&&!c)return!!a.fuzzy}return!0})()?o:void 0}function S(t,e){var a,n,r,o="";for(a in t)if(void 0!==(r=t[a]))if(Array.isArray(r))for(n=0;n<r.length;n++)o&&(o+="&"),o+=encodeURIComponent(a)+"="+encodeURIComponent(r[n]);else o&&(o+="&"),o+=encodeURIComponent(a)+"="+encodeURIComponent(r);return(e||"")+o}function R(t){if(!t)return"";var e=decodeURIComponent(t);return"false"!==e&&("true"===e||("0"===e.charAt(0)?e:0*+e==0?+e:e))}function I(t){for(var e,a,n={},r=t.split("&");e=r.shift();)void 0!==n[a=(e=e.split("=")).shift()]?n[a]=[].concat(n[a],R(e.shift())):n[a]=R(e.shift());return n}var E=void 0,O=null,j=0,C=null;function D(){if(C){for(let t=0;t<C.length;t++)C[t].get();C=null}}function k(t){C=[];let e=t();return D(),e}var F=Symbol("store-raw"),T=Symbol("track"),$=Symbol("store-proxy"),N=Symbol("store-node");function U(t){let e=t[$];if(!e&&(Object.defineProperty(t,$,{value:e=new Proxy(t,J)}),!Array.isArray(t))){const a=Object.keys(t),n=Object.getOwnPropertyDescriptors(t);for(let r=0,o=a.length;r<o;r++){const o=a[r];if(n[o].get){const a=n[o].get.bind(e);Object.defineProperty(t,o,{enumerable:n[o].enumerable,get:a})}}}return e}function B(t){let e;return null!=t&&"object"==typeof t&&(t[$]||!(e=Object.getPrototypeOf(t))||e===Object.prototype||Array.isArray(t))}function H(t,e=new Set){let a,n,r,o;if(a=null!=t&&t[F])return a;if(!B(t)||e.has(t))return t;if(Array.isArray(t)){Object.isFrozen(t)?t=t.slice(0):e.add(t);for(let a=0,o=t.length;a<o;a++)r=t[a],(n=H(r,e))!==r&&(t[a]=n)}else{Object.isFrozen(t)?t=Object.assign({},t):e.add(t);const a=Object.keys(t),s=Object.getOwnPropertyDescriptors(t);for(let i=0,c=a.length;i<c;i++)o=a[i],s[o].get||(r=t[o],(n=H(r,e))!==r&&(t[o]=n))}return t}function G(t){let e=t[N];return e||Object.defineProperty(t,N,{value:e={}}),e}function z(t,e,a){return t[e]||(t[e]=V(a))}function K(t){if(E){const e=G(t);(e._||(e._=V())).get()}}function V(t){const e=new class{value;fn;observers=null;sources=null;state;effect;cleanups=null;alwaysUpdate=!1;constructor(t,e){0!=e?(this.fn=t,this.value=void 0,this.state=2,console.error("Memos and effects must be wrapped in a createRoot"),this.effect=2==e,this.effect&&this.update()):(this.fn=void 0,this.value=t,this.state=0,this.effect=!1)}get(){return E&&(!O&&E.sources&&E.sources[j]==this?j++:O?O.push(this):O=[this]),this.fn&&this.updateIfNecessary(),this.value}set(t){const e=!C,a="function"==typeof t?t(this.value):t;if((this.value!==a||this.alwaysUpdate)&&this.observers)for(let t=0;t<this.observers.length;t++)this.observers[t].stale(2);return this.value=a,e&&D(),a}stale(t){if(this.state<t&&(0===this.state&&this.effect&&(C?C.push(this):C=[this]),this.state=t,this.observers))for(let t=0;t<this.observers.length;t++)this.observers[t].stale(1)}update(){const t=this.value,e=E,a=O,n=j;E=this,O=null,j=0;try{if(this.cleanups&&(this.cleanups.forEach((t=>t())),this.cleanups=null),this.value=this.fn(),O){if(this.removeParentObservers(j),this.sources&&j>0){this.sources.length=j+O.length;for(let t=0;t<O.length;t++)this.sources[j+t]=O[t]}else this.sources=O;for(let t=j;t<this.sources.length;t++){const e=this.sources[t];e.observers?e.observers.push(this):e.observers=[this]}}else this.sources&&j<this.sources.length&&(this.removeParentObservers(j),this.sources.length=j)}finally{O=a,E=e,j=n}if((t!==this.value||this.alwaysUpdate)&&this.observers)for(let t=0;t<this.observers.length;t++)this.observers[t].state=2;this.state=0}updateIfNecessary(){if(1===this.state)for(const t of this.sources)if(t.updateIfNecessary(),2===this.state)break;2===this.state&&this.update(),this.state=0}removeParentObservers(t){if(this.sources)for(let e=t;e<this.sources.length;e++){const t=this.sources[e],a=t.observers.findIndex((t=>t===this));t.observers[a]=t.observers[t.observers.length-1],t.observers.pop()}}destroy(){this.cleanups&&(this.cleanups.forEach((t=>t())),this.cleanups=null),this.removeParentObservers(0)}}(t,0);return e.alwaysUpdate=!0,e}var W=!1,J={get(t,e,a){if(e===F)return t;if(e===$)return a;if(e===T)return K(t),a;const n=G(t),r=n.hasOwnProperty(e);let o=r?n[e].get():t[e];if(e===N||"__proto__"===e)return o;if(!r){const a=Object.getOwnPropertyDescriptor(t,e);!E||"function"==typeof o&&!t.hasOwnProperty(e)||a&&a.get||(o=z(n,e,o).get())}return B(o)?U(o):o},has(t,e){return e===F||e===$||e===T||e===N||"__proto__"===e||(this.get(t,e,t),e in t)},set:(t,e,a)=>(W&&q(t,e,H(a)),!0),deleteProperty:(t,e)=>(W&&q(t,e,void 0,!0),!0),ownKeys:function(t){return K(t),Reflect.ownKeys(t)},getOwnPropertyDescriptor:function(t,e){const a=Reflect.getOwnPropertyDescriptor(t,e);return a&&!a.get&&a.configurable&&e!==$&&e!==N?(delete a.value,delete a.writable,a.get=()=>t[$][e],a):a}};function q(t,e,a,n=!1){if(!n&&t[e]===a)return;const r=t[e],o=t.length;n?delete t[e]:t[e]=a;const s=G(t);let i;(i=z(s,e,r))&&i.set((()=>a)),Array.isArray(t)&&t.length!==o&&(i=z(s,"length",o))&&i.set(t.length),(i=s._)&&i.set()}function X(t){const e=U(H(t));return[e,t=>{k((()=>{try{W=!0,t(e)}finally{W=!1}}))}]}function Q(t,e,a,n,r){const{id:o,routeId:s,path:i,fullPath:c}=t;let l={routeInfo:void 0,routeId:o,routeRouteId:s,originalIndex:a,routePath:i,fullPath:c,options:e,router:r,childRoutes:void 0,parentRoute:n,get action(){let t=r.store.actions[o]||(r.setStore((e=>{e.actions[o]={submissions:[],submit:async(e,a)=>{if(!l)return;const n=(null==a?void 0:a.invalidate)??!0,[s,i]=X({submittedAt:Date.now(),status:"pending",submission:e,isMulti:!(null==a||!a.multi)});r.setStore((e=>{null!=a&&a.multi||(e.actions[o].submissions=t.submissions.filter((t=>t.isMulti))),e.actions[o].current=s,e.actions[o].latest=s,e.actions[o].submissions.push(s)}));try{const t=await(null==l.options.action?void 0:l.options.action(e));return i((e=>{e.data=t})),n&&(r.invalidateRoute({to:".",fromCurrent:!0}),await r.reload()),i((t=>{t.status="success"})),t}catch(t){console.error(t),i((e=>{e.error=t,e.status="error"}))}}}})),r.store.actions[o]);return t},get loader(){return r.store.loaders[o]||(r.setStore((t=>{t.loaders[o]={pending:[],fetch:async t=>{if(!l)return;const e={loadedAt:Date.now(),loaderContext:t};r.setStore((t=>{t.loaders[o].current=e,t.loaders[o].latest=e,t.loaders[o].pending.push(e)}));try{return await(null==l.options.loader?void 0:l.options.loader(t))}finally{r.setStore((t=>{t.loaders[o].pending=t.loaders[o].pending.filter((t=>t!==e))}))}}}})),r.store.loaders[o])}};return null==r.options.createRoute||r.options.createRoute({router:r,route:l}),l}const Y="__root__",Z=function(t,e,a,n,r){void 0===t&&(t={}),void 0===a&&(a=!0),a&&(t.path=Y),n===Y&&(n="");let o=a?Y:t.path;o&&"/"!==o&&(o=P(o));const s=o||t.id;let i=g([n,s]);o===Y&&(o="/"),i!==Y&&(i=g(["/",i]));const c=i===Y?"/":w(g([r,o]));return{id:i,routeId:s,path:o,fullPath:c,options:t,children:e,addChildren:e=>Z(t,e,!1,n,r),createRoute:t=>Z(t,void 0,!1,i,c),generate:()=>{f(!1)}}};function tt(t,e,a){const n=new Map;return function t(e,a){if(e===a)return e;if(n.has(a))return n.get(a);const r=Array.isArray(e),o=Array.isArray(a),s=et(e),i=et(a),c=r&&o;if(c||s&&i){const r=c?e.length:Object.keys(e).length,o=c?a:Object.keys(a),s=o.length,i=c?[]:{};let l=0;for(let t=0;t<s;t++){const a=c?t:o[t];i[a]===e[a]&&l++}if(r===s&&l===r)return n.set(a,e),e;n.set(a,i);for(let n=0;n<s;n++){const r=c?n:o[n];"function"==typeof o[n]?i[r]=e[r]:i[r]=t(e[r],a[r]),i[r]===e[r]&&l++}return i}if(o){const e=[];n.set(a,e);for(let n=0;n<a.length;n++)e[n]=t(void 0,a[n]);return e}if(i){const e={};n.set(a,e);const r=Object.keys(a);for(let n=0;n<r.length;n++){const o=r[n];e[o]=t(void 0,a[o])}return e}return a}(t,e)}function et(t){if(!at(t))return!1;const e=t.constructor;if(void 0===e)return!0;const a=e.prototype;return!!at(a)&&!!a.hasOwnProperty("isPrototypeOf")}function at(t){return"[object Object]"===Object.prototype.toString.call(t)}const nt=["component","errorComponent","pendingComponent"];function rt(t,e,a){let n,r,o="",s=()=>{};function i(){l((t=>{var e;t.loaderData=tt(t.loaderData,{...null==(e=c.parentMatch)?void 0:e.store.loaderData,...t.routeLoaderData})}))}const[c,l]=X({routeSearch:{},search:{},status:"idle",routeLoaderData:{},loaderData:{},isFetching:!1,invalid:!1,invalidAt:1/0,get isInvalid(){const t=Date.now();return this.invalid||this.invalidAt<t}}),u={...e,...a,store:c,router:t,childMatches:[],__:{setParentMatch:t=>{k((()=>{l((e=>{e.parentMatch=t})),i()}))},abortController:new AbortController,validate:()=>{var e;const a=(null==(e=c.parentMatch)?void 0:e.store.search)??t.store.currentLocation.search;try{const t=c.routeSearch,e="object"==typeof u.options.validateSearch?u.options.validateSearch.parse:u.options.validateSearch;let n=tt(t,(null==e?void 0:e(a))??{});k((()=>{t!==n&&l((t=>t.invalid=!0)),l((t=>{t.routeSearch=n,t.search=tt(a,{...a,...n})}))})),nt.map((async t=>{const e=u.options[t];"function"!=typeof u.__[t]&&(u.__[t]=e)}))}catch(t){console.error(t);const e=new Error("Invalid search params found",{cause:t});return e.code="INVALID_SEARCH_PARAMS",void l((t=>{t.status="error",t.error=e}))}}},cancel:()=>{var t;null==(t=u.__.abortController)||t.abort()},invalidate:()=>{l((t=>t.invalid=!0))},hasLoaders:()=>!(!e.options.loader&&!nt.some((t=>{var a;return null==(a=e.options[t])?void 0:a.preload}))),load:async e=>{const a=Date.now(),n=null!=e&&e.preload?Math.max(null==e?void 0:e.maxAge,null==e?void 0:e.gcMaxAge):0;if(null!=e&&e.preload&&n>0){if(t.store.currentMatches.find((t=>t.matchId===u.matchId)))return;t.store.matchCache[u.matchId]={gc:a+e.gcMaxAge,match:u}}if("success"===c.status&&c.isInvalid||"error"===c.status||"idle"===c.status){const t=null!=e&&e.preload?null==e?void 0:e.maxAge:void 0;await u.fetch({maxAge:t})}},fetch:async e=>{const a=""+Date.now()+Math.random();o=a;const h=async()=>{if(a!==o)return new Promise((()=>{}))};k((()=>{"idle"===c.status&&l((t=>t.status="loading")),l((t=>t.invalid=!1))})),u.__.loadPromise=new Promise((async a=>{l((t=>t.isFetching=!0)),s=a,n=(async()=>{await Promise.all(nt.map((async e=>{var a;const n=u.options[e];null!=(a=u.__[e])&&a.preload&&(u.__[e]=await t.options.loadComponent(n))})))})(),r=Promise.resolve().then((async()=>{try{if(u.options.loader){const e=await t.loadMatchData(u);await h(),a=e,k((()=>{l((t=>{t.routeLoaderData=tt(t.routeLoaderData,a)})),i()}))}return l((a=>{a.error=void 0,a.status="success",a.updatedAt=Date.now(),a.invalidAt=a.updatedAt+((null==e?void 0:e.maxAge)??u.options.loaderMaxAge??t.options.defaultLoaderMaxAge??0)})),c.routeLoaderData}catch(t){throw await h(),l((e=>{e.error=t,e.status="error",e.updatedAt=Date.now()})),t}var a}));const o=async()=>{await h(),l((t=>t.isFetching=!1)),delete u.__.loadPromise,s()};try{await Promise.all([n,r.catch((()=>{}))]),o()}catch{o()}})),await u.__.loadPromise,await h()}};return u.hasLoaders()||l((t=>t.status="success")),u}const ot=it(JSON.parse),st=ct(JSON.stringify);function it(t){return e=>{"?"===e.substring(0,1)&&(e=e.substring(1));let a=I(e);for(let e in a){const n=a[e];if("string"==typeof n)try{a[e]=t(n)}catch(t){}}return a}}function ct(t){return e=>{(e={...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=S(e).toString();return a?`?${a}`:""}}var lt;const ut="undefined"==typeof window||!(null!=(lt=window.document)&<.createElement);function ht(){return{status:"idle",latestLocation:null,currentLocation:null,currentMatches:[],actions:{},loaders:{},lastUpdated:Date.now(),matchCache:{},get isFetching(){return"loading"===this.status||this.currentMatches.some((t=>t.store.isFetching))},get isPreloading(){return Object.values(this.matchCache).some((t=>t.match.store.isFetching&&!this.currentMatches.find((e=>e.matchId===t.match.matchId))))}}}t.cleanPath=y,t.createBrowserHistory=o,t.createHashHistory=function(t){void 0===t&&(t={});var o=t.window,s=void 0===o?document.defaultView:o,i=s.history;function f(){var t=d(s.location.hash.substr(1)),e=t.pathname,a=void 0===e?"/":e,n=t.search,r=void 0===n?"":n,o=t.hash,c=void 0===o?"":o,l=i.state||{};return[l.idx,{pathname:a,search:r,hash:c,state:l.usr||null,key:l.key||"default"}]}var p=null;function v(){if(p)P.call(p),p=null;else{var t=a.Pop,e=f(),n=e[0],r=e[1];if(P.length){if(null!=n){var o=y-n;o&&(p={action:t,location:r,retry:function(){S(-1*o)}},S(o))}}else A(t)}}s.addEventListener(r,v),s.addEventListener("hashchange",(function(){h(f()[1])!==h(b)&&v()}));var m=a.Pop,g=f(),y=g[0],b=g[1],w=l(),P=l();function _(t){return function(){var t=document.querySelector("base"),e="";if(t&&t.getAttribute("href")){var a=s.location.href,n=a.indexOf("#");e=-1===n?a:a.slice(0,n)}return e}()+"#"+("string"==typeof t?t:h(t))}function L(t,a){return void 0===a&&(a=null),e({pathname:b.pathname,hash:"",search:""},"string"==typeof t?d(t):t,{state:a,key:u()})}function M(t,e){return[{usr:t.state,key:t.key,idx:e},_(t)]}function x(t,e,a){return!P.length||(P.call({action:t,location:e,retry:a}),!1)}function A(t){m=t;var e=f();y=e[0],b=e[1],w.call({action:m,location:b})}function S(t){i.go(t)}null==y&&(y=0,i.replaceState(e({},i.state,{idx:y}),""));var R={get action(){return m},get location(){return b},createHref:_,push:function t(e,n){var r=a.Push,o=L(e,n);if(x(r,o,(function(){t(e,n)}))){var c=M(o,y+1),l=c[0],u=c[1];try{i.pushState(l,"",u)}catch(t){s.location.assign(u)}A(r)}},replace:function t(e,n){var r=a.Replace,o=L(e,n);if(x(r,o,(function(){t(e,n)}))){var s=M(o,y),c=s[0],l=s[1];i.replaceState(c,"",l),A(r)}},go:S,back:function(){S(-1)},forward:function(){S(1)},listen:function(t){return w.push(t)},block:function(t){var e=P.push(t);return 1===P.length&&s.addEventListener(n,c),function(){e(),P.length||s.removeEventListener(n,c)}}};return R},t.createMemoryHistory=s,t.createRoute=Q,t.createRouteConfig=Z,t.createRouteMatch=rt,t.createRouter=function(t){const e={defaultLoaderGcMaxAge:3e5,defaultLoaderMaxAge:0,defaultPreloadMaxAge:2e3,defaultPreloadDelay:50,context:void 0,...t,stringifySearch:(null==t?void 0:t.stringifySearch)??st,parseSearch:(null==t?void 0:t.parseSearch)??ot},[a,n]=X(ht());let r,i=Date.now(),c=()=>{};function l(){b.load()}function u(t,e){const a=b.options.parseSearch(t.search);return{pathname:t.pathname,searchStr:t.search,search:tt(null==e?void 0:e.search,a),hash:t.hash.split("#").reverse()[0]??"",href:`${t.pathname}${t.search}${t.hash}`,state:t.state,key:t.key}}function h(t){return function(t,e){const a=""+Date.now()+Math.random();let n="replace";e||(n="push");u(b.history.location).href!==t.href||t.key||(n="replace");return b.history[n]({pathname:t.pathname,hash:t.hash,search:t.searchStr},{id:a,...t.state}),r=new Promise((t=>{const e=c;c=()=>{e(),t()}}))}(b.buildNext(t),t.replace)}function d(t){var e,n,r,o;void 0===t&&(t={});const s=t.fromCurrent?a.latestLocation.pathname:t.from??a.latestLocation.pathname;let i=_(b.basepath??"/",s,`${t.to??"."}`);const c=b.matchRoutes(a.latestLocation.pathname,{strictParseParams:!0}),l=b.matchRoutes(i),u={...null==(e=p(c))?void 0:e.params};let h=!0===(t.params??!0)?u:v(t.params,u);h&&l.map((t=>t.options.stringifyParams)).filter(Boolean).forEach((t=>{Object.assign({},h,t(h))})),i=M(i,h??{});const d=null!=(n=t.__preSearchFilters)&&n.length?t.__preSearchFilters.reduce(((t,e)=>e(t)),a.latestLocation.search):a.latestLocation.search,f=!0===t.search?d:t.search?v(t.search,d)??{}:null!=(r=t.__preSearchFilters)&&r.length?d:{},m=null!=(o=t.__postSearchFilters)&&o.length?t.__postSearchFilters.reduce(((t,e)=>e(t)),f):f,g=tt(a.latestLocation.search,m),y=b.options.stringifySearch(g);let w=!0===t.hash?a.latestLocation.hash:v(t.hash,a.latestLocation.hash);return w=w?`#${w}`:"",{pathname:i,search:g,searchStr:y,state:a.latestLocation.state,hash:w,href:`${i}${y}${w}`,key:t.key}}const b={types:void 0,history:(null==t?void 0:t.history)||(ut?s():o()),store:a,setStore:n,options:e,basepath:"",routeTree:void 0,routesById:{},reset:()=>{n((t=>Object.assign(t,ht())))},getRoute:t=>b.routesById[t],dehydrate:()=>({store:{...m(a,["latestLocation","currentLocation","status","lastUpdated"]),currentMatches:a.currentMatches.map((t=>({matchId:t.matchId,store:m(t.store,["status","routeLoaderData","isInvalid","invalidAt"])})))},context:b.options.context}),hydrate:t=>{n((e=>{b.options.context=t.context;const a=b.matchRoutes(t.store.latestLocation.pathname,{strictParseParams:!0});a.forEach(((e,a)=>{const n=t.store.currentMatches[a];f(n&&n.matchId===e.matchId),Object.assign(e,n)})),a.forEach((t=>t.__.validate())),Object.assign(e,{...t.store,currentMatches:a})}))},mount:()=>{if(!ut){a.currentMatches.length||b.load();const t=b.history.listen((t=>{b.load(u(t.location,a.latestLocation))}));return window.addEventListener&&(window.addEventListener("visibilitychange",l,!1),window.addEventListener("focus",l,!1)),()=>{t(),window.removeEventListener&&(window.removeEventListener("visibilitychange",l),window.removeEventListener("focus",l))}}return()=>{}},update:t=>{const e=(null==t?void 0:t.history)!==b.history;a.latestLocation&&!e||(null!=t&&t.history&&(b.history=t.history),n((t=>{t.latestLocation=u(b.history.location),t.currentLocation=t.latestLocation}))),Object.assign(b.options,t);const{basepath:r,routeConfig:o}=b.options;return b.basepath=`/${P(r??"")??""}`,o&&(b.routesById={},b.routeTree=function(t){const e=(t,a)=>t.map(((t,n)=>{const r=Q(t,t.options,n,a,b);if(b.routesById[r.routeId])throw new Error;b.routesById[r.routeId]=r;const o=t.children;return r.childRoutes=null!=o&&o.length?e(o,r):void 0,r}));return e([t])[0]}(o)),b},cancelMatches:()=>{[...a.currentMatches,...a.pendingMatches||[]].forEach((t=>{t.cancel()}))},load:async t=>{let e=Date.now();const o=e;let s;i=o,b.cancelMatches(),k((()=>{t&&n((e=>{e.latestLocation=t})),s=b.matchRoutes(a.latestLocation.pathname,{strictParseParams:!0}),console.log("set loading",s),n((t=>{t.status="loading",t.pendingMatches=s,t.pendingLocation=a.latestLocation}))}));try{await b.loadMatches(s)}catch(t){console.log(t),f(!1)}if(i!==o)return r;const l=a.currentMatches,u=[],h=[];l.forEach((t=>{s.find((e=>e.matchId===t.matchId))?h.push(t):u.push(t)}));const d=s.filter((t=>!l.find((e=>e.matchId===t.matchId))));e=Date.now(),u.forEach((t=>{null==t.__.onExit||t.__.onExit({params:t.params,search:t.store.routeSearch}),"error"!==t.store.status||t.store.isFetching||(t.store.status="idle",t.store.error=void 0);const n=Math.max(t.options.loaderGcMaxAge??b.options.defaultLoaderGcMaxAge??0,t.options.loaderMaxAge??b.options.defaultLoaderMaxAge??0);n>0&&(a.matchCache[t.matchId]={gc:n==1/0?Number.MAX_SAFE_INTEGER:e+n,match:t})})),h.forEach((t=>{null==t.options.onTransition||t.options.onTransition({params:t.params,search:t.store.routeSearch})})),d.forEach((t=>{t.__.onExit=null==t.options.onLoaded?void 0:t.options.onLoaded({params:t.params,search:t.store.search}),delete a.matchCache[t.matchId]})),i===o&&(s.forEach((t=>{t.action&&(t.action.current=void 0,t.action.submissions=[])})),n((t=>{console.log("set",s),Object.assign(t,{status:"idle",currentLocation:a.latestLocation,currentMatches:s,pendingLocation:void 0,pendingMatches:void 0})})),c())},cleanMatchCache:()=>{const t=Date.now();n((e=>{Object.keys(e.matchCache).forEach((a=>{const n=e.matchCache[a];"loading"!==n.match.store.status&&(n.gc>0&&n.gc>t||delete e.matchCache[a])}))}))},loadRoute:async function(t){void 0===t&&(t=a.latestLocation);const e=b.buildNext(t),n=b.matchRoutes(e.pathname,{strictParseParams:!0});return await b.loadMatches(n),n},preloadRoute:async function(t,e){void 0===t&&(t=a.latestLocation);const n=b.buildNext(t),r=b.matchRoutes(n.pathname,{strictParseParams:!0});return await b.loadMatches(r,{preload:!0,maxAge:e.maxAge??b.options.defaultPreloadMaxAge??b.options.defaultLoaderMaxAge??0,gcMaxAge:e.gcMaxAge??b.options.defaultPreloadGcMaxAge??b.options.defaultLoaderGcMaxAge??0}),r},matchRoutes:(t,e)=>{b.cleanMatchCache();const n=[];if(!b.routeTree)return n;const r=[...a.currentMatches,...a.pendingMatches??[]],o=async s=>{var i;const c=p(n);let l=(null==c?void 0:c.params)??{};const u=(null==b.options.filterRoutes?void 0:b.options.filterRoutes(s))??s;let h=[];const d=(a,n)=>(n.some((n=>{var r,o;if(!n.routePath&&null!=(r=n.childRoutes)&&r.length)return d([...h,n],n.childRoutes);const s=!!("/"!==n.routePath||null!=(o=n.childRoutes)&&o.length),i=x(b.basepath,t,{to:n.fullPath,fuzzy:s,caseSensitive:n.options.caseSensitive??b.options.caseSensitive});if(i){let t;try{t=(null==n.options.parseParams?void 0:n.options.parseParams(i))??i}catch(t){if(null!=e&&e.strictParseParams)throw t}l={...l,...t}}return i&&(h=[...a,n]),!!h.length})),!!h.length);if(d([],u),!h.length)return;h.forEach((t=>{var e;const o=M(t.routePath,l),s=M(t.routeId,l,!0),i=r.find((t=>t.matchId===s))||(null==(e=a.matchCache[s])?void 0:e.match)||rt(b,t,{parentMatch:c,matchId:s,params:l,pathname:g([b.basepath,o])});n.push(i)}));const f=p(h);null!=(i=f.childRoutes)&&i.length&&o(f.childRoutes)};return o([b.routeTree]),function(t){t.forEach(((e,a)=>{const n=t[a-1];n?e.__.setParentMatch(n):e.__.setParentMatch(void 0)}))}(n),n},loadMatches:async(t,e)=>{t.forEach((async t=>{t.__.validate()})),await Promise.all(t.map((async t=>{try{await(null==t.options.beforeLoad?void 0:t.options.beforeLoad({router:b,match:t}))}catch(a){throw null!=e&&e.preload||null==t.options.onLoadError||t.options.onLoadError(a),a}})));const a=t.map((async t=>{var a;const n=t.store.search;null!=(a=n.__data)&&a.matchId&&n.__data.matchId!==t.matchId||(t.load(e),"success"!==t.store.status&&t.__.loadPromise&&await t.__.loadPromise)}));await Promise.all(a)},loadMatchData:async t=>{if(ut||!b.options.useServerData)return await(null==t.options.loader?void 0:t.options.loader({params:t.params,search:t.store.routeSearch,signal:t.__.abortController.signal}))||{};{const e=b.buildNext({to:".",search:e=>({...e??{},__data:{matchId:t.matchId}})}),a=await fetch(e.href,{method:"GET"});if(a.ok)return a.json();throw new Error("Failed to fetch match data")}},invalidateRoute:t=>{const e=b.buildNext(t),n=b.matchRoutes(e.pathname).map((t=>t.matchId));[...a.currentMatches,...a.pendingMatches??[]].forEach((t=>{n.includes(t.matchId)&&t.invalidate()}))},reload:()=>h({fromCurrent:!0,replace:!0,search:!0}),resolvePath:(t,e)=>_(b.basepath,t,y(e)),matchRoute:(t,e)=>{t={...t,to:t.to?b.resolvePath(t.from??"",t.to):void 0};const n=b.buildNext(t);return null!=e&&e.pending?!!a.pendingLocation&&!!x(b.basepath,a.pendingLocation.pathname,{...e,to:n.pathname}):x(b.basepath,a.currentLocation.pathname,{...e,to:n.pathname})},navigate:async t=>{let{from:e,to:a=".",search:n,hash:r,replace:o,params:s}=t;const i=String(a),c=String(e);let l;try{new URL(`${i}`),l=!0}catch(t){}return f(!l),h({from:c,to:i,search:n,hash:r,replace:o,params:s})},buildLink:t=>{let{from:e,to:n=".",search:r,params:o,hash:s,target:i,replace:c,activeOptions:l,preload:u,preloadMaxAge:d,preloadGcMaxAge:f,preloadDelay:p,disabled:v}=t;try{return new URL(`${n}`),{type:"external",href:n}}catch(t){}const m={from:e,to:n,search:r,params:o,hash:s,replace:c},g=b.buildNext(m);u=u??b.options.defaultPreload;const y=p??b.options.defaultPreloadDelay??0,w=a.currentLocation.pathname===g.pathname,P=a.currentLocation.pathname.split("/"),_=g.pathname.split("/").every(((t,e)=>t===P[e])),L=a.currentLocation.hash===g.hash,M=null!=l&&l.exact?w:_,x=null==l||!l.includeHash||L;return{type:"internal",next:g,handleFocus:t=>{u&&b.preloadRoute(m,{maxAge:d,gcMaxAge:f}).catch((t=>{console.log(t),console.warn("Error preloading route! ☝️")}))},handleClick:t=>{v||function(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}(t)||t.defaultPrevented||i&&"_self"!==i||0!==t.button||(t.preventDefault(),!w||r||s||b.invalidateRoute(m),h(m))},handleEnter:t=>{const e=t.target||{};if(u){if(e.preloadTimeout)return;e.preloadTimeout=setTimeout((()=>{e.preloadTimeout=null,b.preloadRoute(m,{maxAge:d,gcMaxAge:f}).catch((t=>{console.log(t),console.warn("Error preloading route! ☝️")}))}),y)}},handleLeave:t=>{const e=t.target||{};e.preloadTimeout&&(clearTimeout(e.preloadTimeout),e.preloadTimeout=null)},isActive:M&&x,disabled:v}},buildNext:t=>{const e=d(t),a=b.matchRoutes(e.pathname),n=a.map((t=>t.options.preSearchFilters??[])).flat().filter(Boolean),r=a.map((t=>t.options.postSearchFilters??[])).flat().filter(Boolean);return d({...t,__preSearchFilters:n,__postSearchFilters:r})}};return b.update(t),null==b.options.createRouter||b.options.createRouter(b),b},t.decode=I,t.defaultParseSearch=ot,t.defaultStringifySearch=st,t.encode=S,t.functionalUpdate=v,t.interpolatePath=M,t.invariant=f,t.joinPaths=g,t.last=p,t.matchByPath=A,t.matchPathname=x,t.parsePathname=L,t.parseSearchWith=it,t.pick=m,t.resolvePath=_,t.rootRouteId=Y,t.sharedClone=tt,t.stringifySearchWith=ct,t.trimPath=P,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{}}return!0},Object.defineProperty(t,"__esModule",{value:!0})}));
|
|
12
12
|
//# sourceMappingURL=index.production.js.map
|