@tanstack/react-router 0.0.1-beta.222 → 0.0.1-beta.224
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/Matches.js.map +1 -1
- package/build/cjs/RouterProvider.js +56 -955
- package/build/cjs/RouterProvider.js.map +1 -1
- package/build/cjs/fileRoute.js.map +1 -1
- package/build/cjs/route.js.map +1 -1
- package/build/cjs/router.js +953 -39
- package/build/cjs/router.js.map +1 -1
- package/build/cjs/scroll-restoration.js +5 -9
- package/build/cjs/scroll-restoration.js.map +1 -1
- package/build/cjs/useSearch.js.map +1 -1
- package/build/cjs/utils.js.map +1 -1
- package/build/esm/index.js +895 -889
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +369 -363
- package/build/types/Matches.d.ts +25 -2
- package/build/types/RouterProvider.d.ts +4 -45
- package/build/types/fileRoute.d.ts +5 -5
- package/build/types/route.d.ts +3 -1
- package/build/types/router.d.ts +50 -5
- package/build/umd/index.development.js +895 -889
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +2 -2
- package/build/umd/index.production.js.map +1 -1
- package/package.json +2 -2
- package/src/Matches.tsx +38 -2
- package/src/RouterProvider.tsx +58 -1342
- package/src/fileRoute.ts +1 -1
- package/src/route.ts +24 -1
- package/src/router.ts +1320 -45
- package/src/scroll-restoration.tsx +5 -5
- package/src/useSearch.tsx +1 -1
- package/src/utils.ts +1 -1
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
11
|
-
!function(e
|
|
11
|
+
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).ReactRouter={},t.React)}(this,(function(t,e){"use strict";function o(t){if(t&&t.__esModule)return t;var e=Object.create(null);return t&&Object.keys(t).forEach((function(o){if("default"!==o){var r=Object.getOwnPropertyDescriptor(t,o);Object.defineProperty(e,o,r.get?r:{enumerable:!0,get:function(){return t[o]}})}})),e.default=t,Object.freeze(e)}var r=o(e);
|
|
12
12
|
/**
|
|
13
13
|
* @tanstack/history/src/index.ts
|
|
14
14
|
*
|
|
@@ -18,5 +18,5 @@
|
|
|
18
18
|
* LICENSE.md file in the root directory of this source tree.
|
|
19
19
|
*
|
|
20
20
|
* @license MIT
|
|
21
|
-
*/const o="pushstate",a="popstate",s="beforeunload",c=e=>(e.preventDefault(),e.returnValue=""),i=()=>{removeEventListener(s,c,{capture:!0})};function u(e){let t=e.getLocation(),r=new Set,n=[],o=[];const a=()=>{t=e.getLocation(),r.forEach((e=>e()))},u=()=>{if(n.length)n[0]?.(u,(()=>{n=[],i()}));else for(;o.length;)o.shift()?.()},h=e=>{o.push(e),u()};return{get location(){return t},subscribe:e=>(r.add(e),()=>{r.delete(e)}),push:(t,r)=>{r=l(r),h((()=>{e.pushState(t,r,a)}))},replace:(t,r)=>{r=l(r),h((()=>{e.replaceState(t,r,a)}))},go:t=>{h((()=>{e.go(t)}))},back:()=>{h((()=>{e.back()}))},forward:()=>{h((()=>{e.forward()}))},createHref:t=>e.createHref(t),block:e=>(n.push(e),1===n.length&&addEventListener(s,c,{capture:!0}),()=>{n=n.filter((t=>t!==e)),n.length||i()}),flush:()=>e.flush?.(),destroy:()=>e.destroy?.(),notify:a}}function l(e){return e||(e={}),{...e,key:f()}}function h(e){const t=e?.getHref??(()=>`${window.location.pathname}${window.location.search}${window.location.hash}`),r=e?.createHref??(e=>e);let n=d(t(),window.history.state);let s,c,i=!0;const l=()=>{i=!1,(()=>{s&&(window.history[s.isPush?"pushState":"replaceState"](s.state,"",s.href),s=void 0,c=void 0)})(),i=!0},h=(e,t,o,a)=>{const i=r(t);n=d(i,o),s={href:i,state:o,isPush:s?.isPush||"push"===e},a(),c||(c=Promise.resolve().then((()=>l())))},f=()=>{n=d(t(),window.history.state),y.notify()};var p=window.history.pushState,m=window.history.replaceState;const y=u({getLocation:()=>n,pushState:(e,t,r)=>h("push",e,t,r),replaceState:(e,t,r)=>h("replace",e,t,r),back:()=>window.history.back(),forward:()=>window.history.forward(),go:e=>window.history.go(e),createHref:e=>r(e),flush:l,destroy:()=>{window.history.pushState=p,window.history.replaceState=m,window.removeEventListener(o,f),window.removeEventListener(a,f)}});return window.addEventListener(o,f),window.addEventListener(a,f),window.history.pushState=function(){let e=p.apply(window.history,arguments);return i&&y.notify(),e},window.history.replaceState=function(){let e=m.apply(window.history,arguments);return i&&y.notify(),e},y}function d(e,t){let r=e.indexOf("#"),n=e.indexOf("?");return{href:e,pathname:e.substring(0,r>0?n>0?Math.min(r,n):r:n>0?n:e.length),hash:r>-1?e.substring(r):"",search:n>-1?e.slice(n,-1===r?void 0:r):"",state:t||{}}}function f(){return(Math.random()+1).toString(36).substring(7)}function p(e,t){if(!e)throw new Error("Invariant failed")}function m(e,t){}function y(e){const t=e.errorComponent??v;return n.createElement(g,{resetKey:e.resetKey,onCatch:e.onCatch,children:({error:r})=>r?n.createElement(t,{error:r}):e.children})}class g extends n.Component{state={error:null};static getDerivedStateFromError(e){return{error:e}}componentDidUpdate(e,t){t.error&&e.resetKey!==this.props.resetKey&&this.setState({error:null})}componentDidCatch(e){console.error(e),this.props.onCatch?.(e)}render(){return this.props.children(this.state)}}function v({error:e}){const[t,r]=n.useState(!1);return n.createElement("div",{style:{padding:".5rem",maxWidth:"100%"}},n.createElement("div",{style:{display:"flex",alignItems:"center",gap:".5rem"}},n.createElement("strong",{style:{fontSize:"1rem"}},"Something went wrong!"),n.createElement("button",{style:{appearance:"none",fontSize:".6em",border:"1px solid currentColor",padding:".1rem .2rem",fontWeight:"bold",borderRadius:".25rem"},onClick:()=>r((e=>!e))},t?"Hide Error":"Show Error")),n.createElement("div",{style:{height:".25rem"}}),t?n.createElement("div",null,n.createElement("pre",{style:{fontSize:".7em",border:"1px solid red",borderRadius:".25rem",padding:".3rem",color:"red",overflow:"auto"}},e.message?n.createElement("code",null,e.message):null)):null)}const w="undefined"==typeof document;function S(e){return e[e.length-1]}function E(e,t){return"function"==typeof e?e(t):e}function b(e,t){return t.reduce(((t,r)=>(t[r]=e[r],t)),{})}function R(e,t){if(e===t)return e;const r=t,n=Array.isArray(e)&&Array.isArray(r);if(n||_(e)&&_(r)){const t=n?e.length:Object.keys(e).length,o=n?r:Object.keys(r),a=o.length,s=n?[]:{};let c=0;for(let t=0;t<a;t++){const a=n?t:o[t];s[a]=R(e[a],r[a]),s[a]===e[a]&&c++}return t===a&&c===t?e:s}return r}function _(e){if(!C(e))return!1;const t=e.constructor;if(void 0===t)return!0;const r=t.prototype;return!!C(r)&&!!r.hasOwnProperty("isPrototypeOf")}function C(e){return"[object Object]"===Object.prototype.toString.call(e)}function P(e,t,r=!1){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(_(e)&&_(t)){const n=Object.keys(e),o=Object.keys(t);return!(!r&&n.length!==o.length)&&!o.some((n=>!(n in e)||!P(e[n],t[n],r)))}return!(!Array.isArray(e)||!Array.isArray(t))&&!e.some(((e,n)=>!P(e,t[n],r)))}function x(e){const t=n.useRef(e);t.current=e;return n.useRef(((...e)=>t.current(...e))).current}const L="undefined"!=typeof window?n.useLayoutEffect:n.useEffect;function k(e){return e.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/"/g,'\\"')}function O(e){return T(e.filter(Boolean).join("/"))}function T(e){return e.replace(/\/{2,}/g,"/")}function D(e){return"/"===e?e:e.replace(/^\/{1,}/,"")}function I(e){return"/"===e?e:e.replace(/\/{1,}$/,"")}function j(e){return I(D(e))}function M(e,t,r){t=t.replace(new RegExp(`^${e}`),"/"),r=r.replace(new RegExp(`^${e}`),"/");let n=$(t);const o=$(r);o.forEach(((e,t)=>{if("/"===e.value)t?t===o.length-1&&n.push(e):n=[e];else if(".."===e.value)n.length>1&&"/"===S(n)?.value&&n.pop(),n.pop();else{if("."===e.value)return;n.push(e)}}));return T(O([e,...n.map((e=>e.value))]))}function $(e){if(!e)return[];const t=[];if("/"===(e=T(e)).slice(0,1)&&(e=e.substring(1),t.push({type:"pathname",value:"/"})),!e)return t;const r=e.split("/").filter(Boolean);return t.push(...r.map((e=>"$"===e||"*"===e?{type:"wildcard",value:e}:"$"===e.charAt(0)?{type:"param",value:e}:{type:"pathname",value:e}))),"/"===e.slice(-1)&&(e=e.substring(1),t.push({type:"pathname",value:"/"})),t}function A(e,t,r=!1){return O($(e).map((e=>{if("wildcard"===e.type){const n=t[e.value];return r?`${e.value}${n??""}`:n}return"param"===e.type?t[e.value.substring(1)]??"":e.value})))}function N(e,t,r){const n=H(e,t,r);if(!r.to||n)return n??{}}function H(e,t,r){t="/"!=e?t.substring(e.length):t;const n=`${r.to??"$"}`,o=$(t),a=$(n);t.startsWith("/")||o.unshift({type:"pathname",value:"/"}),n.startsWith("/")||a.unshift({type:"pathname",value:"/"});const s={};return(()=>{for(let e=0;e<Math.max(o.length,a.length);e++){const t=o[e],n=a[e],c=e>=o.length-1,i=e>=a.length-1;if(n){if("wildcard"===n.type)return!!t?.value&&(s["*"]=O(o.slice(e).map((e=>e.value))),!0);if("pathname"===n.type){if("/"===n.value&&!t?.value)return!0;if(t)if(r.caseSensitive){if(n.value!==t.value)return!1}else if(n.value.toLowerCase()!==t.value.toLowerCase())return!1}if(!t)return!1;if("param"===n.type){if("/"===t?.value)return!1;"$"!==t.value.charAt(0)&&(s[n.value.substring(1)]=t.value)}}if(!c&&i)return!!r.fuzzy}return!0})()?s:void 0}function B(e){return ye({select:t=>{const r=S(t.matches)?.params;return e?.select?e.select(r):r}})}function F(e){return Q({...e,select:t=>e?.select?e.select(t.search):t.search})}const K="__root__";class z{constructor(e){this.options=e||{},this.isRoot=!e?.getParentRoute,z.__onInit(this)}init=e=>{this.originalIndex=e.originalIndex;const t=this.options,r=!t?.path&&!t?.id;this.parentRoute=this.options?.getParentRoute?.(),r?this.path=K:p(this.parentRoute);let n=r?K:t.path;n&&"/"!==n&&(n=j(n));const o=t?.id||n;let a=r?K:O([this.parentRoute.id===K?"":this.parentRoute.id,o]);n===K&&(n="/"),a!==K&&(a=O(["/",a]));const s=a===K?"/":O([this.parentRoute.fullPath,n]);this.path=n,this.id=a,this.fullPath=s,this.to=s};addChildren=e=>(this.children=e,this);update=e=>(Object.assign(this.options,e),this);static __onInit=e=>{};useMatch=e=>Q({...e,from:this.id});useRouteContext=e=>Q({...e,from:this.id,select:t=>e?.select?e.select(t.context):t.context});useSearch=e=>F({...e,from:this.id});useParams=e=>B({...e,from:this.id});useLoaderData=e=>ee({...e,from:this.id})}class U extends z{constructor(e){super(e)}}function W(){const{routesById:e,state:t}=ge(),{matches:r}=t,o=ye().location.state.key,a=e.__root__,s=n.useCallback((e=>n.createElement(v,{...e,useMatch:a.useMatch,useRouteContext:a.useRouteContext,useSearch:a.useSearch,useParams:a.useParams})),[a]);return n.createElement(Z.Provider,{value:r},n.createElement(y,{resetKey:o,errorComponent:s,onCatch:()=>{}},r.length?n.createElement(X,{matches:r}):null))}const J=()=>null;function Y(e){return n.createElement(n.Fragment,null,e.children)}function X({matches:e}){const{options:t,routesById:r}=ge(),o=e[0],a=o?.routeId,s=r[a],c=ye().location.state?.key,i=s.options.pendingComponent??t.defaultPendingComponent??J,u=s.options.errorComponent??t.defaultErrorComponent??v,l=s.options.wrapInSuspense?n.Suspense:Y,h=u?n.useCallback((e=>n.createElement(u,{...e,useMatch:s.useMatch,useRouteContext:s.useRouteContext,useSearch:s.useSearch,useParams:s.useParams})),[s]):void 0;return n.createElement(Z.Provider,{value:e},n.createElement(l,{fallback:n.createElement(i,{useMatch:s.useMatch,useRouteContext:s.useRouteContext,useSearch:s.useSearch,useParams:s.useParams})},h?n.createElement(y,{resetKey:c,errorComponent:h,onCatch:()=>{o.id}},n.createElement(q,{match:o})):n.createElement(Y,null,n.createElement(q,{match:o}))))}function q({match:e}){const{options:t,routesById:r}=ge(),o=r[e.routeId];if("error"===e.status)throw e.error;if("pending"===e.status)throw e.loadPromise;if("success"===e.status){let e=o.options.component??t.defaultComponent;return e?n.createElement(e,{useMatch:o.useMatch,useRouteContext:o.useRouteContext,useSearch:o.useSearch,useParams:o.useParams,useLoaderData:o.useLoaderData}):n.createElement(V,null)}p(!1)}function V(){const e=n.useContext(Z).slice(1);return e[0]?n.createElement(X,{matches:e}):null}function G(){const{matchRoute:e}=ge();return n.useCallback((t=>{const{pending:r,caseSensitive:n,...o}=t;return e(o,{pending:r,caseSensitive:n})}),[])}function Q(e){const t=n.useContext(Z)[0],r=t?.routeId,o=ye({select:r=>(e?.from?r.matches.find((t=>t.routeId===e?.from)):r.matches.find((e=>e.id===t.id))).routeId});(e?.strict??1)&&p(r==o);return ye({select:r=>{const n=e?.from?r.matches.find((t=>t.routeId===e?.from)):r.matches.find((e=>e.id===t.id));return p(n,e?.from&&e.from),e?.select?e.select(n):n}})}const Z=n.createContext(null);function ee(e){const t=Q({...e,select:void 0});return"function"==typeof e.select?e.select(t?.loaderData):t?.loaderData}function te(e){return!!e?.isRedirect}function re(e,t){var r,n,o,a="";for(r in e)if(void 0!==(o=e[r]))if(Array.isArray(o))for(n=0;n<o.length;n++)a&&(a+="&"),a+=encodeURIComponent(r)+"="+encodeURIComponent(o[n]);else a&&(a+="&"),a+=encodeURIComponent(r)+"="+encodeURIComponent(o);return(t||"")+a}function ne(e){if(!e)return"";var t=decodeURIComponent(e);return"false"!==t&&("true"===t||(0*+t==0&&+t+""===t?+t:t))}function oe(e){for(var t,r,n={},o=e.split("&");t=o.shift();)void 0!==n[r=(t=t.split("=")).shift()]?n[r]=[].concat(n[r],ne(t.shift())):n[r]=ne(t.shift());return n}const ae=ce(JSON.parse),se=ie(JSON.stringify,JSON.parse);function ce(e){return t=>{"?"===t.substring(0,1)&&(t=t.substring(1));let r=oe(t);for(let t in r){const n=r[t];if("string"==typeof n)try{r[t]=e(n)}catch(e){}}return r}}function ie(e,t){return r=>{(r={...r})&&Object.keys(r).forEach((n=>{const o=r[n];void 0===o||void 0===o?delete r[n]:r[n]=function(r){if("object"==typeof r&&null!==r)try{return e(r)}catch(e){}else if("string"==typeof r&&"function"==typeof t)try{return t(r),e(r)}catch(e){}return r}(o)}));const n=re(r).toString();return n?`?${n}`:""}}const ue=["component","errorComponent","pendingComponent"];const le=n.createContext(null);"undefined"!=typeof document&&(window.__TSR_ROUTER_CONTEXT__=le);const he="Error preloading route! ☝️";class de extends Error{}class fe extends Error{}function pe(e){return{status:"idle",resolvedLocation:e,location:e,matches:[],pendingMatches:[],lastUpdated:Date.now()}}function me(e,t){return[...e.pendingMatches,...e.matches].find((e=>e.id===t))}function ye(e){const{state:t}=ge();return e?.select?e.select(t):t}function ge(){const e=window.__TSR_ROUTER_CONTEXT__||le;return n.useContext(e)}function ve(e){return"object"==typeof e&&null!==e&&!(e instanceof Promise)&&!e.then&&"__deferredState"in e}function we({promise:e}){const t=ge();let r=e.__deferredState;const n=`__TSR__DEFERRED__${r.uid}`;if(ve(e)&&(r=t.hydrateData(n),(e=Promise.resolve(r.data)).__deferredState=r),"pending"===r.status)throw e;if("error"===r.status)throw r.error;return t.dehydrateData(n,r),[r.data]}function Se(){return Se=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},Se.apply(this,arguments)}function Ee(e){const{buildLink:t}=ge(),r=Q({strict:!1}),{type:n,children:o,target:a,activeProps:s=(()=>({className:"active"})),inactiveProps:c=(()=>({})),activeOptions:i,disabled:u,hash:l,search:h,params:d,to:f,state:p,mask:m,preload:y,preloadDelay:g,replace:v,startTransition:w,resetScroll:S,style:b,className:R,onClick:_,onFocus:C,onMouseEnter:P,onMouseLeave:x,onTouchStart:L,...k}=e,O=t({from:e.to?r.pathname:void 0,...e});if("external"===O.type){const{href:e}=O;return{href:e}}const{handleClick:T,handleFocus:D,handleEnter:I,handleLeave:j,handleTouchStart:M,isActive:$,next:A}=O,N=e=>t=>{t.persist&&t.persist(),e.filter(Boolean).forEach((e=>{t.defaultPrevented||e(t)}))},H=$?E(s,{})??{}:{},B=$?{}:E(c,{})??{};return{...H,...B,...k,href:u?void 0:A.maskedLocation?A.maskedLocation.href:A.href,onClick:N([_,T]),onFocus:N([C,D]),onMouseEnter:N([P,I]),onMouseLeave:N([x,j]),onTouchStart:N([L,M]),target:a,style:{...b,...H.style,...B.style},className:[R,H.className,B.className].filter(Boolean).join(" ")||void 0,...u?{role:"link","aria-disabled":!0}:void 0,"data-status":$?"active":void 0}}const be=n.forwardRef(((e,t)=>{const r=Ee(e);return n.createElement("a",Se({ref:t},r,{children:"function"==typeof e.children?e.children({isActive:"active"===r["data-status"]}):e.children}))})),Re="undefined"!=typeof window?n.useLayoutEffect:n.useEffect,_e="window";let Ce,Pe=new WeakSet;const xe="undefined"!=typeof window&&window.sessionStorage,Le=e=>e.state.key;function ke(e){const{state:t,subscribe:r,resetNextScrollRef:n}=ge();Re((()=>{const t=e?.getKey||Le;xe&&(Ce||(Ce=(()=>{const e="tsr-scroll-restoration-v2";return{state:JSON.parse(window.sessionStorage.getItem(e)||"null")||{cached:{},next:{}},set:t=>{Ce.state=E(t,Ce.state),window.sessionStorage.setItem(e,JSON.stringify(Ce.state))}}})()));const{history:o}=window;o.scrollRestoration&&(o.scrollRestoration="manual");const a=e=>{if(Pe.has(e.target))return;Pe.add(e.target);const t=e.target===document||e.target===window?_e:s(e.target);Ce.state.next[t]||Ce.set((e=>({...e,next:{...e.next,[t]:{scrollX:NaN,scrollY:NaN}}})))},s=e=>{let t,r=[];for(;t=e.parentNode;)r.unshift(`${e.tagName}:nth-child(${[].indexOf.call(t.children,e)+1})`),e=t;return`${r.join(" > ")}`.toLowerCase()};"undefined"!=typeof document&&document.addEventListener("scroll",a,!0);const c=r("onBeforeLoad",(e=>{if(e.pathChanged){const r=t(e.fromLocation);for(const e in Ce.state.next){const t=Ce.state.next[e];if(e===_e)t.scrollX=window.scrollX||0,t.scrollY=window.scrollY||0;else if(e){const r=document.querySelector(e);t.scrollX=r?.scrollLeft||0,t.scrollY=r?.scrollTop||0}Ce.set((n=>{const o={...n.next};return delete o[e],{...n,next:o,cached:{...n.cached,[[r,e].join("___")]:t}}}))}}})),i=r("onResolved",(t=>{if(t.pathChanged){if(!n.current)return;n.current=!0;const r=(e?.getKey||Le)(t.toLocation);let o=!1;for(const e in Ce.state.cached){const t=Ce.state.cached[e],[n,a]=e.split("___");if(n===r)if(a===_e)o=!0,window.scrollTo(t.scrollX,t.scrollY);else if(a){const e=document.querySelector(a);e&&(e.scrollLeft=t.scrollX,e.scrollTop=t.scrollY)}}o||window.scrollTo(0,0),Ce.set((e=>({...e,next:{}}))),Pe=new WeakSet}}));return()=>{document.removeEventListener("scroll",a),c(),i()}}),[])}function Oe(e,t=!0){const{history:r}=ge();n.useEffect((()=>{if(!t)return;let n=r.block(((t,r)=>{window.confirm(e)&&(n(),t())}));return n}))}e.Await=function(e){const t=we(e);return e.children(...t)},e.Block=function({message:e,condition:t,children:r}){return Oe(e,t),r??null},e.CatchBoundary=y,e.CatchBoundaryImpl=g,e.ErrorComponent=v,e.FileRoute=class{constructor(e){this.path=e}createRoute=e=>{const t=new z(e);return t.isRoot=!1,t}},e.Link=be,e.Match=X,e.MatchRoute=function(e){const t=G()(e);return"function"==typeof e.children?e.children(t):t?e.children:null},e.Matches=W,e.Navigate=function(e){const{navigate:t}=ge(),r=Q({strict:!1});return L((()=>{t({from:e.to?r.pathname:void 0,...e})}),[]),null},e.Outlet=V,e.PathParamError=fe,e.RootRoute=U,e.Route=z,e.Router=class{constructor(e){this.options={defaultPreloadDelay:50,context:void 0,...e,stringifySearch:e?.stringifySearch??se,parseSearch:e?.parseSearch??ae},this.routeTree=this.options.routeTree}subscribers=new Set;subscribe=(e,t)=>{const r={eventType:e,fn:t};return this.subscribers.add(r),()=>{this.subscribers.delete(r)}};emit=e=>{this.subscribers.forEach((t=>{t.eventType===e.type&&t.fn(e)}))}},e.RouterProvider=function({router:e,...t}){const r={...e.options,...t,context:{...e.options.context,...t?.context}},o=n.useState((()=>r.history??h()))[0],a=n.useRef(`${Math.round(1e7*Math.random())}`),s=n.useRef(!0),c=n.useRef(null),i=n.useRef(Promise.resolve()),u=e=>i.current!==e?i.current:void 0,l=x((e=>{const t=({pathname:t,search:n,hash:o,state:a})=>{const s=r.parseSearch(n);return{pathname:t,searchStr:n,search:R(e?.search,s),hash:o.split("#").reverse()[0]??"",href:`${t}${n}${o}`,state:R(e?.state,a)}},n=t(o.location);let{__tempLocation:s,__tempKey:c}=n.state;if(s&&(!c||c===a.current)){const e=t(s);return e.state.key=n.state.key,delete e.state.__tempLocation,{...e,maskedLocation:n}}return n})),d=n.useRef(l()),[f,m]=n.useState((()=>pe(d.current))),[y,g]=n.useTransition(),v=n.useRef([]),w=n.useMemo((()=>({...f,status:y?"pending":"idle",location:y?d.current:f.location,pendingMatches:v.current})),[f,y]);n.useLayoutEffect((()=>{y||w.resolvedLocation===w.location||(e.emit({type:"onResolved",fromLocation:w.resolvedLocation,toLocation:w.location,pathChanged:w.location.href!==w.resolvedLocation?.href}),v.current=[],m((e=>({...e,resolvedLocation:e.location}))))}));const _=`/${j(r.basepath??"")??""}`,C=x(((e,t)=>M(_,e,T(t)))),[L,D]=n.useMemo((()=>{const t={},r={},n=e=>{e.forEach(((e,o)=>{e.init({originalIndex:o});if(p(!t[e.id],String(e.id)),t[e.id]=e,!e.isRoot&&e.path){const t=I(e.fullPath);r[t]&&!e.fullPath.endsWith("/")||(r[t]=e)}const a=e.children;a?.length&&n(a)}))};return n([e.routeTree]),[t,r]}),[]),H=L,B=n.useMemo((()=>Object.values(D).map(((e,t)=>{const r=j(e.fullPath),n=$(r);for(;n.length>1&&"/"===n[0]?.value;)n.shift();const o=n.map((e=>"param"===e.type?.5:"wildcard"===e.type?.25:1));return{child:e,trimmed:r,parsed:n,index:t,score:o}})).sort(((e,t)=>{let r="/"===e.trimmed?1:"/"===t.trimmed?-1:0;if(0!==r)return r;const n=Math.min(e.score.length,t.score.length);if(e.score.length!==t.score.length)return t.score.length-e.score.length;for(let r=0;r<n;r++)if(e.score[r]!==t.score[r])return t.score[r]-e.score[r];for(let r=0;r<n;r++)if(e.parsed[r].value!==t.parsed[r].value)return e.parsed[r].value>t.parsed[r].value?1:-1;return e.trimmed!==t.trimmed?e.trimmed>t.trimmed?1:-1:e.index-t.index})).map(((e,t)=>(e.child.rank=t,e.child)))),[D]),F=x(((e,t,n)=>{let o={},a=B.find((t=>{const n=N(_,I(e),{to:t.fullPath,caseSensitive:t.options.caseSensitive??r.caseSensitive,fuzzy:!1});return!!n&&(o=n,!0)}))||L.__root__,s=[a];for(;a?.parentRoute;)a=a.parentRoute,a&&s.unshift(a);const c=s.map((e=>{let t;if(e.options.parseParams)try{const t=e.options.parseParams(o);Object.assign(o,t)}catch(e){if(t=new fe(e.message,{cause:e}),n?.throwOnError)throw t;return t}})),i=s.map(((e,t)=>{const r=A(e.path,o),n=A(e.id,o,!0),a=me(w,n);if(a)return{...a};const s=!(!e.options.loader&&!ue.some((t=>e.options[t]?.preload)));return{id:n,routeId:e.id,params:o,pathname:O([_,r]),updatedAt:Date.now(),routeSearch:{},search:{},status:s?"pending":"success",isFetching:!1,invalid:!1,error:void 0,paramsError:c[t],searchError:void 0,loadPromise:Promise.resolve(),context:void 0,abortController:new AbortController,shouldReloadDeps:void 0,fetchedAt:0}}));return i.forEach(((e,r)=>{const o=i[r-1],a=H[e.routeId],s=(()=>{const r={search:o?.search??t,routeSearch:o?.routeSearch??t};try{let t=("object"==typeof a.options.validateSearch?a.options.validateSearch.parse:a.options.validateSearch)?.(r.search)??{},n={...r.search,...t};return t=R(e.routeSearch,t),n=R(e.search,n),{routeSearch:t,search:n,searchDidChange:e.routeSearch!==t}}catch(t){if(e.searchError=new de(t.message,{cause:t}),n?.throwOnError)throw e.searchError;return r}})();Object.assign(e,s)})),i})),K=x((e=>{me(w,e)?.abortController?.abort()})),z=x((e=>{e.matches.forEach((e=>{K(e.id)}))})),U=x((e=>{const t=(e={},t)=>{const n=d.current,a=e.from??n.pathname;let s=C(a,`${e.to??""}`);const c=F(a,n.search),i=t?.filter((e=>c?.find((t=>t.routeId===e.routeId)))),u={...S(c)?.params};let l=!0===(e.params??!0)?u:E(e.params,u);l&&t?.map((e=>H[e.routeId].options.stringifyParams)).filter(Boolean).forEach((e=>{l={...l,...e(l)}})),s=A(s,l??{});const h=i?.map((e=>H[e.routeId].options.preSearchFilters??[])).flat().filter(Boolean)??[],f=i?.map((e=>H[e.routeId].options.postSearchFilters??[])).flat().filter(Boolean)??[],p=h?.length?h?.reduce(((e,t)=>t(e)),n.search):n.search,m=!0===e.search?p:e.search?E(e.search,p)??{}:h?.length?p:{},y=f?.length?f.reduce(((e,t)=>t(e)),m):m,g=R(n.search,y),v=r.stringifySearch(g),w=!0===e.hash?n.hash:e.hash?E(e.hash,n.hash):n.hash,b=w?`#${w}`:"";let _=!0===e.state?n.state:e.state?E(e.state,n.state):n.state;return _=R(n.state,_),{pathname:s,search:g,searchStr:v,state:_,hash:w,href:o.createHref(`${s}${v}${b}`),unmaskOnReload:e.unmaskOnReload}},n=(e={},n)=>{let o=t(e),a=n?t(n):void 0;if(!a){let e={},s=r.routeMasks?.find((t=>{const r=N(_,o.pathname,{to:t.from,caseSensitive:!1,fuzzy:!1});return!!r&&(e=r,!0)}));s&&(s={...s,from:A(s.from,e)},a=t(n=s))}const s=F(o.pathname,o.search),c=a?F(a.pathname,a.search):void 0,i=a?t(n,c):void 0,u=t(e,s);return i&&(u.maskedLocation=i),u};return e.mask?n(e,{...b(e,["from"]),...e.mask}):n(e)})),J=x((async({startTransition:e,...t})=>{c.current&&clearTimeout(c.current);if(!(d.current.href===t.href)||!t.replace){let{maskedLocation:n,...s}=t;n&&(s={...n,state:{...n.state,__tempKey:void 0,__tempLocation:{...s,search:s.searchStr,state:{...s.state,__tempKey:void 0,__tempLocation:void 0,key:void 0}}}},(s.unmaskOnReload??r.unmaskOnReload)&&(s.state.__tempKey=a.current));const c=()=>{o[t.replace?"replace":"push"](s.href,s.state)};e??1?g(c):c()}return s.current=t.resetScroll??!0,i.current})),Y=x((({replace:e,resetScroll:t,startTransition:r,...n}={})=>{const o=U(n);return J({...o,startTransition:r,replace:e,resetScroll:t})})),X=x((({from:e,to:t="",...r})=>{const n=String(t),o=void 0===e?e:String(e);let a;try{new URL(`${n}`),a=!0}catch(e){}return p(!a),Y({...r,from:o,to:n})})),q=x((async({checkLatest:e,matches:t,preload:n})=>{let o,a;try{for(let[e,o]of t.entries()){const s=t[e-1],c=H[o.routeId],i=(r,n)=>{if(r.routerCode=n,a=a??e,te(r))throw r;try{c.options.onError?.(r)}catch(e){if(r=e,te(e))throw e}t[e]=o={...o,error:r,status:"error",updatedAt:Date.now()}};try{o.paramsError&&i(o.paramsError,"PARSE_PARAMS"),o.searchError&&i(o.searchError,"VALIDATE_SEARCH");const a=s?.context??r.context??{},u=await(c.options.beforeLoad?.({search:o.search,abortController:o.abortController,params:o.params,preload:!!n,context:a,location:w.location,navigate:e=>X({...e,from:o.pathname}),buildLocation:U}))??{},l={...a,...u};t[e]=o={...o,context:R(o.context,l)}}catch(e){i(e,"BEFORE_LOAD");break}}}catch(e){if(te(e))return n||X(e),t;throw e}const s=t.slice(0,a),c=[];return s.forEach(((r,a)=>{c.push((async()=>{const s=c[a-1],i=H[r.routeId],u=e=>!!te(e)&&(n||X(e),!0);let l;if(t[a]=r={...r,fetchedAt:Date.now(),invalid:!1},r.isFetching)l=me(w,r.id)?.loadPromise;else{const e=w.matches.find((e=>e.id===r.id))?"stay":"enter",o={params:r.params,search:r.search,preload:!!n,parentMatchPromise:s,abortController:r.abortController,context:r.context,location:w.location,navigate:e=>X({...e,from:r.pathname}),cause:e};let c=!0,u="function"==typeof i.options.shouldReload?i.options.shouldReload?.(o):!!(i.options.shouldReload??1);if("enter"===e?r.shouldReloadDeps=u:"stay"===e&&("object"==typeof u?(c=!P(u,r.shouldReloadDeps),r.shouldReloadDeps=u):c=!!u),c){t[a]=r={...r,isFetching:!0};const e=Promise.all(ue.map((async e=>{const t=i.options[e];t?.preload&&await t.preload()}))),n=i.options.loader?.(o);l=Promise.all([e,n]).then((e=>e[1]))}else l=Promise.resolve(r.loaderData)}t[a]=r={...r,loadPromise:l},n||m((e=>({...e,matches:e.matches.map((e=>e.id===r.id?r:e))})));try{const n=await l;if(o=e())return await o;t[a]=r={...r,error:void 0,status:"success",isFetching:!1,updatedAt:Date.now(),loaderData:n,loadPromise:void 0}}catch(n){if(o=e())return await o;if(u(n))return;try{i.options.onError?.(n)}catch(e){if(n=e,u(e))return}t[a]=r={...r,error:n,status:"error",isFetching:!1,updatedAt:Date.now()}}n||m((e=>({...e,matches:e.matches.map((e=>e.id===r.id?r:e))})))})())})),await Promise.all(c),t})),V=x((async()=>{const t=new Promise((async(r,n)=>{const o=d.current,a=w.resolvedLocation,s=a.href!==o.href;let c;z(w),e.emit({type:"onBeforeLoad",fromLocation:a,toLocation:o,pathChanged:s});let i=F(o.pathname,o.search,{debug:!0});v.current=i;const l=w.matches;m((e=>({...e,status:"pending",location:o,matches:i})));try{try{await q({matches:i,checkLatest:()=>u(t)})}catch(e){}if(c=u(t))return c;const n=l.filter((e=>!v.current.includes(e))),h=v.current.filter((e=>!l.includes(e)));[[n,"onLeave"],[h,"onEnter"],[l.filter((e=>v.current.includes(e))),"onTransition"]].forEach((([e,t])=>{e.forEach((e=>{H[e.routeId].options[t]?.(e)}))})),e.emit({type:"onLoad",fromLocation:a,toLocation:o,pathChanged:s}),r()}catch(e){if(c=u(t))return c;n(e)}}));return i.current=t,i.current})),G=x((async(e=w.location)=>{let t=U(e),r=F(t.pathname,t.search,{throwOnError:!0});return await q({matches:r,preload:!0,checkLatest:()=>{}}),[S(r),r]})),Q=x((e=>{const{to:t,preload:n,preloadDelay:o,activeOptions:a,disabled:s,target:c,replace:i,resetScroll:u,startTransition:l}=e;try{return new URL(`${t}`),{type:"external",href:t}}catch(e){}const h=e,f=U(h),p=n??r.defaultPreload,m=o??r.defaultPreloadDelay??0,y=d.current.pathname.split("/"),g=f.pathname.split("/").every(((e,t)=>e===y[t])),v=a?.exact?d.current.pathname===f.pathname:g,w=!a?.includeHash||d.current.hash===f.hash,S=!(a?.includeSearch??1)||P(d.current.search,f.search,!0);return{type:"internal",next:f,handleFocus:e=>{p&&G(h).catch((e=>{console.warn(e),console.warn(he)}))},handleClick:e=>{s||function(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}(e)||e.defaultPrevented||c&&"_self"!==c||0!==e.button||(e.preventDefault(),J({...f,replace:i,resetScroll:u,startTransition:l}))},handleEnter:e=>{const t=e.target||{};if(p){if(t.preloadTimeout)return;t.preloadTimeout=setTimeout((()=>{t.preloadTimeout=null,G(h).catch((e=>{console.warn(e),console.warn(he)}))}),m)}},handleLeave:e=>{const t=e.target||{};t.preloadTimeout&&(clearTimeout(t.preloadTimeout),t.preloadTimeout=null)},handleTouchStart:e=>{G(h).catch((e=>{console.warn(e),console.warn(he)}))},isActive:v&&w&&S,disabled:s}}));n.useLayoutEffect((()=>{const e=o.subscribe((()=>{d.current=l(d.current),w.location!==d.current&&g((()=>{try{V()}catch(e){console.error(e)}}))})),t=U({search:!0,params:!0,hash:!0,state:!0});return w.location.href!==t.href&&J({...t,replace:!0}),()=>{e()}}),[o]);const Z=x(((e,t)=>{e={...e,to:e.to?C(e.from||"",e.to):void 0};const r=U(e);if(t?.pending&&"pending"!==w.status)return!1;const n=t?.pending?d.current:w.resolvedLocation;if(!n)return!1;const o=N(_,n.pathname,{...t,to:r.pathname});return!!o&&(o&&(t?.includeSearch??1)?!!P(n.search,r.search,!0)&&o:o)})),ee=n.useRef([]),re=x((async e=>{ee.current.push(e)})),ne=x(((e,t)=>{if("undefined"==typeof document){const r="string"==typeof e?e:JSON.stringify(e);return re((async()=>{const e=`__TSR_DEHYDRATED__${r}`,n="function"==typeof t?await t():t;return`<script id='${e}' suppressHydrationWarning>window["__TSR_DEHYDRATED__${k(r)}"] = ${JSON.stringify(n)}\n ;(() => {\n var el = document.getElementById('${e}')\n el.parentElement.removeChild(el)\n })()\n <\/script>`})),()=>oe(e)}return()=>{}})),oe=x((e=>{if("undefined"!=typeof document){const t="string"==typeof e?e:JSON.stringify(e);return window[`__TSR_DEHYDRATED__${t}`]}}));n.useLayoutEffect((()=>{g((()=>{try{V()}catch(e){console.error(e)}}))}),[]);const ae={routeTree:e.routeTree,navigate:X,buildLink:Q,state:w,matchRoute:Z,routesById:L,options:r,history:o,load:V,buildLocation:U,subscribe:e.subscribe,resetNextScrollRef:s,injectedHtmlRef:ee,injectHtml:re,dehydrateData:ne,hydrateData:oe};return n.createElement(le.Provider,{value:ae},n.createElement(W,null))},e.ScrollRestoration=function(e){return ke(e),null},e.SearchParamError=de,e.cleanPath=T,e.componentTypes=ue,e.createBrowserHistory=h,e.createHashHistory=function(){return h({getHref:()=>window.location.hash.substring(1),createHref:e=>`#${e}`})},e.createMemoryHistory=function(e={initialEntries:["/"]}){const t=e.initialEntries;let r=e.initialIndex??t.length-1,n={key:f()};return u({getLocation:()=>d(t[r],n),pushState:(e,o)=>{n=o,t.push(e),r++},replaceState:(e,o)=>{n=o,t[r]=e},back:()=>{r--},forward:()=>{r=Math.min(r+1,t.length-1)},go:e=>window.history.go(e),createHref:e=>e})},e.createRouteMask=function(e){return e},e.decode=oe,e.deepEqual=P,e.defaultParseSearch=ae,e.defaultStringifySearch=se,e.defer=function(e){const t=e;if(!t.__deferredState){t.__deferredState={uid:Math.random().toString(36).slice(2),status:"pending"};const e=t.__deferredState;t.then((t=>{e.status="success",e.data=t})).catch((t=>{e.status="error",e.error=t}))}return t},e.encode=re,e.escapeJSON=k,e.functionalUpdate=E,e.getInitialRouterState=pe,e.getRouteMatch=me,e.interpolatePath=A,e.invariant=p,e.isDehydratedDeferred=ve,e.isPlainObject=_,e.isRedirect=te,e.isServer=w,e.joinPaths=O,e.last=S,e.lazyFn=function(e,t){return async(...r)=>(await e())[t||"default"](...r)},e.lazyRouteComponent=function(e,t){let r;const o=()=>(r||(r=e()),r),a=n.lazy((async()=>({default:(await o())[t??"default"]})));return a.preload=o,a},e.matchByPath=H,e.matchPathname=N,e.matchesContext=Z,e.parsePathname=$,e.parseSearchWith=ce,e.pick=b,e.redirect=function(e){return e.isRedirect=!0,e},e.replaceEqualDeep=R,e.resolvePath=M,e.rootRouteId=K,e.rootRouteWithContext=function(){return e=>new U(e)},e.routerContext=le,e.shallow=function(e,t){if(Object.is(e,t))return!0;if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;const r=Object.keys(e);if(r.length!==Object.keys(t).length)return!1;for(let n=0;n<r.length;n++)if(!Object.prototype.hasOwnProperty.call(t,r[n])||!Object.is(e[r[n]],t[r[n]]))return!1;return!0},e.stringifySearchWith=ie,e.trimPath=j,e.trimPathLeft=D,e.trimPathRight=I,e.typedNavigate=function(e){return e},e.useAwaited=we,e.useBlocker=Oe,e.useLayoutEffect=L,e.useLinkProps=Ee,e.useLoaderData=ee,e.useMatch=Q,e.useMatchRoute=G,e.useMatches=function(e){const t=n.useContext(Z);return ye({select:r=>{const n=r.matches.slice(r.matches.findIndex((e=>e.id===t[0]?.id)));return e?.select?e.select(n):n}})},e.useNavigate=function(e){const{navigate:t}=ge(),r=Q({strict:!1});return n.useCallback((n=>t({from:n?.to?r.pathname:void 0,...e,...n})),[])},e.useParams=B,e.useRouteContext=function(e){return Q({...e,select:t=>e?.select?e.select(t.context):t.context})},e.useRouter=ge,e.useRouterState=ye,e.useScrollRestoration=ke,e.useSearch=F,e.useStableCallback=x,e.warning=m,Object.defineProperty(e,"__esModule",{value:!0})}));
|
|
21
|
+
*/const n="pushstate",s="popstate",a="beforeunload",i=t=>(t.preventDefault(),t.returnValue=""),c=()=>{removeEventListener(a,i,{capture:!0})};function l(t){let e=t.getLocation(),o=new Set,r=[],n=[];const s=()=>{e=t.getLocation(),o.forEach((t=>t()))},l=()=>{if(r.length)r[0]?.(l,(()=>{r=[],c()}));else for(;n.length;)n.shift()?.()},h=t=>{n.push(t),l()};return{get location(){return e},subscribe:t=>(o.add(t),()=>{o.delete(t)}),push:(e,o)=>{o=u(o),h((()=>{t.pushState(e,o,s)}))},replace:(e,o)=>{o=u(o),h((()=>{t.replaceState(e,o,s)}))},go:e=>{h((()=>{t.go(e)}))},back:()=>{h((()=>{t.back()}))},forward:()=>{h((()=>{t.forward()}))},createHref:e=>t.createHref(e),block:t=>(r.push(t),1===r.length&&addEventListener(a,i,{capture:!0}),()=>{r=r.filter((e=>e!==t)),r.length||c()}),flush:()=>t.flush?.(),destroy:()=>t.destroy?.(),notify:s}}function u(t){return t||(t={}),{...t,key:f()}}function h(t){const e=t?.getHref??(()=>`${window.location.pathname}${window.location.search}${window.location.hash}`),o=t?.createHref??(t=>t);let r=d(e(),window.history.state);let a,i,c=!0;const u=()=>{c=!1,(()=>{a&&(window.history[a.isPush?"pushState":"replaceState"](a.state,"",a.href),a=void 0,i=void 0)})(),c=!0},h=(t,e,n,s)=>{const c=o(e);r=d(c,n),a={href:c,state:n,isPush:a?.isPush||"push"===t},s(),i||(i=Promise.resolve().then((()=>u())))},f=()=>{r=d(e(),window.history.state),y.notify()};var p=window.history.pushState,m=window.history.replaceState;const y=l({getLocation:()=>r,pushState:(t,e,o)=>h("push",t,e,o),replaceState:(t,e,o)=>h("replace",t,e,o),back:()=>window.history.back(),forward:()=>window.history.forward(),go:t=>window.history.go(t),createHref:t=>o(t),flush:u,destroy:()=>{window.history.pushState=p,window.history.replaceState=m,window.removeEventListener(n,f),window.removeEventListener(s,f)}});return window.addEventListener(n,f),window.addEventListener(s,f),window.history.pushState=function(){let t=p.apply(window.history,arguments);return c&&y.notify(),t},window.history.replaceState=function(){let t=m.apply(window.history,arguments);return c&&y.notify(),t},y}function d(t,e){let o=t.indexOf("#"),r=t.indexOf("?");return{href:t,pathname:t.substring(0,o>0?r>0?Math.min(o,r):o:r>0?r:t.length),hash:o>-1?t.substring(o):"",search:r>-1?t.slice(r,-1===o?void 0:o):"",state:e||{}}}function f(){return(Math.random()+1).toString(36).substring(7)}function p(t,e){if(!t)throw new Error("Invariant failed")}function m(t,e){}function y(t){const e=t.errorComponent??v;return r.createElement(g,{resetKey:t.resetKey,onCatch:t.onCatch,children:({error:o})=>o?r.createElement(e,{error:o}):t.children})}class g extends r.Component{state={error:null};static getDerivedStateFromError(t){return{error:t}}componentDidUpdate(t,e){e.error&&t.resetKey!==this.props.resetKey&&this.setState({error:null})}componentDidCatch(t){console.error(t),this.props.onCatch?.(t)}render(){return this.props.children(this.state)}}function v({error:t}){const[e,o]=r.useState(!1);return r.createElement("div",{style:{padding:".5rem",maxWidth:"100%"}},r.createElement("div",{style:{display:"flex",alignItems:"center",gap:".5rem"}},r.createElement("strong",{style:{fontSize:"1rem"}},"Something went wrong!"),r.createElement("button",{style:{appearance:"none",fontSize:".6em",border:"1px solid currentColor",padding:".1rem .2rem",fontWeight:"bold",borderRadius:".25rem"},onClick:()=>o((t=>!t))},e?"Hide Error":"Show Error")),r.createElement("div",{style:{height:".25rem"}}),e?r.createElement("div",null,r.createElement("pre",{style:{fontSize:".7em",border:"1px solid red",borderRadius:".25rem",padding:".3rem",color:"red",overflow:"auto"}},t.message?r.createElement("code",null,t.message):null)):null)}const w="undefined"==typeof document;function S(t){return t[t.length-1]}function b(t,e){return"function"==typeof t?t(e):t}function R(t,e){return e.reduce(((e,o)=>(e[o]=t[o],e)),{})}function L(t,e){if(t===e)return t;const o=e,r=Array.isArray(t)&&Array.isArray(o);if(r||E(t)&&E(o)){const e=r?t.length:Object.keys(t).length,n=r?o:Object.keys(o),s=n.length,a=r?[]:{};let i=0;for(let e=0;e<s;e++){const s=r?e:n[e];a[s]=L(t[s],o[s]),a[s]===t[s]&&i++}return e===s&&i===e?t:a}return o}function E(t){if(!_(t))return!1;const e=t.constructor;if(void 0===e)return!0;const o=e.prototype;return!!_(o)&&!!o.hasOwnProperty("isPrototypeOf")}function _(t){return"[object Object]"===Object.prototype.toString.call(t)}function P(t,e,o=!1){if(t===e)return!0;if(typeof t!=typeof e)return!1;if(E(t)&&E(e)){const r=Object.keys(t),n=Object.keys(e);return!(!o&&r.length!==n.length)&&!n.some((r=>!(r in t)||!P(t[r],e[r],o)))}return!(!Array.isArray(t)||!Array.isArray(e))&&!t.some(((t,r)=>!P(t,e[r],o)))}const C="undefined"!=typeof window?r.useLayoutEffect:r.useEffect;function x(t){return t.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/"/g,'\\"')}function k(t){return O(t.filter(Boolean).join("/"))}function O(t){return t.replace(/\/{2,}/g,"/")}function T(t){return"/"===t?t:t.replace(/^\/{1,}/,"")}function I(t){return"/"===t?t:t.replace(/\/{1,}$/,"")}function M(t){return I(T(t))}function D(t,e,o){e=e.replace(new RegExp(`^${t}`),"/"),o=o.replace(new RegExp(`^${t}`),"/");let r=j(e);const n=j(o);n.forEach(((t,e)=>{if("/"===t.value)e?e===n.length-1&&r.push(t):r=[t];else if(".."===t.value)r.length>1&&"/"===S(r)?.value&&r.pop(),r.pop();else{if("."===t.value)return;r.push(t)}}));return O(k([t,...r.map((t=>t.value))]))}function j(t){if(!t)return[];const e=[];if("/"===(t=O(t)).slice(0,1)&&(t=t.substring(1),e.push({type:"pathname",value:"/"})),!t)return e;const o=t.split("/").filter(Boolean);return e.push(...o.map((t=>"$"===t||"*"===t?{type:"wildcard",value:t}:"$"===t.charAt(0)?{type:"param",value:t}:{type:"pathname",value:t}))),"/"===t.slice(-1)&&(t=t.substring(1),e.push({type:"pathname",value:"/"})),e}function B(t,e,o=!1){return k(j(t).map((t=>{if("wildcard"===t.type){const r=e[t.value];return o?`${t.value}${r??""}`:r}return"param"===t.type?e[t.value.substring(1)]??"":t.value})))}function $(t,e,o){const r=A(t,e,o);if(!o.to||r)return r??{}}function A(t,e,o){e="/"!=t?e.substring(t.length):e;const r=`${o.to??"$"}`,n=j(e),s=j(r);e.startsWith("/")||n.unshift({type:"pathname",value:"/"}),r.startsWith("/")||s.unshift({type:"pathname",value:"/"});const a={};return(()=>{for(let t=0;t<Math.max(n.length,s.length);t++){const e=n[t],r=s[t],i=t>=n.length-1,c=t>=s.length-1;if(r){if("wildcard"===r.type)return!!e?.value&&(a["*"]=k(n.slice(t).map((t=>t.value))),!0);if("pathname"===r.type){if("/"===r.value&&!e?.value)return!0;if(e)if(o.caseSensitive){if(r.value!==e.value)return!1}else if(r.value.toLowerCase()!==e.value.toLowerCase())return!1}if(!e)return!1;if("param"===r.type){if("/"===e?.value)return!1;"$"!==e.value.charAt(0)&&(a[r.value.substring(1)]=e.value)}}if(!i&&c)return!!o.fuzzy}return!0})()?a:void 0}function N(t){return st({select:e=>{const o=S(e.matches)?.params;return t?.select?t.select(o):o}})}function H(t){return G({...t,select:e=>t?.select?t.select(e.search):e.search})}const K="__root__";class F{constructor(t){this.options=t||{},this.isRoot=!t?.getParentRoute,F.__onInit(this)}init=t=>{this.originalIndex=t.originalIndex;const e=this.options,o=!e?.path&&!e?.id;this.parentRoute=this.options?.getParentRoute?.(),o?this.path=K:p(this.parentRoute);let r=o?K:e.path;r&&"/"!==r&&(r=M(r));const n=e?.id||r;let s=o?K:k([this.parentRoute.id===K?"":this.parentRoute.id,n]);r===K&&(r="/"),s!==K&&(s=k(["/",s]));const a=s===K?"/":k([this.parentRoute.fullPath,r]);this.path=r,this.id=s,this.fullPath=a,this.to=a};addChildren=t=>(this.children=t,this);update=t=>(Object.assign(this.options,t),this);static __onInit=t=>{};useMatch=t=>G({...t,from:this.id});useRouteContext=t=>G({...t,from:this.id,select:e=>t?.select?t.select(e.context):e.context});useSearch=t=>H({...t,from:this.id});useParams=t=>N({...t,from:this.id});useLoaderData=t=>Z({...t,from:this.id})}class W extends F{constructor(t){super(t)}}function z(){const{routesById:t,state:e}=at(),{matches:o}=e,n=st().location.state.key,s=t.__root__,a=r.useCallback((t=>r.createElement(v,{...t,useMatch:s.useMatch,useRouteContext:s.useRouteContext,useSearch:s.useSearch,useParams:s.useParams})),[s]);return r.createElement(Q.Provider,{value:o},r.createElement(y,{resetKey:n,errorComponent:a,onCatch:()=>{}},o.length?r.createElement(Y,{matches:o}):null))}const U=()=>null;function J(t){return r.createElement(r.Fragment,null,t.children)}function Y({matches:t}){const{options:e,routesById:o}=at(),n=t[0],s=n?.routeId,a=o[s],i=st().location.state?.key,c=a.options.pendingComponent??e.defaultPendingComponent??U,l=a.options.errorComponent??e.defaultErrorComponent??v,u=a.options.wrapInSuspense?r.Suspense:J,h=l?r.useCallback((t=>r.createElement(l,{...t,useMatch:a.useMatch,useRouteContext:a.useRouteContext,useSearch:a.useSearch,useParams:a.useParams})),[a]):void 0;return r.createElement(Q.Provider,{value:t},r.createElement(u,{fallback:r.createElement(c,{useMatch:a.useMatch,useRouteContext:a.useRouteContext,useSearch:a.useSearch,useParams:a.useParams})},h?r.createElement(y,{resetKey:i,errorComponent:h,onCatch:()=>{n.id}},r.createElement(X,{match:n})):r.createElement(J,null,r.createElement(X,{match:n}))))}function X({match:t}){const{options:e,routesById:o}=at(),n=o[t.routeId];if("error"===t.status)throw t.error;if("pending"===t.status)throw t.loadPromise;if("success"===t.status){let t=n.options.component??e.defaultComponent;return t?r.createElement(t,{useMatch:n.useMatch,useRouteContext:n.useRouteContext,useSearch:n.useSearch,useParams:n.useParams,useLoaderData:n.useLoaderData}):r.createElement(q,null)}p(!1)}function q(){const t=r.useContext(Q).slice(1);return t[0]?r.createElement(Y,{matches:t}):null}function V(){const{matchRoute:t}=at();return r.useCallback((e=>{const{pending:o,caseSensitive:r,...n}=e;return t(n,{pending:o,caseSensitive:r})}),[])}function G(t){const e=r.useContext(Q)[0],o=e?.routeId,n=st({select:o=>(t?.from?o.matches.find((e=>e.routeId===t?.from)):o.matches.find((t=>t.id===e.id))).routeId});(t?.strict??1)&&p(o==n);return st({select:o=>{const r=t?.from?o.matches.find((e=>e.routeId===t?.from)):o.matches.find((t=>t.id===e.id));return p(r,t?.from&&t.from),t?.select?t.select(r):r}})}const Q=r.createContext(null);function Z(t){const e=G({...t,select:void 0});return"function"==typeof t.select?t.select(e?.loaderData):e?.loaderData}const tt=r.createContext(null);"undefined"!=typeof document&&(window.__TSR_ROUTER_CONTEXT__=tt);class et extends Error{}class ot extends Error{}function rt(t){return{status:"idle",resolvedLocation:t,location:t,matches:[],pendingMatches:[],lastUpdated:Date.now()}}function nt(t,e){return[...t.pendingMatches,...t.matches].find((t=>t.id===e))}function st(t){const{state:e}=at();return t?.select?t.select(e):e}function at(){const t=window.__TSR_ROUTER_CONTEXT__||tt;return r.useContext(t)}function it(t){return"object"==typeof t&&null!==t&&!(t instanceof Promise)&&!t.then&&"__deferredState"in t}function ct({promise:t}){const e=at();let o=t.__deferredState;const r=`__TSR__DEFERRED__${o.uid}`;if(it(t)&&(o=e.hydrateData(r),(t=Promise.resolve(o.data)).__deferredState=o),"pending"===o.status)throw t;if("error"===o.status)throw o.error;return e.dehydrateData(r,o),[o.data]}function lt(){return lt=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var o=arguments[e];for(var r in o)Object.prototype.hasOwnProperty.call(o,r)&&(t[r]=o[r])}return t},lt.apply(this,arguments)}function ut(t){const{buildLink:e}=at(),o=G({strict:!1}),{type:r,children:n,target:s,activeProps:a=(()=>({className:"active"})),inactiveProps:i=(()=>({})),activeOptions:c,disabled:l,hash:u,search:h,params:d,to:f,state:p,mask:m,preload:y,preloadDelay:g,replace:v,startTransition:w,resetScroll:S,style:R,className:L,onClick:E,onFocus:_,onMouseEnter:P,onMouseLeave:C,onTouchStart:x,...k}=t,O=e({from:t.to?o.pathname:void 0,...t});if("external"===O.type){const{href:t}=O;return{href:t}}const{handleClick:T,handleFocus:I,handleEnter:M,handleLeave:D,handleTouchStart:j,isActive:B,next:$}=O,A=t=>e=>{e.persist&&e.persist(),t.filter(Boolean).forEach((t=>{e.defaultPrevented||t(e)}))},N=B?b(a,{})??{}:{},H=B?{}:b(i,{})??{};return{...N,...H,...k,href:l?void 0:$.maskedLocation?$.maskedLocation.href:$.href,onClick:A([E,T]),onFocus:A([_,I]),onMouseEnter:A([P,M]),onMouseLeave:A([C,D]),onTouchStart:A([x,j]),target:s,style:{...R,...N.style,...H.style},className:[L,N.className,H.className].filter(Boolean).join(" ")||void 0,...l?{role:"link","aria-disabled":!0}:void 0,"data-status":B?"active":void 0}}const ht=r.forwardRef(((t,e)=>{const o=ut(t);return r.createElement("a",lt({ref:e},o,{children:"function"==typeof t.children?t.children({isActive:"active"===o["data-status"]}):t.children}))}));function dt(t,e){var o,r,n,s="";for(o in t)if(void 0!==(n=t[o]))if(Array.isArray(n))for(r=0;r<n.length;r++)s&&(s+="&"),s+=encodeURIComponent(o)+"="+encodeURIComponent(n[r]);else s&&(s+="&"),s+=encodeURIComponent(o)+"="+encodeURIComponent(n);return(e||"")+s}function ft(t){if(!t)return"";var e=decodeURIComponent(t);return"false"!==e&&("true"===e||(0*+e==0&&+e+""===e?+e:e))}function pt(t){for(var e,o,r={},n=t.split("&");e=n.shift();)void 0!==r[o=(e=e.split("=")).shift()]?r[o]=[].concat(r[o],ft(e.shift())):r[o]=ft(e.shift());return r}function mt(t){return!!t?.isRedirect}const yt=vt(JSON.parse),gt=wt(JSON.stringify,JSON.parse);function vt(t){return e=>{"?"===e.substring(0,1)&&(e=e.substring(1));let o=pt(e);for(let e in o){const r=o[e];if("string"==typeof r)try{o[e]=t(r)}catch(t){}}return o}}function wt(t,e){return o=>{(o={...o})&&Object.keys(o).forEach((r=>{const n=o[r];void 0===n||void 0===n?delete o[r]:o[r]=function(o){if("object"==typeof o&&null!==o)try{return t(o)}catch(t){}else if("string"==typeof o&&"function"==typeof e)try{return e(o),t(o)}catch(t){}return o}(n)}));const r=dt(o).toString();return r?`?${r}`:""}}const St=["component","errorComponent","pendingComponent"],bt="Error preloading route! ☝️";const Rt="undefined"!=typeof window?r.useLayoutEffect:r.useEffect,Lt="window";let Et,_t=new WeakSet;const Pt="undefined"!=typeof window&&window.sessionStorage,Ct=t=>t.state.key;function xt(t){const e=at();Rt((()=>{const o=t?.getKey||Ct;Pt&&(Et||(Et=(()=>{const t="tsr-scroll-restoration-v2";return{state:JSON.parse(window.sessionStorage.getItem(t)||"null")||{cached:{},next:{}},set:e=>{Et.state=b(e,Et.state),window.sessionStorage.setItem(t,JSON.stringify(Et.state))}}})()));const{history:r}=window;r.scrollRestoration&&(r.scrollRestoration="manual");const n=t=>{if(_t.has(t.target))return;_t.add(t.target);const e=t.target===document||t.target===window?Lt:s(t.target);Et.state.next[e]||Et.set((t=>({...t,next:{...t.next,[e]:{scrollX:NaN,scrollY:NaN}}})))},s=t=>{let e,o=[];for(;e=t.parentNode;)o.unshift(`${t.tagName}:nth-child(${[].indexOf.call(e.children,t)+1})`),t=e;return`${o.join(" > ")}`.toLowerCase()};"undefined"!=typeof document&&document.addEventListener("scroll",n,!0);const a=e.subscribe("onBeforeLoad",(t=>{if(t.pathChanged){const e=o(t.fromLocation);for(const t in Et.state.next){const o=Et.state.next[t];if(t===Lt)o.scrollX=window.scrollX||0,o.scrollY=window.scrollY||0;else if(t){const e=document.querySelector(t);o.scrollX=e?.scrollLeft||0,o.scrollY=e?.scrollTop||0}Et.set((r=>{const n={...r.next};return delete n[t],{...r,next:n,cached:{...r.cached,[[e,t].join("___")]:o}}}))}}})),i=e.subscribe("onResolved",(o=>{if(o.pathChanged){if(!e.resetNextScroll)return;e.resetNextScroll=!0;const r=(t?.getKey||Ct)(o.toLocation);let n=!1;for(const t in Et.state.cached){const e=Et.state.cached[t],[o,s]=t.split("___");if(o===r)if(s===Lt)n=!0,window.scrollTo(e.scrollX,e.scrollY);else if(s){const t=document.querySelector(s);t&&(t.scrollLeft=e.scrollX,t.scrollTop=e.scrollY)}}n||window.scrollTo(0,0),Et.set((t=>({...t,next:{}}))),_t=new WeakSet}}));return()=>{document.removeEventListener("scroll",n),a(),i()}}),[])}function kt(t,e=!0){const{history:o}=at();r.useEffect((()=>{if(!e)return;let r=o.block(((e,o)=>{window.confirm(t)&&(r(),e())}));return r}))}t.Await=function(t){const e=ct(t);return t.children(...e)},t.Block=function({message:t,condition:e,children:o}){return kt(t,e),o??null},t.CatchBoundary=y,t.CatchBoundaryImpl=g,t.ErrorComponent=v,t.FileRoute=class{constructor(t){this.path=t}createRoute=t=>{const e=new F(t);return e.isRoot=!1,e}},t.Link=ht,t.Match=Y,t.MatchRoute=function(t){const e=V()(t);return"function"==typeof t.children?t.children(e):e?t.children:null},t.Matches=z,t.Navigate=function(t){const{navigate:e}=at(),o=G({strict:!1});return C((()=>{e({from:t.to?o.pathname:void 0,...t})}),[]),null},t.Outlet=q,t.PathParamError=ot,t.RootRoute=W,t.Route=F,t.Router=class{tempLocationKey=`${Math.round(1e7*Math.random())}`;resetNextScroll=!0;navigateTimeout=null;latestLoadPromise=Promise.resolve();subscribers=new Set;pendingMatches=[];injectedHtml=[];constructor(t){this.updateOptions({defaultPreloadDelay:50,context:void 0,...t,stringifySearch:t?.stringifySearch??gt,parseSearch:t?.parseSearch??yt})}startReactTransition=()=>{};setState=()=>{};updateOptions=t=>{this.options,this.options={...this.options,...t},this.basepath=`/${M(t.basepath??"")??""}`,(!this.history||this.options.history&&this.options.history!==this.history)&&(this.history=this.options.history??h(),this.latestLocation=this.parseLocation()),this.options.routeTree!==this.routeTree&&(this.routeTree=this.options.routeTree,this.buildRouteTree()),this.state||(this.state=rt(this.latestLocation))};buildRouteTree=()=>{this.routesById={},this.routesByPath={};const t=e=>{e.forEach(((e,o)=>{e.init({originalIndex:o});if(p(!this.routesById[e.id],String(e.id)),this.routesById[e.id]=e,!e.isRoot&&e.path){const t=I(e.fullPath);this.routesByPath[t]&&!e.fullPath.endsWith("/")||(this.routesByPath[t]=e)}const r=e.children;r?.length&&t(r)}))};t([this.routeTree]),this.flatRoutes=Object.values(this.routesByPath).map(((t,e)=>{const o=M(t.fullPath),r=j(o);for(;r.length>1&&"/"===r[0]?.value;)r.shift();const n=r.map((t=>"param"===t.type?.5:"wildcard"===t.type?.25:1));return{child:t,trimmed:o,parsed:r,index:e,score:n}})).sort(((t,e)=>{let o="/"===t.trimmed?1:"/"===e.trimmed?-1:0;if(0!==o)return o;const r=Math.min(t.score.length,e.score.length);if(t.score.length!==e.score.length)return e.score.length-t.score.length;for(let o=0;o<r;o++)if(t.score[o]!==e.score[o])return e.score[o]-t.score[o];for(let o=0;o<r;o++)if(t.parsed[o].value!==e.parsed[o].value)return t.parsed[o].value>e.parsed[o].value?1:-1;return t.trimmed!==e.trimmed?t.trimmed>e.trimmed?1:-1:t.index-e.index})).map(((t,e)=>(t.child.rank=e,t.child)))};subscribe=(t,e)=>{const o={eventType:t,fn:e};return this.subscribers.add(o),()=>{this.subscribers.delete(o)}};emit=t=>{this.subscribers.forEach((e=>{e.eventType===t.type&&e.fn(t)}))};checkLatest=t=>this.latestLoadPromise!==t?this.latestLoadPromise:void 0;parseLocation=t=>{const e=({pathname:e,search:o,hash:r,state:n})=>{const s=this.options.parseSearch(o);return{pathname:e,searchStr:o,search:L(t?.search,s),hash:r.split("#").reverse()[0]??"",href:`${e}${o}${r}`,state:L(t?.state,n)}},o=e(this.history.location);let{__tempLocation:r,__tempKey:n}=o.state;if(r&&(!n||n===this.tempLocationKey)){const t=e(r);return t.state.key=o.state.key,delete t.state.__tempLocation,{...t,maskedLocation:o}}return o};resolvePathWithBase=(t,e)=>D(this.basepath,t,O(e));get looseRoutesById(){return this.routesById}matchRoutes=(t,e,o)=>{let r={},n=this.flatRoutes.find((e=>{const o=$(this.basepath,I(t),{to:e.fullPath,caseSensitive:e.options.caseSensitive??this.options.caseSensitive,fuzzy:!1});return!!o&&(r=o,!0)}))||this.routesById.__root__,s=[n];for(;n?.parentRoute;)n=n.parentRoute,n&&s.unshift(n);const a=s.map((t=>{let e;if(t.options.parseParams)try{const e=t.options.parseParams(r);Object.assign(r,e)}catch(t){if(e=new ot(t.message,{cause:t}),o?.throwOnError)throw e;return e}})),i=s.map(((t,e)=>{const o=B(t.path,r),n=B(t.id,r,!0),s=nt(this.state,n),i=this.state.matches.find((t=>t.id===n))?"stay":"enter";if(s)return{...s,cause:i};const c=!(!t.options.loader&&!St.some((e=>t.options[e]?.preload)));return{id:n,routeId:t.id,params:r,pathname:k([this.basepath,o]),updatedAt:Date.now(),routeSearch:{},search:{},status:c?"pending":"success",isFetching:!1,invalid:!1,error:void 0,paramsError:a[e],searchError:void 0,loadPromise:Promise.resolve(),context:void 0,abortController:new AbortController,shouldReloadDeps:void 0,fetchedAt:0,cause:i}}));return i.forEach(((t,r)=>{const n=i[r-1],s=this.looseRoutesById[t.routeId],a=(()=>{const r={search:n?.search??e,routeSearch:n?.routeSearch??e};try{let e=("object"==typeof s.options.validateSearch?s.options.validateSearch.parse:s.options.validateSearch)?.(r.search)??{},o={...r.search,...e};return e=L(t.routeSearch,e),o=L(t.search,o),{routeSearch:e,search:o,searchDidChange:t.routeSearch!==e}}catch(e){if(t.searchError=new et(e.message,{cause:e}),o?.throwOnError)throw t.searchError;return r}})();Object.assign(t,a)})),i};cancelMatch=t=>{nt(this.state,t)?.abortController?.abort()};cancelMatches=()=>{this.state.matches.forEach((t=>{this.cancelMatch(t.id)}))};buildLocation=t=>{const e=(t={},e)=>{const o=this.latestLocation,r=t.from??o.pathname;let n=this.resolvePathWithBase(r,`${t.to??""}`);const s=this.matchRoutes(r,o.search),a=e?.filter((t=>s?.find((e=>e.routeId===t.routeId)))),i={...S(s)?.params};let c=!0===(t.params??!0)?i:b(t.params,i);c&&e?.map((t=>this.looseRoutesById[t.routeId].options.stringifyParams)).filter(Boolean).forEach((t=>{c={...c,...t(c)}})),n=B(n,c??{});const l=a?.map((t=>this.looseRoutesById[t.routeId].options.preSearchFilters??[])).flat().filter(Boolean)??[],u=a?.map((t=>this.looseRoutesById[t.routeId].options.postSearchFilters??[])).flat().filter(Boolean)??[],h=l?.length?l?.reduce(((t,e)=>e(t)),o.search):o.search,d=!0===t.search?h:t.search?b(t.search,h)??{}:l?.length?h:{},f=u?.length?u.reduce(((t,e)=>e(t)),d):d,p=L(o.search,f),m=this.options.stringifySearch(p),y=!0===t.hash?o.hash:t.hash?b(t.hash,o.hash):o.hash,g=y?`#${y}`:"";let v=!0===t.state?o.state:t.state?b(t.state,o.state):o.state;return v=L(o.state,v),{pathname:n,search:p,searchStr:m,state:v,hash:y,href:this.history.createHref(`${n}${m}${g}`),unmaskOnReload:t.unmaskOnReload}},o=(t={},o)=>{let r=e(t),n=o?e(o):void 0;if(!n){let t={},s=this.options.routeMasks?.find((e=>{const o=$(this.basepath,r.pathname,{to:e.from,caseSensitive:!1,fuzzy:!1});return!!o&&(t=o,!0)}));s&&(s={...s,from:B(s.from,t)},n=e(o=s))}const s=this.matchRoutes(r.pathname,r.search),a=n?this.matchRoutes(n.pathname,n.search):void 0,i=n?e(o,a):void 0,c=e(t,s);return i&&(c.maskedLocation=i),c};return t.mask?o(t,{...R(t,["from"]),...t.mask}):o(t)};commitLocation=async({startTransition:t,...e})=>{this.navigateTimeout&&clearTimeout(this.navigateTimeout);if(!(this.latestLocation.href===e.href)||!e.replace){let{maskedLocation:o,...r}=e;o&&(r={...o,state:{...o.state,__tempKey:void 0,__tempLocation:{...r,search:r.searchStr,state:{...r.state,__tempKey:void 0,__tempLocation:void 0,key:void 0}}}},(r.unmaskOnReload??this.options.unmaskOnReload)&&(r.state.__tempKey=this.tempLocationKey));const n=()=>{this.history[e.replace?"replace":"push"](r.href,r.state)};t??1?this.startReactTransition(n):n()}return this.resetNextScroll=e.resetScroll??!0,this.latestLoadPromise};buildAndCommitLocation=({replace:t,resetScroll:e,startTransition:o,...r}={})=>{const n=this.buildLocation(r);return this.commitLocation({...n,startTransition:o,replace:t,resetScroll:e})};navigate=({from:t,to:e="",...o})=>{const r=String(e),n=void 0===t?t:String(t);let s;try{new URL(`${r}`),s=!0}catch(t){}return p(!s),this.buildAndCommitLocation({...o,from:n,to:r})};loadMatches=async({checkLatest:t,matches:e,preload:o})=>{let r,n;try{for(let[t,r]of e.entries()){const s=e[t-1],a=this.looseRoutesById[r.routeId],i=(o,s)=>{if(o.routerCode=s,n=n??t,mt(o))throw o;try{a.options.onError?.(o)}catch(t){if(o=t,mt(t))throw t}e[t]=r={...r,error:o,status:"error",updatedAt:Date.now()}};try{r.paramsError&&i(r.paramsError,"PARSE_PARAMS"),r.searchError&&i(r.searchError,"VALIDATE_SEARCH");const n=s?.context??this.options.context??{},c=await(a.options.beforeLoad?.({search:r.search,abortController:r.abortController,params:r.params,preload:!!o,context:n,location:this.state.location,navigate:t=>this.navigate({...t,from:r.pathname}),buildLocation:this.buildLocation,cause:r.cause}))??{},l={...n,...c};e[t]=r={...r,context:L(r.context,l)}}catch(t){i(t,"BEFORE_LOAD");break}}}catch(t){if(mt(t))return o||this.navigate(t),e;throw t}const s=e.slice(0,n),a=[];return s.forEach(((n,s)=>{a.push((async()=>{const i=a[s-1],c=this.looseRoutesById[n.routeId],l=t=>!!mt(t)&&(o||this.navigate(t),!0);let u;if(e[s]=n={...n,fetchedAt:Date.now(),invalid:!1},n.isFetching)u=nt(this.state,n.id)?.loadPromise;else{const t={params:n.params,search:n.search,preload:!!o,parentMatchPromise:i,abortController:n.abortController,context:n.context,location:this.state.location,navigate:t=>this.navigate({...t,from:n.pathname}),cause:n.cause};let r=!0,a="function"==typeof c.options.shouldReload?c.options.shouldReload?.(t):!!(c.options.shouldReload??1);if("enter"===n.cause?n.shouldReloadDeps=a:"stay"===n.cause&&("object"==typeof a?(r=!P(a,n.shouldReloadDeps),n.shouldReloadDeps=a):r=!!a),r){e[s]=n={...n,isFetching:!0};const o=Promise.all(St.map((async t=>{const e=c.options[t];e?.preload&&await e.preload()}))),r=c.options.loader?.(t);u=Promise.all([o,r]).then((t=>t[1]))}else u=Promise.resolve(n.loaderData)}e[s]=n={...n,loadPromise:u},o||this.setState((t=>({...t,matches:t.matches.map((t=>t.id===n.id?n:t))})));try{const o=await u;if(r=t())return await r;e[s]=n={...n,error:void 0,status:"success",isFetching:!1,updatedAt:Date.now(),loaderData:o,loadPromise:void 0}}catch(o){if(r=t())return await r;if(l(o))return;try{c.options.onError?.(o)}catch(t){if(o=t,l(t))return}e[s]=n={...n,error:o,status:"error",isFetching:!1,updatedAt:Date.now()}}o||this.setState((t=>({...t,matches:t.matches.map((t=>t.id===n.id?n:t))})))})())})),await Promise.all(a),e};load=async()=>{const t=new Promise((async(e,o)=>{const r=this.latestLocation,n=this.state.resolvedLocation,s=n.href!==r.href;let a;this.cancelMatches(),this.emit({type:"onBeforeLoad",fromLocation:n,toLocation:r,pathChanged:s});let i=this.matchRoutes(r.pathname,r.search,{debug:!0});this.pendingMatches=i;const c=this.state.matches;this.setState((t=>({...t,status:"pending",location:r,matches:i})));try{try{await this.loadMatches({matches:i,checkLatest:()=>this.checkLatest(t)})}catch(t){}if(a=this.checkLatest(t))return a;const o=c.filter((t=>!this.pendingMatches.includes(t))),l=this.pendingMatches.filter((t=>!c.includes(t)));[[o,"onLeave"],[l,"onEnter"],[c.filter((t=>this.pendingMatches.includes(t))),"onTransition"]].forEach((([t,e])=>{t.forEach((t=>{this.looseRoutesById[t.routeId].options[e]?.(t)}))})),this.emit({type:"onLoad",fromLocation:n,toLocation:r,pathChanged:s}),e()}catch(e){if(a=this.checkLatest(t))return a;o(e)}}));return this.latestLoadPromise=t,this.latestLoadPromise};preloadRoute=async(t=this.state.location)=>{let e=this.buildLocation(t),o=this.matchRoutes(e.pathname,e.search,{throwOnError:!0});return await this.loadMatches({matches:o,preload:!0,checkLatest:()=>{}}),[S(o),o]};buildLink=t=>{const{to:e,preload:o,preloadDelay:r,activeOptions:n,disabled:s,target:a,replace:i,resetScroll:c,startTransition:l}=t;try{return new URL(`${e}`),{type:"external",href:e}}catch(t){}const u=t,h=this.buildLocation(u),d=o??this.options.defaultPreload,f=r??this.options.defaultPreloadDelay??0,p=this.latestLocation.pathname.split("/"),m=h.pathname.split("/").every(((t,e)=>t===p[e])),y=n?.exact?this.latestLocation.pathname===h.pathname:m,g=!n?.includeHash||this.latestLocation.hash===h.hash,v=!(n?.includeSearch??1)||P(this.latestLocation.search,h.search,!0);return{type:"internal",next:h,handleFocus:t=>{d&&this.preloadRoute(u).catch((t=>{console.warn(t),console.warn(bt)}))},handleClick:t=>{s||function(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}(t)||t.defaultPrevented||a&&"_self"!==a||0!==t.button||(t.preventDefault(),this.commitLocation({...h,replace:i,resetScroll:c,startTransition:l}))},handleEnter:t=>{const e=t.target||{};if(d){if(e.preloadTimeout)return;e.preloadTimeout=setTimeout((()=>{e.preloadTimeout=null,this.preloadRoute(u).catch((t=>{console.warn(t),console.warn(bt)}))}),f)}},handleLeave:t=>{const e=t.target||{};e.preloadTimeout&&(clearTimeout(e.preloadTimeout),e.preloadTimeout=null)},handleTouchStart:t=>{this.preloadRoute(u).catch((t=>{console.warn(t),console.warn(bt)}))},isActive:y&&g&&v,disabled:s}};matchRoute=(t,e)=>{t={...t,to:t.to?this.resolvePathWithBase(t.from||"",t.to):void 0};const o=this.buildLocation(t);if(e?.pending&&"pending"!==this.state.status)return!1;const r=e?.pending?this.latestLocation:this.state.resolvedLocation;if(!r)return!1;const n=$(this.basepath,r.pathname,{...e,to:o.pathname});return!!n&&(n&&(e?.includeSearch??1)?!!P(r.search,o.search,!0)&&n:n)};injectHtml=async t=>{this.injectedHtml.push(t)};dehydrateData=(t,e)=>{if("undefined"==typeof document){const o="string"==typeof t?t:JSON.stringify(t);return this.injectHtml((async()=>{const t=`__TSR_DEHYDRATED__${o}`,r="function"==typeof e?await e():e;return`<script id='${t}' suppressHydrationWarning>window["__TSR_DEHYDRATED__${x(o)}"] = ${JSON.stringify(r)}\n ;(() => {\n var el = document.getElementById('${t}')\n el.parentElement.removeChild(el)\n })()\n <\/script>`})),()=>this.hydrateData(t)}return()=>{}};hydrateData=t=>{if("undefined"!=typeof document){const e="string"==typeof t?t:JSON.stringify(t);return window[`__TSR_DEHYDRATED__${e}`]}}},t.RouterProvider=function({router:t,...e}){t.updateOptions({...t.options,...e,context:{...t.options.context,...e?.context}});const[o,n]=r.useState((()=>t.state)),[s,a]=r.useTransition(),i=r.useMemo((()=>({...o,status:s?"pending":"idle",location:s?t.latestLocation:o.location,pendingMatches:t.pendingMatches})),[o,s]);return t.setState=n,t.state=i,t.startReactTransition=a,r.useLayoutEffect((()=>{const e=t.history.subscribe((()=>{t.latestLocation=t.parseLocation(t.latestLocation),i.location!==t.latestLocation&&a((()=>{try{t.load()}catch(t){console.error(t)}}))})),o=t.buildLocation({search:!0,params:!0,hash:!0,state:!0});return i.location.href!==o.href&&t.commitLocation({...o,replace:!0}),()=>{e()}}),[history]),r.useLayoutEffect((()=>{s||i.resolvedLocation===i.location||(t.emit({type:"onResolved",fromLocation:i.resolvedLocation,toLocation:i.location,pathChanged:i.location.href!==i.resolvedLocation?.href}),t.pendingMatches=[],n((t=>({...t,resolvedLocation:t.location}))))})),r.useLayoutEffect((()=>{a((()=>{try{t.load()}catch(t){console.error(t)}}))}),[]),r.createElement(tt.Provider,{value:t},r.createElement(z,null))},t.ScrollRestoration=function(t){return xt(t),null},t.SearchParamError=et,t.cleanPath=O,t.componentTypes=St,t.createBrowserHistory=h,t.createHashHistory=function(){return h({getHref:()=>window.location.hash.substring(1),createHref:t=>`#${t}`})},t.createMemoryHistory=function(t={initialEntries:["/"]}){const e=t.initialEntries;let o=t.initialIndex??e.length-1,r={key:f()};return l({getLocation:()=>d(e[o],r),pushState:(t,n)=>{r=n,e.push(t),o++},replaceState:(t,n)=>{r=n,e[o]=t},back:()=>{o--},forward:()=>{o=Math.min(o+1,e.length-1)},go:t=>window.history.go(t),createHref:t=>t})},t.createRouteMask=function(t){return t},t.decode=pt,t.deepEqual=P,t.defaultParseSearch=yt,t.defaultStringifySearch=gt,t.defer=function(t){const e=t;if(!e.__deferredState){e.__deferredState={uid:Math.random().toString(36).slice(2),status:"pending"};const t=e.__deferredState;e.then((e=>{t.status="success",t.data=e})).catch((e=>{t.status="error",t.error=e}))}return e},t.encode=dt,t.escapeJSON=x,t.functionalUpdate=b,t.getInitialRouterState=rt,t.getRouteMatch=nt,t.interpolatePath=B,t.invariant=p,t.isDehydratedDeferred=it,t.isPlainObject=E,t.isRedirect=mt,t.isServer=w,t.joinPaths=k,t.last=S,t.lazyFn=function(t,e){return async(...o)=>(await t())[e||"default"](...o)},t.lazyRouteComponent=function(t,e){let o;const n=()=>(o||(o=t()),o),s=r.lazy((async()=>({default:(await n())[e??"default"]})));return s.preload=n,s},t.matchByPath=A,t.matchPathname=$,t.matchesContext=Q,t.parsePathname=j,t.parseSearchWith=vt,t.pick=R,t.redirect=function(t){return t.isRedirect=!0,t},t.replaceEqualDeep=L,t.resolvePath=D,t.rootRouteId=K,t.rootRouteWithContext=function(){return t=>new W(t)},t.routerContext=tt,t.shallow=function(t,e){if(Object.is(t,e))return!0;if("object"!=typeof t||null===t||"object"!=typeof e||null===e)return!1;const o=Object.keys(t);if(o.length!==Object.keys(e).length)return!1;for(let r=0;r<o.length;r++)if(!Object.prototype.hasOwnProperty.call(e,o[r])||!Object.is(t[o[r]],e[o[r]]))return!1;return!0},t.stringifySearchWith=wt,t.trimPath=M,t.trimPathLeft=T,t.trimPathRight=I,t.typedNavigate=function(t){return t},t.useAwaited=ct,t.useBlocker=kt,t.useLayoutEffect=C,t.useLinkProps=ut,t.useLoaderData=Z,t.useMatch=G,t.useMatchRoute=V,t.useMatches=function(t){const e=r.useContext(Q);return st({select:o=>{const r=o.matches.slice(o.matches.findIndex((t=>t.id===e[0]?.id)));return t?.select?t.select(r):r}})},t.useNavigate=function(t){const{navigate:e}=at(),o=G({strict:!1});return r.useCallback((r=>e({from:r?.to?o.pathname:void 0,...t,...r})),[])},t.useParams=N,t.useRouteContext=function(t){return G({...t,select:e=>t?.select?t.select(e.context):e.context})},t.useRouter=at,t.useRouterState=st,t.useScrollRestoration=xt,t.useSearch=H,t.useStableCallback=function(t){const e=r.useRef(t);return e.current=t,r.useRef(((...t)=>e.current(...t))).current},t.warning=m,Object.defineProperty(t,"__esModule",{value:!0})}));
|
|
22
22
|
//# sourceMappingURL=index.production.js.map
|