@tanstack/react-router 0.0.1-beta.235 → 0.0.1-beta.237
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 +31 -18
- package/build/cjs/Matches.js.map +1 -1
- package/build/cjs/RouterProvider.js +45 -25
- package/build/cjs/RouterProvider.js.map +1 -1
- package/build/cjs/index.js +1 -0
- package/build/cjs/index.js.map +1 -1
- package/build/cjs/route.js +13 -7
- package/build/cjs/route.js.map +1 -1
- package/build/cjs/router.js +49 -37
- package/build/cjs/router.js.map +1 -1
- package/build/cjs/useParams.js +7 -2
- package/build/cjs/useParams.js.map +1 -1
- package/build/cjs/useSearch.js +6 -1
- package/build/cjs/useSearch.js.map +1 -1
- package/build/cjs/utils.js +4 -1
- package/build/cjs/utils.js.map +1 -1
- package/build/esm/index.js +155 -92
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +574 -293
- package/build/types/Matches.d.ts +9 -3
- package/build/types/RouterProvider.d.ts +3 -0
- package/build/types/route.d.ts +30 -10
- package/build/types/router.d.ts +6 -3
- package/build/types/useParams.d.ts +3 -1
- package/build/types/useSearch.d.ts +3 -1
- package/build/types/utils.d.ts +3 -1
- package/build/umd/index.development.js +423 -95
- 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 +4 -2
- package/src/Matches.tsx +70 -35
- package/src/RouterProvider.tsx +68 -32
- package/src/route.ts +37 -15
- package/src/router.ts +62 -44
- package/src/useParams.tsx +14 -4
- package/src/useSearch.tsx +11 -3
- package/src/utils.ts +20 -12
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
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){var e=Object.create(null);return t&&Object.keys(t).forEach((function(
|
|
11
|
+
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("react"),require("use-sync-external-store/shim")):"function"==typeof define&&define.amd?define(["exports","react","use-sync-external-store/shim"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).ReactRouter={},t.React,t.require$$1)}(this,(function(t,e,n){"use strict";function o(t){var e=Object.create(null);return t&&Object.keys(t).forEach((function(n){if("default"!==n){var o=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,o.get?o:{enumerable:!0,get:function(){return t[n]}})}})),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 r="pushstate",a="popstate",s="beforeunload",i=t=>(t.preventDefault(),t.returnValue=""),c=()=>{removeEventListener(s,i,{capture:!0})};function l(t){let e=t.getLocation(),o=new Set,n=[],r=[];const a=()=>{e=t.getLocation(),o.forEach((t=>t()))},l=()=>{if(n.length)n[0]?.(l,(()=>{n=[],c()}));else for(;r.length;)r.shift()?.()},h=t=>{r.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,a)}))},replace:(e,o)=>{o=u(o),h((()=>{t.replaceState(e,o,a)}))},go:e=>{h((()=>{t.go(e)}))},back:()=>{h((()=>{t.back()}))},forward:()=>{h((()=>{t.forward()}))},createHref:e=>t.createHref(e),block:t=>(n.push(t),1===n.length&&addEventListener(s,i,{capture:!0}),()=>{n=n.filter((e=>e!==t)),n.length||c()}),flush:()=>t.flush?.(),destroy:()=>t.destroy?.(),notify:a}}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 n=p(e(),window.history.state);let s,i,c=!0;const u=()=>{c=!1,(()=>{s&&(window.history[s.isPush?"pushState":"replaceState"](s.state,"",s.href),s=void 0,i=void 0)})(),c=!0},h=(t,e,r,a)=>{const c=o(e);n=p(c,r),s={href:c,state:r,isPush:s?.isPush||"push"===t},a(),i||(i=Promise.resolve().then((()=>u())))},d=()=>{n=p(e(),window.history.state),y.notify()};var f=window.history.pushState,m=window.history.replaceState;const y=l({getLocation:()=>n,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=f,window.history.replaceState=m,window.removeEventListener(r,d),window.removeEventListener(a,d)}});return window.addEventListener(r,d),window.addEventListener(a,d),window.history.pushState=function(){let t=f.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={initialEntries:["/"]}){const e=t.initialEntries;let o=t.initialIndex??e.length-1,n={key:f()};return l({getLocation:()=>p(e[o],n),pushState:(t,r)=>{n=r,e.push(t),o++},replaceState:(t,r)=>{n=r,e[o]=t},back:()=>{o--},forward:()=>{o=Math.min(o+1,e.length-1)},go:t=>window.history.go(t),createHref:t=>t})}function p(t,e){let o=t.indexOf("#"),n=t.indexOf("?");return{href:t,pathname:t.substring(0,o>0?n>0?Math.min(o,n):o:n>0?n:t.length),hash:o>-1?t.substring(o):"",search:n>-1?t.slice(n,-1===o?void 0:o):"",state:e||{}}}function f(){return(Math.random()+1).toString(36).substring(7)}var m="Invariant failed";function y(t,e){if(!t)throw new Error(m)}function g(t,e){}function v(t){const e=t.errorComponent??S;return n.createElement(w,{resetKey:t.resetKey,onCatch:t.onCatch,children:({error:o})=>o?n.createElement(e,{error:o}):t.children})}class w extends n.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 S({error:t}){const[e,o]=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:()=>o((t=>!t))},e?"Hide Error":"Show Error")),n.createElement("div",{style:{height:".25rem"}}),e?n.createElement("div",null,n.createElement("pre",{style:{fontSize:".7em",border:"1px solid red",borderRadius:".25rem",padding:".3rem",color:"red",overflow:"auto"}},t.message?n.createElement("code",null,t.message):null)):null)}const R="undefined"==typeof document;function b(t){return t[t.length-1]}function E(t,e){return"function"==typeof t?t(e):t}function L(t,e){return e.reduce(((e,o)=>(e[o]=t[o],e)),{})}function P(t,e){if(t===e)return t;const o=e,n=Array.isArray(t)&&Array.isArray(o);if(n||_(t)&&_(o)){const e=n?t.length:Object.keys(t).length,r=n?o:Object.keys(o),a=r.length,s=n?[]:{};let i=0;for(let e=0;e<a;e++){const a=n?e:r[e];s[a]=P(t[a],o[a]),s[a]===t[a]&&i++}return e===a&&i===e?t:s}return o}function _(t){if(!C(t))return!1;const e=t.constructor;if(void 0===e)return!0;const o=e.prototype;return!!C(o)&&!!o.hasOwnProperty("isPrototypeOf")}function C(t){return"[object Object]"===Object.prototype.toString.call(t)}function x(t,e,o=!1){if(t===e)return!0;if(typeof t!=typeof e)return!1;if(_(t)&&_(e)){const n=Object.keys(t),r=Object.keys(e);return!(!o&&n.length!==r.length)&&!r.some((n=>!(n in t)||!x(t[n],e[n],o)))}return!(!Array.isArray(t)||!Array.isArray(e))&&!t.some(((t,n)=>!x(t,e[n],o)))}const k="undefined"!=typeof window?n.useLayoutEffect:n.useEffect;function T(t){return t.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/"/g,'\\"')}function M(t){return O(t.filter(Boolean).join("/"))}function O(t){return t.replace(/\/{2,}/g,"/")}function D(t){return"/"===t?t:t.replace(/^\/{1,}/,"")}function I(t){return"/"===t?t:t.replace(/\/{1,}$/,"")}function j(t){return I(D(t))}function A(t,e,o){e=e.replace(new RegExp(`^${t}`),"/"),o=o.replace(new RegExp(`^${t}`),"/");let n=$(e);const r=$(o);r.forEach(((t,e)=>{if("/"===t.value)e?e===r.length-1&&n.push(t):n=[t];else if(".."===t.value)n.length>1&&"/"===b(n)?.value&&n.pop(),n.pop();else{if("."===t.value)return;n.push(t)}}));return O(M([t,...n.map((t=>t.value))]))}function $(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 M($(t).map((t=>{if("wildcard"===t.type){const n=e[t.value];return o?`${t.value}${n??""}`:n}return"param"===t.type?e[t.value.substring(1)]??"":t.value})))}function N(t,e,o){const n=H(t,e,o);if(!o.to||n)return n??{}}function H(t,e,o){e="/"!=t?e.substring(t.length):e;const n=`${o.to??"$"}`,r=$(e),a=$(n);e.startsWith("/")||r.unshift({type:"pathname",value:"/"}),n.startsWith("/")||a.unshift({type:"pathname",value:"/"});const s={};return(()=>{for(let t=0;t<Math.max(r.length,a.length);t++){const e=r[t],n=a[t],i=t>=r.length-1,c=t>=a.length-1;if(n){if("wildcard"===n.type)return!!e?.value&&(s["*"]=M(r.slice(t).map((t=>t.value))),!0);if("pathname"===n.type){if("/"===n.value&&!e?.value)return!0;if(e)if(o.caseSensitive){if(n.value!==e.value)return!1}else if(n.value.toLowerCase()!==e.value.toLowerCase())return!1}if(!e)return!1;if("param"===n.type){if("/"===e?.value)return!1;"$"!==e.value.charAt(0)&&(s[n.value.substring(1)]=e.value)}}if(!i&&c)return!!o.fuzzy}return!0})()?s:void 0}function K(t){return b(rt().state.matches)?.params}function F(t){return Q(t).search}const W="__root__";class z{constructor(t){this.options=t||{},this.isRoot=!t?.getParentRoute,z.__onInit(this),this.$$typeof=Symbol.for("react.memo")}init=t=>{this.originalIndex=t.originalIndex;const e=this.options,o=!e?.path&&!e?.id;this.parentRoute=this.options?.getParentRoute?.(),o?this.path=W:y(this.parentRoute);let n=o?W:e.path;n&&"/"!==n&&(n=j(n));const r=e?.id||n;let a=o?W:M([this.parentRoute.id===W?"":this.parentRoute.id,r]);n===W&&(n="/"),a!==W&&(a=M(["/",a]));const s=a===W?"/":M([this.parentRoute.fullPath,n]);this.path=n,this.id=a,this.fullPath=s,this.to=s};addChildren=t=>(this.children=t,this);update=t=>(Object.assign(this.options,t),this);static __onInit=t=>{};useMatch=()=>Q({from:this.id});useRouteContext=()=>Q({from:this.id}).context;useSearch=()=>F({from:this.id});useParams=()=>K(this.id);useLoaderData=()=>tt({from:this.id})}class U extends z{constructor(t){super(t)}}function Y(){const t=rt(),{matches:e}=t.state,o=t.state.location.state.key,r=t.routesById[W],a=n.useCallback((t=>n.createElement(S,{...t,useMatch:r.useMatch,useRouteContext:r.useRouteContext,useSearch:r.useSearch,useParams:r.useParams})),[r]);return n.createElement(Z.Provider,{value:e},n.createElement(v,{resetKey:o,errorComponent:a,onCatch:()=>{}},e.length?n.createElement(X,{matches:e}):null))}function J(t){return n.createElement(n.Fragment,null,t.children)}function X({matches:t}){const{options:e,routesById:o}=rt(),r=t[0],a=r?.routeId,s=o[a],i=rt(),c=i.latestLocation.state?.key,l=s.options.pendingComponent??e.defaultPendingComponent,u=l?n.createElement(l,{useMatch:s.useMatch,useRouteContext:s.useRouteContext,useSearch:s.useSearch,useParams:s.useParams}):void 0,h=s.options.errorComponent??e.defaultErrorComponent??S,d=s.options.wrapInSuspense??u?n.Suspense:J,p=h?n.useCallback((t=>n.createElement(h,{...t,useMatch:s.useMatch,useRouteContext:s.useRouteContext,useSearch:s.useSearch,useParams:s.useParams})),[s]):void 0,f=p?v:J;return n.createElement(Z.Provider,{value:t},n.createElement(d,{fallback:u},n.createElement(f,{resetKey:c,errorComponent:p,onCatch:()=>{r.id}},n.createElement(q,{match:r,pendingElement:u}))))}function q({match:t,pendingElement:e}){const{options:o,routesById:r}=rt(),a=r[t.routeId];if("error"===t.status)throw t.error;if("pending"===t.status){if(t.showPending)return e||null;throw t.loadPromise}if("success"===t.status){let t=a.options.component??o.defaultComponent;return t?n.createElement(t,{useMatch:a.useMatch,useRouteContext:a.useRouteContext,useSearch:a.useSearch,useParams:a.useParams,useLoaderData:a.useLoaderData}):n.createElement(V,null)}y(!1)}function V(){const t=n.useContext(Z).slice(1);return t[0]?n.createElement(X,{matches:t}):null}function G(){const{matchRoute:t}=rt();return n.useCallback((e=>{const{pending:o,caseSensitive:n,...r}=e;return t(r,{pending:o,caseSensitive:n})}),[])}function Q(t){const e=rt(),o=n.useContext(Z)[0],r=o?.routeId,a=(t?.from?e.state.matches.find((e=>e.routeId===t?.from)):e.state.matches.find((t=>t.id===o.id))).routeId;(t?.strict??1)&&y(r==a);return(()=>{const n=t?.from?e.state.matches.find((e=>e.routeId===t?.from)):e.state.matches.find((t=>t.id===o.id));return y(n,t?.from&&t.from),n})()}const Z=n.createContext(null);function tt(t){return Q(t)?.loaderData}const et=n.createContext(null);function ot({router:t}){const[e,o]=n.useState((()=>t.state)),[r,a]=n.useTransition(),s=r||e.matches.some((t=>"pending"===t.status)),i=n.useMemo((()=>({...e,status:s?"pending":"idle",location:r?t.latestLocation:e.location,pendingMatches:t.pendingMatches})),[e,r]);t.setState=o,t.state=i,t.startReactTransition=a;const c=()=>{a((()=>{try{t.load()}catch(t){console.error(t)}}))};return k((()=>{const e=t.history.subscribe((()=>{t.latestLocation=t.parseLocation(t.latestLocation),i.location!==t.latestLocation&&c()})),o=t.buildLocation({search:!0,params:!0,hash:!0,state:!0});return i.location.href!==o.href&&t.commitLocation({...o,replace:!0}),()=>{e()}}),[t.history]),k((()=>{r||i.resolvedLocation===i.location||(t.emit({type:"onResolved",fromLocation:i.resolvedLocation,toLocation:i.location,pathChanged:i.location.href!==i.resolvedLocation?.href}),t.pendingMatches=[],o((t=>({...t,resolvedLocation:t.location}))))})),k((()=>{window.__TSR_DEHYDRATED__||c()}),[]),n.createElement(et.Provider,{value:t},n.createElement(Y,null))}function nt(t,e){return[...t.pendingMatches,...t.matches].find((t=>t.id===e))}function rt(){const t="undefined"!=typeof document&&window.__TSR_ROUTER_CONTEXT__||et;return n.useContext(t)}function at(t){return"object"==typeof t&&null!==t&&!(t instanceof Promise)&&!t.then&&"__deferredState"in t}function st({promise:t}){const e=rt();let o=t.__deferredState;const n=`__TSR__DEFERRED__${o.uid}`;if(at(t)&&(o=e.hydrateData(n),(t=Promise.resolve(o.data)).__deferredState=o),"pending"===o.status)throw new Promise((t=>setTimeout(t,1))).then((()=>t));if("error"===o.status)throw o.error;return e.dehydrateData(n,o),[o.data]}"undefined"!=typeof document&&(window.__TSR_ROUTER_CONTEXT__=et);function it(){return it=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var o=arguments[e];for(var n in o)Object.prototype.hasOwnProperty.call(o,n)&&(t[n]=o[n])}return t},it.apply(this,arguments)}function ct(t){const{buildLink:e}=rt(),o=Q({strict:!1}),{type:n,children:r,target:a,activeProps:s=(()=>({className:"active"})),inactiveProps:i=(()=>({})),activeOptions:c,disabled:l,hash:u,search:h,params:d,to:p,state:f,mask:m,preload:y,preloadDelay:g,replace:v,startTransition:w,resetScroll:S,style:R,className:b,onClick:L,onFocus:P,onMouseEnter:_,onMouseLeave:C,onTouchStart:x,...k}=t,T=e({from:t.to?o.pathname:void 0,...t});if("external"===T.type){const{href:t}=T;return{href:t}}const{handleClick:M,handleFocus:O,handleEnter:D,handleLeave:I,handleTouchStart:j,isActive:A,next:$}=T,B=t=>e=>{e.persist&&e.persist(),t.filter(Boolean).forEach((t=>{e.defaultPrevented||t(e)}))},N=A?E(s,{})??{}:{},H=A?{}:E(i,{})??{};return{...N,...H,...k,href:l?void 0:$.maskedLocation?$.maskedLocation.href:$.href,onClick:B([L,M]),onFocus:B([P,O]),onMouseEnter:B([_,D]),onMouseLeave:B([C,I]),onTouchStart:B([x,j]),target:a,style:{...R,...N.style,...H.style},className:[b,N.className,H.className].filter(Boolean).join(" ")||void 0,...l?{role:"link","aria-disabled":!0}:void 0,"data-status":A?"active":void 0}}const lt=n.forwardRef(((t,e)=>{const o=ct(t);return n.createElement("a",it({ref:e},o,{children:"function"==typeof t.children?t.children({isActive:"active"===o["data-status"]}):t.children}))}));function ut(t,e){var o,n,r,a="";for(o in t)if(void 0!==(r=t[o]))if(Array.isArray(r))for(n=0;n<r.length;n++)a&&(a+="&"),a+=encodeURIComponent(o)+"="+encodeURIComponent(r[n]);else a&&(a+="&"),a+=encodeURIComponent(o)+"="+encodeURIComponent(r);return(e||"")+a}function ht(t){if(!t)return"";var e=decodeURIComponent(t);return"false"!==e&&("true"===e||(0*+e==0&&+e+""===e?+e:e))}function dt(t){for(var e,o,n={},r=t.split("&");e=r.shift();)void 0!==n[o=(e=e.split("=")).shift()]?n[o]=[].concat(n[o],ht(e.shift())):n[o]=ht(e.shift());return n}function pt(t){return!!t?.isRedirect}const ft=yt(JSON.parse),mt=gt(JSON.stringify,JSON.parse);function yt(t){return e=>{"?"===e.substring(0,1)&&(e=e.substring(1));let o=dt(e);for(let e in o){const n=o[e];if("string"==typeof n)try{o[e]=t(n)}catch(t){}}return o}}function gt(t,e){return o=>{(o={...o})&&Object.keys(o).forEach((n=>{const r=o[n];void 0===r||void 0===r?delete o[n]:o[n]=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}(r)}));const n=ut(o).toString();return n?`?${n}`:""}}const vt=["component","errorComponent","pendingComponent"],wt="Error preloading route! ☝️";class St extends Error{}class Rt extends Error{}function bt(t){return{status:"idle",resolvedLocation:t,location:t,matches:[],pendingMatches:[],lastUpdated:Date.now()}}const Et="undefined"!=typeof window?n.useLayoutEffect:n.useEffect,Lt="window",Pt="___";let _t=new WeakSet;let Ct="undefined"!=typeof window&&window.sessionStorage?(()=>{const t="tsr-scroll-restoration-v2";return{state:JSON.parse(window.sessionStorage.getItem(t)||"null")||{cached:{},next:{}},set:e=>{Ct.state=E(e,Ct.state),window.sessionStorage.setItem(t,JSON.stringify(Ct.state))}}})():void 0;const xt=t=>t.state.key;function kt(t){const e=rt();Et((()=>{const o=t?.getKey||xt,{history:n}=window;n.scrollRestoration&&(n.scrollRestoration="manual");const r=t=>{if(_t.has(t.target))return;_t.add(t.target);let e="";if(t.target===document||t.target===window)e=Lt;else{const o=t.target.getAttribute("data-scroll-restoration-id");e=o?`[data-scroll-restoration-id="${o}"]`:Tt(t.target)}Ct.state.next[e]||Ct.set((t=>({...t,next:{...t.next,[e]:{scrollX:NaN,scrollY:NaN}}})))};"undefined"!=typeof document&&document.addEventListener("scroll",r,!0);const a=e.subscribe("onBeforeLoad",(t=>{if(t.pathChanged){const e=o(t.fromLocation);for(const t in Ct.state.next){const o=Ct.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}Ct.set((n=>{const r={...n.next};return delete r[t],{...n,next:r,cached:{...n.cached,[[e,t].join(Pt)]:o}}}))}}})),s=e.subscribe("onResolved",(o=>{if(o.pathChanged){if(!e.resetNextScroll)return;e.resetNextScroll=!0;const n=(t?.getKey||xt)(o.toLocation);let r=!1;for(const t in Ct.state.cached){const e=Ct.state.cached[t],[o,a]=t.split(Pt);if(o===n)if(a===Lt)r=!0,window.scrollTo(e.scrollX,e.scrollY);else if(a){const t=document.querySelector(a);t&&(t.scrollLeft=e.scrollX,t.scrollTop=e.scrollY)}}r||window.scrollTo(0,0),Ct.set((t=>({...t,next:{}}))),_t=new WeakSet}}));return()=>{document.removeEventListener("scroll",r),a(),s()}}),[])}function Tt(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()}function Mt(t,e=!0){const{history:o}=rt();n.useEffect((()=>{if(!e)return;let n=o.block(((e,o)=>{window.confirm(t)&&(n(),e())}));return n}))}t.Await=function(t){const e=st(t);return t.children(...e)},t.Block=function({message:t,condition:e,children:o}){return Mt(t,e),o??null},t.CatchBoundary=v,t.CatchBoundaryImpl=w,t.ErrorComponent=S,t.FileRoute=class{constructor(t){this.path=t}createRoute=t=>{const e=new z(t);return e.isRoot=!1,e}},t.Link=lt,t.Match=X,t.MatchRoute=function(t){const e=G()(t);return"function"==typeof t.children?t.children(e):e?t.children:null},t.Matches=Y,t.Navigate=function(t){const{navigate:e}=rt(),o=Q({strict:!1});return k((()=>{e({from:t.to?o.pathname:void 0,...t})}),[]),null},t.Outlet=V,t.PathParamError=Rt,t.RootRoute=U,t.Route=z,t.Router=class{tempLocationKey=`${Math.round(1e7*Math.random())}`;resetNextScroll=!0;navigateTimeout=null;latestLoadPromise=Promise.resolve();subscribers=new Set;pendingMatches=[];injectedHtml=[];constructor(t){this.update({defaultPreloadDelay:50,defaultPendingMs:1e3,defaultPendingMinMs:500,context:void 0,...t,stringifySearch:t?.stringifySearch??mt,parseSearch:t?.parseSearch??ft})}startReactTransition=t=>t();setState=t=>{this.state=E(t,this.state)};update=t=>{this.options={...this.options,...t},this.basepath=`/${j(t.basepath??"")??""}`,(!this.history||this.options.history&&this.options.history!==this.history)&&(this.history=this.options.history??("undefined"!=typeof document?h():d()),this.latestLocation=this.parseLocation()),this.options.routeTree!==this.routeTree&&(this.routeTree=this.options.routeTree,this.buildRouteTree()),this.state||(this.state=bt(this.latestLocation))};buildRouteTree=()=>{this.routesById={},this.routesByPath={};const t=e=>{e.forEach(((e,o)=>{e.init({originalIndex:o});if(y(!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 n=e.children;n?.length&&t(n)}))};t([this.routeTree]),this.flatRoutes=Object.values(this.routesByPath).map(((t,e)=>{const o=j(t.fullPath),n=$(o);for(;n.length>1&&"/"===n[0]?.value;)n.shift();const r=n.map((t=>"param"===t.type?.5:"wildcard"===t.type?.25:1));return{child:t,trimmed:o,parsed:n,index:e,score:r}})).sort(((t,e)=>{let o="/"===t.trimmed?1:"/"===e.trimmed?-1:0;if(0!==o)return o;const n=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<n;o++)if(t.score[o]!==e.score[o])return e.score[o]-t.score[o];for(let o=0;o<n;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:n,state:r})=>{const a=this.options.parseSearch(o);return{pathname:e,searchStr:o,search:P(t?.search,a),hash:n.split("#").reverse()[0]??"",href:`${e}${o}${n}`,state:P(t?.state,r)}},o=e(this.history.location);let{__tempLocation:n,__tempKey:r}=o.state;if(n&&(!r||r===this.tempLocationKey)){const t=e(n);return t.state.key=o.state.key,delete t.state.__tempLocation,{...t,maskedLocation:o}}return o};resolvePathWithBase=(t,e)=>A(this.basepath,t,O(e));get looseRoutesById(){return this.routesById}matchRoutes=(t,e,o)=>{let n={},r=this.flatRoutes.find((e=>{const o=N(this.basepath,I(t),{to:e.fullPath,caseSensitive:e.options.caseSensitive??this.options.caseSensitive,fuzzy:!1});return!!o&&(n=o,!0)}))||this.routesById.__root__,a=[r];for(;r?.parentRoute;)r=r.parentRoute,r&&a.unshift(r);const s=a.map((t=>{let e;if(t.options.parseParams)try{const e=t.options.parseParams(n);Object.assign(n,e)}catch(t){if(e=new Rt(t.message,{cause:t}),o?.throwOnError)throw e;return e}})),i=[];return a.forEach(((t,r)=>{const a=i[r-1],[c,l]=(()=>{const n=a?.search??e;try{const e="object"==typeof t.options.validateSearch?t.options.validateSearch.parse:t.options.validateSearch;let o=e?.(n)??{};return[{...n,...o},void 0]}catch(t){const e=new St(t.message,{cause:t});if(o?.throwOnError)throw e;return[n,e]}})(),u=B(t.path,n),h=B(t.id,n,!0)+(t.options.key?.({search:c,location:this.state.location})??""),d=nt(this.state,h),p=this.state.matches.find((t=>t.id===h))?"stay":"enter",f=!(!t.options.loader&&!vt.some((e=>t.options[e]?.preload))),m=d?{...d,cause:p}:{id:h,routeId:t.id,params:n,pathname:M([this.basepath,u]),updatedAt:Date.now(),search:{},searchError:void 0,status:f?"pending":"success",showPending:!1,isFetching:!1,invalid:!1,error:void 0,paramsError:s[r],loadPromise:Promise.resolve(),context:void 0,abortController:new AbortController,shouldReloadDeps:void 0,fetchedAt:0,cause:p};m.search=P(m.search,c),m.searchError=l,i.push(m)})),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,n=t.from??o.pathname;let r=this.resolvePathWithBase(n,`${t.to??""}`);const a=this.matchRoutes(n,o.search),s=e?.filter((t=>a?.find((e=>e.routeId===t.routeId)))),i={...b(a)?.params};let c=!0===(t.params??!0)?i:E(t.params,i);c&&e?.map((t=>this.looseRoutesById[t.routeId].options.stringifyParams)).filter(Boolean).forEach((t=>{c={...c,...t(c)}})),r=B(r,c??{});const l=s?.map((t=>this.looseRoutesById[t.routeId].options.preSearchFilters??[])).flat().filter(Boolean)??[],u=s?.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?E(t.search,h)??{}:l?.length?h:{},p=u?.length?u.reduce(((t,e)=>e(t)),d):d,f=P(o.search,p),m=this.options.stringifySearch(f),y=!0===t.hash?o.hash:t.hash?E(t.hash,o.hash):o.hash,g=y?`#${y}`:"";let v=!0===t.state?o.state:t.state?E(t.state,o.state):o.state;return v=P(o.state,v),{pathname:r,search:f,searchStr:m,state:v,hash:y,href:this.history.createHref(`${r}${m}${g}`),unmaskOnReload:t.unmaskOnReload}},o=(t={},o)=>{let n=e(t),r=o?e(o):void 0;if(!r){let t={},a=this.options.routeMasks?.find((e=>{const o=N(this.basepath,n.pathname,{to:e.from,caseSensitive:!1,fuzzy:!1});return!!o&&(t=o,!0)}));a&&(a={...a,from:B(a.from,t)},r=e(o=a))}const a=this.matchRoutes(n.pathname,n.search),s=r?this.matchRoutes(r.pathname,r.search):void 0,i=r?e(o,s):void 0,c=e(t,a);return i&&(c.maskedLocation=i),c};return t.mask?o(t,{...L(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,...n}=e;o&&(n={...o,state:{...o.state,__tempKey:void 0,__tempLocation:{...n,search:n.searchStr,state:{...n.state,__tempKey:void 0,__tempLocation:void 0,key:void 0}}}},(n.unmaskOnReload??this.options.unmaskOnReload)&&(n.state.__tempKey=this.tempLocationKey));const r=()=>{this.history[e.replace?"replace":"push"](n.href,n.state)};t??1?this.startReactTransition(r):r()}return this.resetNextScroll=e.resetScroll??!0,this.latestLoadPromise};buildAndCommitLocation=({replace:t,resetScroll:e,startTransition:o,...n}={})=>{const r=this.buildLocation(n);return this.commitLocation({...r,startTransition:o,replace:t,resetScroll:e})};navigate=({from:t,to:e="",...o})=>{const n=String(e),r=void 0===t?t:String(t);let a;try{new URL(`${n}`),a=!0}catch(t){}return y(!a),this.buildAndCommitLocation({...o,from:r,to:n})};loadMatches=async({checkLatest:t,matches:e,preload:o,invalidate:n})=>{let r,a;try{for(let[t,n]of e.entries()){const r=e[t-1],s=this.looseRoutesById[n.routeId],i=(o,r)=>{if(o.routerCode=r,a=a??t,pt(o))throw o;try{s.options.onError?.(o)}catch(t){if(o=t,pt(t))throw t}e[t]=n={...n,error:o,status:"error",updatedAt:Date.now()}};try{n.paramsError&&i(n.paramsError,"PARSE_PARAMS"),n.searchError&&i(n.searchError,"VALIDATE_SEARCH");const a=r?.context??this.options.context??{},c=await(s.options.beforeLoad?.({search:n.search,abortController:n.abortController,params:n.params,preload:!!o,context:a,location:this.state.location,navigate:t=>this.navigate({...t,from:n.pathname}),buildLocation:this.buildLocation,cause:n.cause}))??{},l={...a,...c};e[t]=n={...n,context:P(n.context,l)}}catch(t){i(t,"BEFORE_LOAD");break}}}catch(t){if(pt(t))return o||this.navigate(t),e;throw t}const s=e.slice(0,a),i=[];return s.forEach(((a,s)=>{i.push((async()=>{const c=i[s-1],l=this.looseRoutesById[a.routeId],u=t=>!!pt(t)&&(o||this.navigate(t),!0);let h;e[s]=a={...a,fetchedAt:Date.now(),invalid:!1,showPending:!1};const d=l.options.pendingMs??this.options.defaultPendingMs;let p;if(!o&&d&&(l.options.pendingComponent??this.options.defaultPendingComponent)&&(p=new Promise((t=>setTimeout(t,d)))),a.isFetching)h=nt(this.state,a.id)?.loadPromise;else{const t={params:a.params,search:a.search,preload:!!o,parentMatchPromise:c,abortController:a.abortController,context:a.context,location:this.state.location,navigate:t=>this.navigate({...t,from:a.pathname}),cause:a.cause};let r=!0,i="function"==typeof l.options.shouldReload?l.options.shouldReload?.(t):!!(l.options.shouldReload??1);if("enter"===a.cause||n?a.shouldReloadDeps=i:"stay"===a.cause&&("object"==typeof i?(r=!x(i,a.shouldReloadDeps),a.shouldReloadDeps=i):r=!!i),r){e[s]=a={...a,isFetching:!0};const o=Promise.all(vt.map((async t=>{const e=l.options[t];e?.preload&&await e.preload()}))),n=l.options.loader?.(t);h=Promise.all([o,n]).then((t=>t[1]))}else h=Promise.resolve(a.loaderData)}e[s]=a={...a,loadPromise:h},o||this.setState((t=>({...t,matches:t.matches.map((t=>t.id===a.id?a:t))})));let f=!1;await new Promise((async n=>{p&&p.then((()=>{(r=t())||(f=!0,e[s]=a={...a,showPending:!0},this.setState((t=>({...t,matches:t.matches.map((t=>t.id===a.id?a:t))}))),n())}));try{const o=await h;if(r=t())return await r;const n=l.options.pendingMinMs??this.options.defaultPendingMinMs;if(f&&n&&await new Promise((t=>setTimeout(t,n))),r=t())return await r;e[s]=a={...a,error:void 0,status:"success",isFetching:!1,updatedAt:Date.now(),loaderData:o,loadPromise:void 0}}catch(o){if(r=t())return await r;if(u(o))return;try{l.options.onError?.(o)}catch(t){if(o=t,u(t))return}e[s]=a={...a,error:o,status:"error",isFetching:!1,updatedAt:Date.now()}}o||this.setState((t=>({...t,matches:t.matches.map((t=>t.id===a.id?a:t))}))),n()}))})())})),await Promise.all(i),e};invalidate=()=>this.load({invalidate:!0});load=async t=>{const e=new Promise((async(o,n)=>{const r=this.latestLocation,a=this.state.resolvedLocation,s=a.href!==r.href;let i;this.cancelMatches(),this.emit({type:"onBeforeLoad",fromLocation:a,toLocation:r,pathChanged:s});let c=this.matchRoutes(r.pathname,r.search,{debug:!0});this.pendingMatches=c;const l=this.state.matches;this.setState((t=>({...t,location:r,matches:c})));try{try{await this.loadMatches({matches:c,checkLatest:()=>this.checkLatest(e),invalidate:t?.invalidate})}catch(t){}if(i=this.checkLatest(e))return i;const n=l.filter((t=>!this.pendingMatches.includes(t))),u=this.pendingMatches.filter((t=>!l.includes(t)));[[n,"onLeave"],[u,"onEnter"],[l.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:a,toLocation:r,pathChanged:s}),o()}catch(t){if(i=this.checkLatest(e))return i;n(t)}}));return this.latestLoadPromise=e,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:()=>{}}),[b(o),o]};buildLink=t=>{const{to:e,preload:o,preloadDelay:n,activeOptions:r,disabled:a,target:s,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,p=n??this.options.defaultPreloadDelay??0,f=this.latestLocation.pathname.split("/"),m=h.pathname.split("/").every(((t,e)=>t===f[e])),y=r?.exact?this.latestLocation.pathname===h.pathname:m,g=!r?.includeHash||this.latestLocation.hash===h.hash,v=!(r?.includeSearch??1)||x(this.latestLocation.search,h.search,!0);return{type:"internal",next:h,handleFocus:t=>{d&&this.preloadRoute(u).catch((t=>{console.warn(t),console.warn(wt)}))},handleClick:t=>{a||function(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}(t)||t.defaultPrevented||s&&"_self"!==s||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(wt)}))}),p)}},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(wt)}))},isActive:y&&g&&v,disabled:a}};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 n=e?.pending?this.latestLocation:this.state.resolvedLocation;if(!n)return!1;const r=N(this.basepath,n.pathname,{...e,to:o.pathname});return!!r&&(r&&(e?.includeSearch??1)?!!x(n.search,o.search,!0)&&r:r)};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}`,n="function"==typeof e?await e():e;return`<script id='${t}' suppressHydrationWarning>window["__TSR_DEHYDRATED__${T(o)}"] = ${JSON.stringify(n)}\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}`]}};dehydrate=()=>({state:{dehydratedMatches:this.state.matches.map((t=>L(t,["fetchedAt","invalid","id","status","updatedAt","loaderData"])))}});hydrate=async t=>{let e=t;"undefined"!=typeof document&&(e=window.__TSR_DEHYDRATED__),y(e);const o=e;this.dehydratedData=o.payload,this.options.hydrate?.(o.payload);const n=o.router.state;let r=this.matchRoutes(this.state.location.pathname,this.state.location.search).map((t=>{const e=n.dehydratedMatches.find((e=>e.id===t.id));return y(e,t.id),e?{...t,...e}:t}));this.setState((t=>({...t,matches:r})))}},t.RouterProvider=function({router:t,...e}){t.update({...t.options,...e,context:{...t.options.context,...e?.context}});const o=n.createElement(ot,{router:t});return t.options.Wrap?n.createElement(t.options.Wrap,null,o):o},t.ScrollRestoration=function(t){return kt(t),null},t.SearchParamError=St,t.cleanPath=O,t.componentTypes=vt,t.createBrowserHistory=h,t.createHashHistory=function(){return h({getHref:()=>window.location.hash.substring(1),createHref:t=>`#${t}`})},t.createMemoryHistory=d,t.createRouteMask=function(t){return t},t.decode=dt,t.deepEqual=x,t.defaultParseSearch=ft,t.defaultStringifySearch=mt,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=ut,t.escapeJSON=T,t.functionalUpdate=E,t.getInitialRouterState=bt,t.getRouteMatch=nt,t.interpolatePath=B,t.invariant=y,t.isDehydratedDeferred=at,t.isPlainObject=_,t.isRedirect=pt,t.isServer=R,t.joinPaths=M,t.last=b,t.lazyFn=function(t,e){return async(...o)=>(await t())[e||"default"](...o)},t.lazyRouteComponent=function(t,e){let o;const r=()=>(o||(o=t()),o),a=n.lazy((async()=>({default:(await r())[e??"default"]})));return a.preload=r,a},t.matchByPath=H,t.matchPathname=N,t.matchesContext=Z,t.parsePathname=$,t.parseSearchWith=yt,t.pick=L,t.redirect=function(t){return t.isRedirect=!0,t},t.replaceEqualDeep=P,t.resolvePath=A,t.rootRouteId=W,t.rootRouteWithContext=function(){return t=>new U(t)},t.routerContext=et,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 n=0;n<o.length;n++)if(!Object.prototype.hasOwnProperty.call(e,o[n])||!Object.is(t[o[n]],e[o[n]]))return!1;return!0},t.stringifySearchWith=gt,t.trimPath=j,t.trimPathLeft=D,t.trimPathRight=I,t.typedNavigate=function(t){return t},t.useAwaited=st,t.useBlocker=Mt,t.useElementScrollRestoration=function(t){const e=rt(),o=t?.getKey||xt;let n="";if(t.id)n=`[data-scroll-restoration-id="${t.id}"]`;else{const e=t.getElement?.();if(!e)return;n=Tt(e)}const r=[o(e.latestLocation),n].join(Pt);return Ct.state.cached[r]},t.useLayoutEffect=k,t.useLinkProps=ct,t.useLoaderData=tt,t.useMatch=Q,t.useMatchRoute=G,t.useMatches=function(){const t=rt(),e=n.useContext(Z);return t.state.matches.slice(t.state.matches.findIndex((t=>t.id===e[0]?.id)))},t.useNavigate=function(t){const{navigate:e}=rt(),o=Q({strict:!1});return n.useCallback((n=>e({from:n?.to?o.pathname:void 0,...t,...n})),[])},t.useParams=K,t.useRouteContext=function(t){return Q(t).context},t.useRouter=rt,t.useScrollRestoration=kt,t.useSearch=F,t.useStableCallback=function(t){const e=n.useRef(t);return e.current=t,n.useRef(((...t)=>e.current(...t))).current},t.warning=g}));
|
|
21
|
+
*/const s="pushstate",a="popstate",i="beforeunload",c=t=>(t.preventDefault(),t.returnValue=""),l=()=>{removeEventListener(i,c,{capture:!0})};function u(t){let e=t.getLocation(),n=new Set,o=[],r=[];const s=()=>{e=t.getLocation(),n.forEach((t=>t()))},a=()=>{if(o.length)o[0]?.(a,(()=>{o=[],l()}));else for(;r.length;)r.shift()?.()},u=t=>{r.push(t),a()};return{get location(){return e},subscribe:t=>(n.add(t),()=>{n.delete(t)}),push:(e,n)=>{n=h(n),u((()=>{t.pushState(e,n,s)}))},replace:(e,n)=>{n=h(n),u((()=>{t.replaceState(e,n,s)}))},go:e=>{u((()=>{t.go(e)}))},back:()=>{u((()=>{t.back()}))},forward:()=>{u((()=>{t.forward()}))},createHref:e=>t.createHref(e),block:t=>(o.push(t),1===o.length&&addEventListener(i,c,{capture:!0}),()=>{o=o.filter((e=>e!==t)),o.length||l()}),flush:()=>t.flush?.(),destroy:()=>t.destroy?.(),notify:s}}function h(t){return t||(t={}),{...t,key:m()}}function d(t){const e=t?.getHref??(()=>`${window.location.pathname}${window.location.search}${window.location.hash}`),n=t?.createHref??(t=>t);let o=p(e(),window.history.state);let r,i,c=!0;const l=()=>{c=!1,(()=>{r&&(window.history[r.isPush?"pushState":"replaceState"](r.state,"",r.href),r=void 0,i=void 0)})(),c=!0},h=(t,e,s,a)=>{const c=n(e);o=p(c,s),r={href:c,state:s,isPush:r?.isPush||"push"===t},a(),i||(i=Promise.resolve().then((()=>l())))},d=()=>{o=p(e(),window.history.state),y.notify()};var f=window.history.pushState,m=window.history.replaceState;const y=u({getLocation:()=>o,pushState:(t,e,n)=>h("push",t,e,n),replaceState:(t,e,n)=>h("replace",t,e,n),back:()=>window.history.back(),forward:()=>window.history.forward(),go:t=>window.history.go(t),createHref:t=>n(t),flush:l,destroy:()=>{window.history.pushState=f,window.history.replaceState=m,window.removeEventListener(s,d),window.removeEventListener(a,d)}});return window.addEventListener(s,d),window.addEventListener(a,d),window.history.pushState=function(){let t=f.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 f(t={initialEntries:["/"]}){const e=t.initialEntries;let n=t.initialIndex??e.length-1,o={key:m()};return u({getLocation:()=>p(e[n],o),pushState:(t,r)=>{o=r,e.push(t),n++},replaceState:(t,r)=>{o=r,e[n]=t},back:()=>{n--},forward:()=>{n=Math.min(n+1,e.length-1)},go:t=>window.history.go(t),createHref:t=>t})}function p(t,e){let n=t.indexOf("#"),o=t.indexOf("?");return{href:t,pathname:t.substring(0,n>0?o>0?Math.min(n,o):n:o>0?o:t.length),hash:n>-1?t.substring(n):"",search:o>-1?t.slice(o,-1===n?void 0:n):"",state:e||{}}}function m(){return(Math.random()+1).toString(36).substring(7)}var y="Invariant failed";function g(t,e){if(!t)throw new Error(y)}function v(t,e){}var w,b={exports:{}},S={};b.exports=function(){if(w)return S;w=1;var t=e,o=n,r="function"==typeof Object.is?Object.is:function(t,e){return t===e&&(0!==t||1/t==1/e)||t!=t&&e!=e},s=o.useSyncExternalStore,a=t.useRef,i=t.useEffect,c=t.useMemo,l=t.useDebugValue;return S.useSyncExternalStoreWithSelector=function(t,e,n,o,u){var h=a(null);if(null===h.current){var d={hasValue:!1,value:null};h.current=d}else d=h.current;h=c((function(){function t(t){if(!i){if(i=!0,s=t,t=o(t),void 0!==u&&d.hasValue){var e=d.value;if(u(e,t))return a=e}return a=t}if(e=a,r(s,t))return e;var n=o(t);return void 0!==u&&u(e,n)?e:(s=t,a=n)}var s,a,i=!1,c=void 0===n?null:n;return[function(){return t(e())},null===c?void 0:function(){return t(c())}]}),[e,n,o,u]);var f=s(t,h[0],h[1]);return i((function(){d.hasValue=!0,d.value=f}),[f]),l(f),f},S}();var _=b.exports,R=class{constructor(t,e){this.listeners=new Set,this._batching=!1,this._flushing=0,this._nextPriority=null,this.subscribe=t=>{this.listeners.add(t);const e=this.options?.onSubscribe?.(t,this);return()=>{this.listeners.delete(t),e?.()}},this.setState=(t,e)=>{const n=this.state;this.state=this.options?.updateFn?this.options.updateFn(n)(t):t(n);const o=e?.priority??this.options?.defaultPriority??"high";null===this._nextPriority||"high"===this._nextPriority?this._nextPriority=o:this._nextPriority=this.options?.defaultPriority??"high",this.options?.onUpdate?.({priority:this._nextPriority}),this._flush()},this._flush=()=>{if(this._batching)return;const t=++this._flushing;this.listeners.forEach((e=>{this._flushing===t&&e({priority:this._nextPriority??"high"})}))},this.batch=t=>{if(this._batching)return t();this._batching=!0,t(),this._batching=!1,this._flush()},this.state=t,this.options=e}};function E(t,e){if(Object.is(t,e))return!0;if("object"!=typeof t||null===t||"object"!=typeof e||null===e)return!1;const n=Object.keys(t);if(n.length!==Object.keys(e).length)return!1;for(let o=0;o<n.length;o++)if(!Object.prototype.hasOwnProperty.call(e,n[o])||!Object.is(t[n[o]],e[n[o]]))return!1;return!0}function L(t){const e=t.errorComponent??x;return r.createElement(P,{resetKey:t.resetKey,onCatch:t.onCatch,children:({error:n})=>n?r.createElement(e,{error:n}):t.children})}class P 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 x({error:t}){const[e,n]=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:()=>n((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 C="undefined"==typeof document;function M(t){return t[t.length-1]}function T(t,e){return"function"==typeof t?t(e):t}function k(t,e){return e.reduce(((e,n)=>(e[n]=t[n],e)),{})}function O(t,e){if(t===e)return t;const n=e,o=Array.isArray(t)&&Array.isArray(n);if(o||D(t)&&D(n)){const e=o?t.length:Object.keys(t).length,r=o?n:Object.keys(n),s=r.length,a=o?[]:{};let i=0;for(let e=0;e<s;e++){const s=o?e:r[e];a[s]=O(t[s],n[s]),a[s]===t[s]&&i++}return e===s&&i===e?t:a}return n}function D(t){if(!I(t))return!1;const e=t.constructor;if(void 0===e)return!0;const n=e.prototype;return!!I(n)&&!!n.hasOwnProperty("isPrototypeOf")}function I(t){return"[object Object]"===Object.prototype.toString.call(t)}function j(t,e,n=!1){if(t===e)return!0;if(typeof t!=typeof e)return!1;if(D(t)&&D(e)){const o=Object.keys(t),r=Object.keys(e);return!(!n&&o.length!==r.length)&&!r.some((o=>!(o in t)||!j(t[o],e[o],n)))}return!(!Array.isArray(t)||!Array.isArray(e))&&!t.some(((t,o)=>!j(t,e[o],n)))}const $="undefined"!=typeof window?r.useLayoutEffect:r.useEffect;function A(t){return t.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/"/g,'\\"')}function B(t){return N(t.filter(Boolean).join("/"))}function N(t){return t.replace(/\/{2,}/g,"/")}function H(t){return"/"===t?t:t.replace(/^\/{1,}/,"")}function F(t){return"/"===t?t:t.replace(/\/{1,}$/,"")}function K(t){return F(H(t))}function W(t,e,n){e=e.replace(new RegExp(`^${t}`),"/"),n=n.replace(new RegExp(`^${t}`),"/");let o=U(e);const r=U(n);r.forEach(((t,e)=>{if("/"===t.value)e?e===r.length-1&&o.push(t):o=[t];else if(".."===t.value)o.length>1&&"/"===M(o)?.value&&o.pop(),o.pop();else{if("."===t.value)return;o.push(t)}}));return N(B([t,...o.map((t=>t.value))]))}function U(t){if(!t)return[];const e=[];if("/"===(t=N(t)).slice(0,1)&&(t=t.substring(1),e.push({type:"pathname",value:"/"})),!t)return e;const n=t.split("/").filter(Boolean);return e.push(...n.map((t=>"$"===t||"*"===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 z(t,e,n=!1){return B(U(t).map((t=>{if("wildcard"===t.type){const o=e[t.value];return n?`${t.value}${o??""}`:o}return"param"===t.type?e[t.value.substring(1)]??"":t.value})))}function Y(t,e,n){const o=J(t,e,n);if(!n.to||o)return o??{}}function J(t,e,n){e="/"!=t?e.substring(t.length):e;const o=`${n.to??"$"}`,r=U(e),s=U(o);e.startsWith("/")||r.unshift({type:"pathname",value:"/"}),o.startsWith("/")||s.unshift({type:"pathname",value:"/"});const a={};return(()=>{for(let t=0;t<Math.max(r.length,s.length);t++){const e=r[t],o=s[t],i=t>=r.length-1,c=t>=s.length-1;if(o){if("wildcard"===o.type)return!!e?.value&&(a["*"]=B(r.slice(t).map((t=>t.value))),!0);if("pathname"===o.type){if("/"===o.value&&!e?.value)return!0;if(e)if(n.caseSensitive){if(o.value!==e.value)return!1}else if(o.value.toLowerCase()!==e.value.toLowerCase())return!1}if(!e)return!1;if("param"===o.type){if("/"===e?.value)return!1;"$"!==e.value.charAt(0)&&(a[o.value.substring(1)]=e.value)}}if(!i&&c)return!!n.fuzzy}return!0})()?a:void 0}function X(t){return dt({select:e=>{const n=M(e.matches)?.params;return t?.select?t.select(n):n}})}function q(t){return st({...t,select:e=>t?.select?t.select(e.search):e.search})}const V="__root__";class G{constructor(t){this.options=t||{},this.isRoot=!t?.getParentRoute,G.__onInit(this),this.$$typeof=Symbol.for("react.memo")}init=t=>{this.originalIndex=t.originalIndex;const e=this.options,n=!e?.path&&!e?.id;this.parentRoute=this.options?.getParentRoute?.(),n?this.path=V:g(this.parentRoute);let o=n?V:e.path;o&&"/"!==o&&(o=K(o));const r=e?.id||o;let s=n?V:B([this.parentRoute.id===V?"":this.parentRoute.id,r]);o===V&&(o="/"),s!==V&&(s=B(["/",s]));const a=s===V?"/":B([this.parentRoute.fullPath,o]);this.path=o,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=>st({...t,from:this.id});useRouteContext=t=>st({...t,from:this.id,select:e=>t?.select?t.select(e.context):e.context});useSearch=t=>q({...t,from:this.id});useParams=t=>X({...t,from:this.id});useLoaderData=t=>it({...t,from:this.id})}class Q extends G{constructor(t){super(t)}}function Z(){const t=ft(),e=dt(),n=e.pendingMatches?.some((t=>t.showPending))?e.pendingMatches:e.matches,o=t.latestLocation.state.key,s=t.routesById[V],a=r.useCallback((t=>r.createElement(x,{...t,useMatch:s.useMatch,useRouteContext:s.useRouteContext,useSearch:s.useSearch,useParams:s.useParams})),[s]);return r.createElement(at.Provider,{value:n},r.createElement(L,{resetKey:o,errorComponent:a,onCatch:()=>{}},n.length?r.createElement(et,{matches:n}):null))}function tt(t){return r.createElement(r.Fragment,null,t.children)}function et({matches:t}){const{options:e,routesById:n}=ft(),o=t[0],s=o?.routeId,a=n[s],i=ft(),c=i.latestLocation.state?.key,l=a.options.pendingComponent??e.defaultPendingComponent,u=l?r.createElement(l,{useMatch:a.useMatch,useRouteContext:a.useRouteContext,useSearch:a.useSearch,useParams:a.useParams}):void 0,h=a.options.errorComponent??e.defaultErrorComponent??x,d=a.options.wrapInSuspense??u?r.Suspense:tt,f=h?r.useCallback((t=>r.createElement(h,{...t,useMatch:a.useMatch,useRouteContext:a.useRouteContext,useSearch:a.useSearch,useParams:a.useParams})),[a]):void 0,p=f?L:tt;return r.createElement(at.Provider,{value:t},r.createElement(d,{fallback:u},r.createElement(p,{resetKey:c,errorComponent:f,onCatch:()=>{o.id}},r.createElement(nt,{match:o,pendingElement:u}))))}function nt({match:t,pendingElement:e}){const{options:n,routesById:o}=ft(),s=o[t.routeId];if("error"===t.status)throw t.error;if("pending"===t.status){if(t.showPending)return e||null;throw t.loadPromise}if("success"===t.status){let t=s.options.component??n.defaultComponent;return t?r.createElement(t,{useMatch:s.useMatch,useRouteContext:s.useRouteContext,useSearch:s.useSearch,useParams:s.useParams,useLoaderData:s.useLoaderData}):r.createElement(ot,null)}g(!1)}function ot(){const t=r.useContext(at).slice(1);return t[0]?r.createElement(et,{matches:t}):null}function rt(){const{matchRoute:t}=ft();return r.useCallback((e=>{const{pending:n,caseSensitive:o,...r}=e;return t(r,{pending:n,caseSensitive:o})}),[])}function st(t){const e=r.useContext(at)[0],n=e?.routeId,o=dt({select:n=>{const o=n.pendingMatches?.some((t=>t.showPending))?n.pendingMatches:n.matches;return(t?.from?o.find((e=>e.routeId===t?.from)):o.find((t=>t.id===e.id))).routeId}});(t?.strict??1)&&g(n==o);return dt({select:n=>{const o=n.pendingMatches?.some((t=>t.showPending))?n.pendingMatches:n.matches,r=t?.from?o.find((e=>e.routeId===t?.from)):o.find((t=>t.id===e.id));return g(r,t?.from&&t.from),t?.select?t.select(r):r}})}const at=r.createContext(null);function it(t){const e=st({...t,select:void 0});return"function"==typeof t.select?t.select(e?.loaderData):e?.loaderData}const ct=r.createContext(null);function lt({router:t}){return r.createElement(r.Fragment,null,r.createElement(Z,null),r.createElement(ut,null))}function ut(){const t=ft(),e=dt({select:t=>k(t,["isLoading","location","resolvedLocation","isTransitioning"])}),[n,o]=r.useTransition();t.startReactTransition=o,r.useEffect((()=>{n&&t.__store.setState((t=>({...t,isTransitioning:n})))}),[n]);const s=()=>{var n;n=()=>{try{t.load()}catch(t){console.error(t)}},e.isTransitioning?n():o((()=>n()))};return $((()=>{const n=t.history.subscribe((()=>{t.latestLocation=t.parseLocation(t.latestLocation),e.location!==t.latestLocation&&s()})),o=t.buildLocation({search:!0,params:!0,hash:!0,state:!0});return e.location.href!==o.href&&t.commitLocation({...o,replace:!0}),()=>{n()}}),[t.history]),$((()=>{n||e.isLoading||e.resolvedLocation===e.location||(console.log("onResolved",e.location),t.emit({type:"onResolved",fromLocation:e.resolvedLocation,toLocation:e.location,pathChanged:e.location.href!==e.resolvedLocation?.href}),t.pendingMatches=[],t.__store.setState((t=>({...t,isTransitioning:!1,resolvedLocation:t.location}))))}),[n,e.isLoading]),$((()=>{window.__TSR_DEHYDRATED__||s()}),[]),null}function ht(t,e){return[...t.pendingMatches??[],...t.matches].find((t=>t.id===e))}function dt(t){return function(t,e=(t=>t)){return _.useSyncExternalStoreWithSelector(t.subscribe,(()=>t.state),(()=>t.state),e,E)}(ft().__store,t?.select)}function ft(){const t="undefined"!=typeof document&&window.__TSR_ROUTER_CONTEXT__||ct;return r.useContext(t)}function pt(t){return"object"==typeof t&&null!==t&&!(t instanceof Promise)&&!t.then&&"__deferredState"in t}function mt({promise:t}){const e=ft();let n=t.__deferredState;const o=`__TSR__DEFERRED__${n.uid}`;if(pt(t)&&(n=e.hydrateData(o),(t=Promise.resolve(n.data)).__deferredState=n),"pending"===n.status)throw new Promise((t=>setTimeout(t,1))).then((()=>t));if("error"===n.status)throw n.error;return e.dehydrateData(o,n),[n.data]}"undefined"!=typeof document&&(window.__TSR_ROUTER_CONTEXT__=ct);function yt(){return yt=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t},yt.apply(this,arguments)}function gt(t){const{buildLink:e}=ft(),n=st({strict:!1}),{type:o,children:r,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:b,style:S,className:_,onClick:R,onFocus:E,onMouseEnter:L,onMouseLeave:P,onTouchStart:x,...C}=t,M=e({from:t.to?n.pathname:void 0,...t});if("external"===M.type){const{href:t}=M;return{href:t}}const{handleClick:k,handleFocus:O,handleEnter:D,handleLeave:I,handleTouchStart:j,isActive:$,next:A}=M,B=t=>e=>{e.persist&&e.persist(),t.filter(Boolean).forEach((t=>{e.defaultPrevented||t(e)}))},N=$?T(a,{})??{}:{},H=$?{}:T(i,{})??{};return{...N,...H,...C,href:l?void 0:A.maskedLocation?A.maskedLocation.href:A.href,onClick:B([R,k]),onFocus:B([E,O]),onMouseEnter:B([L,D]),onMouseLeave:B([P,I]),onTouchStart:B([x,j]),target:s,style:{...S,...N.style,...H.style},className:[_,N.className,H.className].filter(Boolean).join(" ")||void 0,...l?{role:"link","aria-disabled":!0}:void 0,"data-status":$?"active":void 0}}const vt=r.forwardRef(((t,e)=>{const n=gt(t);return r.createElement("a",yt({ref:e},n,{children:"function"==typeof t.children?t.children({isActive:"active"===n["data-status"]}):t.children}))}));function wt(t,e){var n,o,r,s="";for(n in t)if(void 0!==(r=t[n]))if(Array.isArray(r))for(o=0;o<r.length;o++)s&&(s+="&"),s+=encodeURIComponent(n)+"="+encodeURIComponent(r[o]);else s&&(s+="&"),s+=encodeURIComponent(n)+"="+encodeURIComponent(r);return(e||"")+s}function bt(t){if(!t)return"";var e=decodeURIComponent(t);return"false"!==e&&("true"===e||(0*+e==0&&+e+""===e?+e:e))}function St(t){for(var e,n,o={},r=t.split("&");e=r.shift();)void 0!==o[n=(e=e.split("=")).shift()]?o[n]=[].concat(o[n],bt(e.shift())):o[n]=bt(e.shift());return o}function _t(t){return!!t?.isRedirect}const Rt=Lt(JSON.parse),Et=Pt(JSON.stringify,JSON.parse);function Lt(t){return e=>{"?"===e.substring(0,1)&&(e=e.substring(1));let n=St(e);for(let e in n){const o=n[e];if("string"==typeof o)try{n[e]=t(o)}catch(t){}}return n}}function Pt(t,e){return n=>{(n={...n})&&Object.keys(n).forEach((o=>{const r=n[o];void 0===r||void 0===r?delete n[o]:n[o]=function(n){if("object"==typeof n&&null!==n)try{return t(n)}catch(t){}else if("string"==typeof n&&"function"==typeof e)try{return e(n),t(n)}catch(t){}return n}(r)}));const o=wt(n).toString();return o?`?${o}`:""}}const xt=["component","errorComponent","pendingComponent"],Ct="Error preloading route! ☝️";class Mt extends Error{}class Tt extends Error{}function kt(t){return{isLoading:!1,isTransitioning:!1,status:"idle",resolvedLocation:t,location:t,matches:[],pendingMatches:[],lastUpdated:Date.now()}}const Ot="undefined"!=typeof window?r.useLayoutEffect:r.useEffect,Dt="window",It="___";let jt=new WeakSet;let $t="undefined"!=typeof window&&window.sessionStorage?(()=>{const t="tsr-scroll-restoration-v2";return{state:JSON.parse(window.sessionStorage.getItem(t)||"null")||{cached:{},next:{}},set:e=>{$t.state=T(e,$t.state),window.sessionStorage.setItem(t,JSON.stringify($t.state))}}})():void 0;const At=t=>t.state.key;function Bt(t){const e=ft();Ot((()=>{const n=t?.getKey||At,{history:o}=window;o.scrollRestoration&&(o.scrollRestoration="manual");const r=t=>{if(jt.has(t.target))return;jt.add(t.target);let e="";if(t.target===document||t.target===window)e=Dt;else{const n=t.target.getAttribute("data-scroll-restoration-id");e=n?`[data-scroll-restoration-id="${n}"]`:Nt(t.target)}$t.state.next[e]||$t.set((t=>({...t,next:{...t.next,[e]:{scrollX:NaN,scrollY:NaN}}})))};"undefined"!=typeof document&&document.addEventListener("scroll",r,!0);const s=e.subscribe("onBeforeLoad",(t=>{if(t.pathChanged){const e=n(t.fromLocation);for(const t in $t.state.next){const n=$t.state.next[t];if(t===Dt)n.scrollX=window.scrollX||0,n.scrollY=window.scrollY||0;else if(t){const e=document.querySelector(t);n.scrollX=e?.scrollLeft||0,n.scrollY=e?.scrollTop||0}$t.set((o=>{const r={...o.next};return delete r[t],{...o,next:r,cached:{...o.cached,[[e,t].join(It)]:n}}}))}}})),a=e.subscribe("onResolved",(n=>{if(n.pathChanged){if(!e.resetNextScroll)return;e.resetNextScroll=!0;const o=(t?.getKey||At)(n.toLocation);let r=!1;for(const t in $t.state.cached){const e=$t.state.cached[t],[n,s]=t.split(It);if(n===o)if(s===Dt)r=!0,window.scrollTo(e.scrollX,e.scrollY);else if(s){const t=document.querySelector(s);t&&(t.scrollLeft=e.scrollX,t.scrollTop=e.scrollY)}}r||window.scrollTo(0,0),$t.set((t=>({...t,next:{}}))),jt=new WeakSet}}));return()=>{document.removeEventListener("scroll",r),s(),a()}}),[])}function Nt(t){let e,n=[];for(;e=t.parentNode;)n.unshift(`${t.tagName}:nth-child(${[].indexOf.call(e.children,t)+1})`),t=e;return`${n.join(" > ")}`.toLowerCase()}function Ht(t,e=!0){const{history:n}=ft();r.useEffect((()=>{if(!e)return;let o=n.block(((e,n)=>{window.confirm(t)&&(o(),e())}));return o}))}t.Await=function(t){const e=mt(t);return t.children(...e)},t.Block=function({message:t,condition:e,children:n}){return Ht(t,e),n??null},t.CatchBoundary=L,t.CatchBoundaryImpl=P,t.ErrorComponent=x,t.FileRoute=class{constructor(t){this.path=t}createRoute=t=>{const e=new G(t);return e.isRoot=!1,e}},t.Link=vt,t.Match=et,t.MatchRoute=function(t){const e=rt()(t);return"function"==typeof t.children?t.children(e):e?t.children:null},t.Matches=Z,t.Navigate=function(t){const{navigate:e}=ft(),n=st({strict:!1});return $((()=>{e({from:t.to?n.pathname:void 0,...t})}),[]),null},t.Outlet=ot,t.PathParamError=Tt,t.RootRoute=Q,t.Route=G,t.Router=class{tempLocationKey=`${Math.round(1e7*Math.random())}`;resetNextScroll=!0;navigateTimeout=null;latestLoadPromise=Promise.resolve();subscribers=new Set;pendingMatches=[];injectedHtml=[];constructor(t){this.update({defaultPreloadDelay:50,defaultPendingMs:1e3,defaultPendingMinMs:500,context:void 0,...t,stringifySearch:t?.stringifySearch??Et,parseSearch:t?.parseSearch??Rt})}startReactTransition=t=>t();update=t=>{this.options={...this.options,...t},this.basepath=`/${K(t.basepath??"")??""}`,(!this.history||this.options.history&&this.options.history!==this.history)&&(this.history=this.options.history??("undefined"!=typeof document?d():f()),this.latestLocation=this.parseLocation()),this.options.routeTree!==this.routeTree&&(this.routeTree=this.options.routeTree,this.buildRouteTree()),this.__store||(this.__store=new R(kt(this.latestLocation),{onUpdate:()=>{this.__store.state={...this.state,status:this.state.isTransitioning||this.state.isLoading?"pending":"idle"}}}))};get state(){return this.__store.state}buildRouteTree=()=>{this.routesById={},this.routesByPath={};const t=e=>{e.forEach(((e,n)=>{e.init({originalIndex:n});if(g(!this.routesById[e.id],String(e.id)),this.routesById[e.id]=e,!e.isRoot&&e.path){const t=F(e.fullPath);this.routesByPath[t]&&!e.fullPath.endsWith("/")||(this.routesByPath[t]=e)}const o=e.children;o?.length&&t(o)}))};t([this.routeTree]),this.flatRoutes=Object.values(this.routesByPath).map(((t,e)=>{const n=K(t.fullPath),o=U(n);for(;o.length>1&&"/"===o[0]?.value;)o.shift();const r=o.map((t=>"param"===t.type?.5:"wildcard"===t.type?.25:1));return{child:t,trimmed:n,parsed:o,index:e,score:r}})).sort(((t,e)=>{let n="/"===t.trimmed?1:"/"===e.trimmed?-1:0;if(0!==n)return n;const o=Math.min(t.score.length,e.score.length);if(t.score.length!==e.score.length)return e.score.length-t.score.length;for(let n=0;n<o;n++)if(t.score[n]!==e.score[n])return e.score[n]-t.score[n];for(let n=0;n<o;n++)if(t.parsed[n].value!==e.parsed[n].value)return t.parsed[n].value>e.parsed[n].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 n={eventType:t,fn:e};return this.subscribers.add(n),()=>{this.subscribers.delete(n)}};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:n,hash:o,state:r})=>{const s=this.options.parseSearch(n);return{pathname:e,searchStr:n,search:O(t?.search,s),hash:o.split("#").reverse()[0]??"",href:`${e}${n}${o}`,state:O(t?.state,r)}},n=e(this.history.location);let{__tempLocation:o,__tempKey:r}=n.state;if(o&&(!r||r===this.tempLocationKey)){const t=e(o);return t.state.key=n.state.key,delete t.state.__tempLocation,{...t,maskedLocation:n}}return n};resolvePathWithBase=(t,e)=>W(this.basepath,t,N(e));get looseRoutesById(){return this.routesById}matchRoutes=(t,e,n)=>{let o={},r=this.flatRoutes.find((e=>{const n=Y(this.basepath,F(t),{to:e.fullPath,caseSensitive:e.options.caseSensitive??this.options.caseSensitive,fuzzy:!1});return!!n&&(o=n,!0)}))||this.routesById.__root__,s=[r];for(;r?.parentRoute;)r=r.parentRoute,r&&s.unshift(r);const a=s.map((t=>{let e;if(t.options.parseParams)try{const e=t.options.parseParams(o);Object.assign(o,e)}catch(t){if(e=new Tt(t.message,{cause:t}),n?.throwOnError)throw e;return e}})),i=[];return s.forEach(((t,r)=>{const s=i[r-1],[c,l]=(()=>{const o=s?.search??e;try{const e="object"==typeof t.options.validateSearch?t.options.validateSearch.parse:t.options.validateSearch;let n=e?.(o)??{};return[{...o,...n},void 0]}catch(t){const e=new Mt(t.message,{cause:t});if(n?.throwOnError)throw e;return[o,e]}})(),u=z(t.path,o),h=z(t.id,o,!0)+(t.options.key?.({search:c,location:this.state.location})??""),d=ht(this.state,h),f=this.state.matches.find((t=>t.id===h))?"stay":"enter",p=!(!t.options.loader&&!xt.some((e=>t.options[e]?.preload))),m=d?{...d,cause:f}:{id:h,routeId:t.id,params:o,pathname:B([this.basepath,u]),updatedAt:Date.now(),search:{},searchError:void 0,status:p?"pending":"success",showPending:!1,isFetching:!1,invalid:!1,error:void 0,paramsError:a[r],loadPromise:Promise.resolve(),context:void 0,abortController:new AbortController,shouldReloadDeps:void 0,fetchedAt:0,cause:f};m.search=O(m.search,c),m.searchError=l,i.push(m)})),i};cancelMatch=t=>{ht(this.state,t)?.abortController?.abort()};cancelMatches=()=>{this.state.pendingMatches?.forEach((t=>{this.cancelMatch(t.id)}))};buildLocation=t=>{const e=(t={},e)=>{const n=this.latestLocation,o=t.from??n.pathname;let r=this.resolvePathWithBase(o,`${t.to??""}`);const s=this.matchRoutes(o,n.search),a=e?.filter((t=>s?.find((e=>e.routeId===t.routeId)))),i={...M(s)?.params};let c=!0===(t.params??!0)?i:T(t.params,i);c&&e?.map((t=>this.looseRoutesById[t.routeId].options.stringifyParams)).filter(Boolean).forEach((t=>{c={...c,...t(c)}})),r=z(r,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)),n.search):n.search,d=!0===t.search?h:t.search?T(t.search,h)??{}:l?.length?h:{},f=u?.length?u.reduce(((t,e)=>e(t)),d):d,p=O(n.search,f),m=this.options.stringifySearch(p),y=!0===t.hash?n.hash:t.hash?T(t.hash,n.hash):n.hash,g=y?`#${y}`:"";let v=!0===t.state?n.state:t.state?T(t.state,n.state):n.state;return v=O(n.state,v),{pathname:r,search:p,searchStr:m,state:v,hash:y,href:this.history.createHref(`${r}${m}${g}`),unmaskOnReload:t.unmaskOnReload}},n=(t={},n)=>{let o=e(t),r=n?e(n):void 0;if(!r){let t={},s=this.options.routeMasks?.find((e=>{const n=Y(this.basepath,o.pathname,{to:e.from,caseSensitive:!1,fuzzy:!1});return!!n&&(t=n,!0)}));s&&(s={...s,from:z(s.from,t)},r=e(n=s))}const s=this.matchRoutes(o.pathname,o.search),a=r?this.matchRoutes(r.pathname,r.search):void 0,i=r?e(n,a):void 0,c=e(t,s);return i&&(c.maskedLocation=i),c};return t.mask?n(t,{...k(t,["from"]),...t.mask}):n(t)};commitLocation=async({startTransition:t,...e})=>{this.navigateTimeout&&clearTimeout(this.navigateTimeout);if(!(this.latestLocation.href===e.href)||!e.replace){let{maskedLocation:n,...o}=e;n&&(o={...n,state:{...n.state,__tempKey:void 0,__tempLocation:{...o,search:o.searchStr,state:{...o.state,__tempKey:void 0,__tempLocation:void 0,key:void 0}}}},(o.unmaskOnReload??this.options.unmaskOnReload)&&(o.state.__tempKey=this.tempLocationKey));const r=()=>{this.history[e.replace?"replace":"push"](o.href,o.state)};t??1?this.startReactTransition(r):r()}return this.resetNextScroll=e.resetScroll??!0,this.latestLoadPromise};buildAndCommitLocation=({replace:t,resetScroll:e,startTransition:n,...o}={})=>{const r=this.buildLocation(o);return this.commitLocation({...r,startTransition:n,replace:t,resetScroll:e})};navigate=({from:t,to:e="",...n})=>{const o=String(e),r=void 0===t?t:String(t);let s;try{new URL(`${o}`),s=!0}catch(t){}return g(!s),this.buildAndCommitLocation({...n,from:r,to:o})};loadMatches=async({checkLatest:t,matches:e,preload:n,invalidate:o})=>{let r,s;const a=t=>{this.__store.setState((e=>({...e,pendingMatches:e.pendingMatches?.map((e=>e.id===t.id?t:e))})))};try{for(let[t,o]of e.entries()){const r=e[t-1],a=this.looseRoutesById[o.routeId],i=(n,r)=>{if(n.routerCode=r,s=s??t,_t(n))throw n;try{a.options.onError?.(n)}catch(t){if(n=t,_t(t))throw t}e[t]=o={...o,error:n,status:"error",updatedAt:Date.now()}};try{o.paramsError&&i(o.paramsError,"PARSE_PARAMS"),o.searchError&&i(o.searchError,"VALIDATE_SEARCH");const s=r?.context??this.options.context??{},c=await(a.options.beforeLoad?.({search:o.search,abortController:o.abortController,params:o.params,preload:!!n,context:s,location:this.state.location,navigate:t=>this.navigate({...t,from:o.pathname}),buildLocation:this.buildLocation,cause:o.cause}))??{},l={...s,...c};e[t]=o={...o,context:O(o.context,l)}}catch(t){i(t,"BEFORE_LOAD");break}}}catch(t){if(_t(t))return n||this.navigate(t),e;throw t}const i=e.slice(0,s),c=[];return i.forEach(((s,i)=>{c.push((async()=>{const l=c[i-1],u=this.looseRoutesById[s.routeId],h=t=>!!_t(t)&&(n||this.navigate(t),!0);let d;e[i]=s={...s,fetchedAt:Date.now(),invalid:!1,showPending:!1};const f=u.options.pendingMs??this.options.defaultPendingMs;let p;if(!n&&f&&(u.options.pendingComponent??this.options.defaultPendingComponent)&&(p=new Promise((t=>setTimeout(t,f)))),s.isFetching)d=ht(this.state,s.id)?.loadPromise;else{const t={params:s.params,search:s.search,preload:!!n,parentMatchPromise:l,abortController:s.abortController,context:s.context,location:this.state.location,navigate:t=>this.navigate({...t,from:s.pathname}),cause:s.cause};let r=!0,a="function"==typeof u.options.shouldReload?u.options.shouldReload?.(t):!!(u.options.shouldReload??1);if("enter"===s.cause||o?s.shouldReloadDeps=a:"stay"===s.cause&&("object"==typeof a?(r=!j(a,s.shouldReloadDeps),s.shouldReloadDeps=a):r=!!a),r){e[i]=s={...s,isFetching:!0};const n=Promise.all(xt.map((async t=>{const e=u.options[t];e?.preload&&await e.preload()}))),o=u.options.loader?.(t);d=Promise.all([n,o]).then((t=>t[1]))}else d=Promise.resolve(s.loaderData)}e[i]=s={...s,loadPromise:d},n||a(s);let m=!1;const y=u.options.pendingMinMs??this.options.defaultPendingMinMs;await new Promise((async o=>{p&&p.then((()=>{(r=t())||(m=!0,e[i]=s={...s,showPending:!0},a(s),o())}));try{const n=await d;if(r=t())return await r;if(m&&y&&await new Promise((t=>setTimeout(t,y))),r=t())return await r;e[i]=s={...s,error:void 0,status:"success",isFetching:!1,updatedAt:Date.now(),loaderData:n,loadPromise:void 0}}catch(n){if(r=t())return await r;if(h(n))return;try{u.options.onError?.(n)}catch(t){if(n=t,h(t))return}e[i]=s={...s,error:n,status:"error",isFetching:!1,updatedAt:Date.now()}}finally{m&&y&&s.showPending&&this.__store.setState((t=>({...t,matches:t.matches?.map((t=>t.id===s.id?s:t))})))}n||a(s),o()}))})())})),await Promise.all(c),e};invalidate=()=>this.load({invalidate:!0});load=async t=>{const e=new Promise((async(n,o)=>{const r=this.latestLocation,s=this.state.resolvedLocation,a=s.href!==r.href;let i;this.cancelMatches(),this.emit({type:"onBeforeLoad",fromLocation:s,toLocation:r,pathChanged:a});let c=this.matchRoutes(r.pathname,r.search,{debug:!0});const l=this.state.matches;this.__store.setState((t=>({...t,isLoading:!0,location:r,pendingMatches:c})));try{try{await this.loadMatches({matches:c,checkLatest:()=>this.checkLatest(e),invalidate:t?.invalidate})}catch(t){}if(i=this.checkLatest(e))return i;const o=l.filter((t=>!this.pendingMatches.includes(t))),u=this.pendingMatches.filter((t=>!l.includes(t))),h=l.filter((t=>this.pendingMatches.includes(t)));this.__store.setState((t=>({...t,isLoading:!1,matches:c,pendingMatches:void 0}))),[[o,"onLeave"],[u,"onEnter"],[h,"onTransition"]].forEach((([t,e])=>{t.forEach((t=>{this.looseRoutesById[t.routeId].options[e]?.(t)}))})),this.emit({type:"onLoad",fromLocation:s,toLocation:r,pathChanged:a}),n()}catch(t){if(i=this.checkLatest(e))return i;o(t)}}));return this.latestLoadPromise=e,this.latestLoadPromise};preloadRoute=async(t=this.state.location)=>{let e=this.buildLocation(t),n=this.matchRoutes(e.pathname,e.search,{throwOnError:!0});return await this.loadMatches({matches:n,preload:!0,checkLatest:()=>{}}),[M(n),n]};buildLink=t=>{const{to:e,preload:n,preloadDelay:o,activeOptions:r,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=n??this.options.defaultPreload,f=o??this.options.defaultPreloadDelay??0,p=this.latestLocation.pathname.split("/"),m=h.pathname.split("/").every(((t,e)=>t===p[e])),y=r?.exact?this.latestLocation.pathname===h.pathname:m,g=!r?.includeHash||this.latestLocation.hash===h.hash,v=!(r?.includeSearch??1)||j(this.latestLocation.search,h.search,!0);return{type:"internal",next:h,handleFocus:t=>{d&&this.preloadRoute(u).catch((t=>{console.warn(t),console.warn(Ct)}))},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(Ct)}))}),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(Ct)}))},isActive:y&&g&&v,disabled:s}};matchRoute=(t,e)=>{t={...t,to:t.to?this.resolvePathWithBase(t.from||"",t.to):void 0};const n=this.buildLocation(t);if(e?.pending&&"pending"!==this.state.status)return!1;const o=e?.pending?this.latestLocation:this.state.resolvedLocation;if(!o)return!1;const r=Y(this.basepath,o.pathname,{...e,to:n.pathname});return!!r&&(r&&(e?.includeSearch??1)?!!j(o.search,n.search,!0)&&r:r)};injectHtml=async t=>{this.injectedHtml.push(t)};dehydrateData=(t,e)=>{if("undefined"==typeof document){const n="string"==typeof t?t:JSON.stringify(t);return this.injectHtml((async()=>{const t=`__TSR_DEHYDRATED__${n}`,o="function"==typeof e?await e():e;return`<script id='${t}' suppressHydrationWarning>window["__TSR_DEHYDRATED__${A(n)}"] = ${JSON.stringify(o)}\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}`]}};dehydrate=()=>({state:{dehydratedMatches:this.state.matches.map((t=>k(t,["fetchedAt","invalid","id","status","updatedAt","loaderData"])))}});hydrate=async t=>{let e=t;"undefined"!=typeof document&&(e=window.__TSR_DEHYDRATED__),g(e);const n=e;this.dehydratedData=n.payload,this.options.hydrate?.(n.payload);const o=n.router.state;let r=this.matchRoutes(this.state.location.pathname,this.state.location.search).map((t=>{const e=o.dehydratedMatches.find((e=>e.id===t.id));return g(e,t.id),e?{...t,...e}:t}));this.__store.setState((t=>({...t,matches:r})))}},t.RouterProvider=function({router:t,...e}){t.update({...t.options,...e,context:{...t.options.context,...e?.context}});const n=r.createElement(ct.Provider,{value:t},r.createElement(lt,{router:t}));return t.options.Wrap?r.createElement(t.options.Wrap,null,n):n},t.ScrollRestoration=function(t){return Bt(t),null},t.SearchParamError=Mt,t.cleanPath=N,t.componentTypes=xt,t.createBrowserHistory=d,t.createHashHistory=function(){return d({getHref:()=>window.location.hash.substring(1),createHref:t=>`#${t}`})},t.createMemoryHistory=f,t.createRouteMask=function(t){return t},t.decode=St,t.deepEqual=j,t.defaultParseSearch=Rt,t.defaultStringifySearch=Et,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=wt,t.escapeJSON=A,t.functionalUpdate=T,t.getInitialRouterState=kt,t.getRouteMatch=ht,t.interpolatePath=z,t.invariant=g,t.isDehydratedDeferred=pt,t.isPlainObject=D,t.isRedirect=_t,t.isServer=C,t.joinPaths=B,t.last=M,t.lazyFn=function(t,e){return async(...n)=>(await t())[e||"default"](...n)},t.lazyRouteComponent=function(t,e){let n;const o=()=>(n||(n=t()),n),s=r.lazy((async()=>({default:(await o())[e??"default"]})));return s.preload=o,s},t.matchByPath=J,t.matchPathname=Y,t.matchesContext=at,t.parsePathname=U,t.parseSearchWith=Lt,t.pick=k,t.redirect=function(t){return t.isRedirect=!0,t},t.replaceEqualDeep=O,t.resolvePath=W,t.rootRouteId=V,t.rootRouteWithContext=function(){return t=>new Q(t)},t.routerContext=ct,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 n=Object.keys(t);if(n.length!==Object.keys(e).length)return!1;for(let o=0;o<n.length;o++)if(!Object.prototype.hasOwnProperty.call(e,n[o])||!Object.is(t[n[o]],e[n[o]]))return!1;return!0},t.stringifySearchWith=Pt,t.trimPath=K,t.trimPathLeft=H,t.trimPathRight=F,t.typedNavigate=function(t){return t},t.useAwaited=mt,t.useBlocker=Ht,t.useElementScrollRestoration=function(t){const e=ft(),n=t?.getKey||At;let o="";if(t.id)o=`[data-scroll-restoration-id="${t.id}"]`;else{const e=t.getElement?.();if(!e)return;o=Nt(e)}const r=[n(e.latestLocation),o].join(It);return $t.state.cached[r]},t.useLayoutEffect=$,t.useLinkProps=gt,t.useLoaderData=it,t.useMatch=st,t.useMatchRoute=rt,t.useMatches=function(t){const e=r.useContext(at);return dt({select:n=>{let o=n.pendingMatches?.some((t=>t.showPending))?n.pendingMatches:n.matches;return o=o.slice(o.findIndex((t=>t.id===e[0]?.id))),t?.select?t.select(o):o}})},t.useNavigate=function(t){const{navigate:e}=ft(),n=st({strict:!1});return r.useCallback((o=>e({from:o?.to?n.pathname:void 0,...t,...o})),[])},t.useParams=X,t.useRouteContext=function(t){return st({...t,select:e=>t?.select?t.select(e.context):e.context})},t.useRouter=ft,t.useRouterState=dt,t.useScrollRestoration=Bt,t.useSearch=q,t.useStableCallback=function(t){const e=r.useRef(t);return e.current=t,r.useRef(((...t)=>e.current(...t))).current},t.warning=v}));
|
|
22
22
|
//# sourceMappingURL=index.production.js.map
|