1 line
12 KiB
JavaScript
1 line
12 KiB
JavaScript
import{a,b as Z}from"./vendor-react-BHG7lGYR.js";import{A as V,i as v,p as W,s as K,a as _,b as F,j as L,m as H,c as ee,d as te,e as M}from"./vendor-IYr-MHu4.js";function w(){return w=Object.assign?Object.assign.bind():function(e){for(let t=1;t<arguments.length;t++){const r=arguments[t];for(const n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},w.apply(this,arguments)}const j=a.createContext(null),re=a.createContext(null),x=a.createContext(null),N=a.createContext(null),E=a.createContext({outlet:null,matches:[],isDataRoute:!1}),$=a.createContext(null);function ne(e,t){const{relative:r}=t===void 0?{}:t;R()||v(!1);let{basename:n,navigator:o}=a.useContext(x),{hash:i,pathname:l,search:d}=X(e,{relative:r}),f=l;return n!=="/"&&(f=l==="/"?n:L([n,l])),o.createHref({pathname:f,search:d,hash:i})}function R(){return a.useContext(N)!=null}function b(){return R()||v(!1),a.useContext(N).location}function G(e){a.useContext(x).static||a.useLayoutEffect(e)}function k(){const{isDataRoute:e}=a.useContext(E);return e?me():ae()}function ae(){R()||v(!1);const e=a.useContext(j),{basename:t,future:r,navigator:n}=a.useContext(x),{matches:o}=a.useContext(E),{pathname:i}=b(),l=JSON.stringify(F(o,r.v7_relativeSplatPath)),d=a.useRef(!1);return G(()=>{d.current=!0}),a.useCallback(function(c,u){if(u===void 0&&(u={}),!d.current)return;if(typeof c=="number"){n.go(c);return}const s=_(c,JSON.parse(l),i,u.relative==="path");e==null&&t!=="/"&&(s.pathname=s.pathname==="/"?t:L([t,s.pathname])),(u.replace?n.replace:n.push)(s,u.state,u)},[t,n,l,i,e])}function _e(){const{matches:e}=a.useContext(E),t=e[e.length-1];return t?t.params:{}}function X(e,t){const{relative:r}=t===void 0?{}:t,{future:n}=a.useContext(x),{matches:o}=a.useContext(E),{pathname:i}=b(),l=JSON.stringify(F(o,n.v7_relativeSplatPath));return a.useMemo(()=>_(e,JSON.parse(l),i,r==="path"),[e,l,i,r])}function oe(e,t){return le(e,t)}function le(e,t,r,n){R()||v(!1);const{navigator:o}=a.useContext(x),{matches:i}=a.useContext(E),l=i[i.length-1],d=l?l.params:{};l&&l.pathname;const f=l?l.pathnameBase:"/";l&&l.route;let c=b(),u;if(t){let s;const h=typeof t=="string"?W(t):t;f==="/"||(s=h.pathname)!=null&&s.startsWith(f)||v(!1),u=h}else u=c;let p=u.pathname||"/",m=p;if(f!=="/"){const h=f.replace(/^\//,"").split("/");m=`/${p.replace(/^\//,"").split("/").slice(h.length).join("/")}`}const g=H(e,{pathname:m}),y=fe(g&&g.map(h=>Object.assign({},h,{params:Object.assign({},d,h.params),pathname:L([f,o.encodeLocation?o.encodeLocation(h.pathname).pathname:h.pathname]),pathnameBase:h.pathnameBase==="/"?f:L([f,o.encodeLocation?o.encodeLocation(h.pathnameBase).pathname:h.pathnameBase])})),i,r,n);return t&&y?a.createElement(N.Provider,{value:{location:w({pathname:"/",search:"",hash:"",state:null,key:"default"},u),navigationType:V.Pop}},y):y}function ie(){const e=ve(),t=ee(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),r=e instanceof Error?e.stack:null,o={padding:"0.5rem",backgroundColor:"rgba(200,200,200, 0.5)"};return a.createElement(a.Fragment,null,a.createElement("h2",null,"Unexpected Application Error!"),a.createElement("h3",{style:{fontStyle:"italic"}},t),r?a.createElement("pre",{style:o},r):null,null)}const se=a.createElement(ie,null);class ue extends a.Component{constructor(t){super(t),this.state={location:t.location,revalidation:t.revalidation,error:t.error}}static getDerivedStateFromError(t){return{error:t}}static getDerivedStateFromProps(t,r){return r.location!==t.location||r.revalidation!=="idle"&&t.revalidation==="idle"?{error:t.error,location:t.location,revalidation:t.revalidation}:{error:t.error!==void 0?t.error:r.error,location:r.location,revalidation:t.revalidation||r.revalidation}}componentDidCatch(t,r){console.error("React Router caught the following error during render",t,r)}render(){return this.state.error!==void 0?a.createElement(E.Provider,{value:this.props.routeContext},a.createElement($.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function ce(e){let{routeContext:t,match:r,children:n}=e,o=a.useContext(j);return o&&o.static&&o.staticContext&&(r.route.errorElement||r.route.ErrorBoundary)&&(o.staticContext._deepestRenderedBoundaryId=r.route.id),a.createElement(E.Provider,{value:t},n)}function fe(e,t,r,n){let o;if(t===void 0&&(t=[]),r===void 0&&(r=null),n===void 0&&(n=null),e==null){let i;if(!r)return null;if(r.errors)e=r.matches;else if((i=n)!=null&&i.v7_partialHydration&&t.length===0&&!r.initialized&&r.matches.length>0)e=r.matches;else return null}let l=e,d=(o=r)==null?void 0:o.errors;if(d!=null){const u=l.findIndex(s=>s.route.id&&d?.[s.route.id]!==void 0);u>=0||v(!1),l=l.slice(0,Math.min(l.length,u+1))}let f=!1,c=-1;if(r&&n&&n.v7_partialHydration)for(let u=0;u<l.length;u++){const s=l[u];if((s.route.HydrateFallback||s.route.hydrateFallbackElement)&&(c=u),s.route.id){let{loaderData:p,errors:m}=r,g=s.route.loader&&p[s.route.id]===void 0&&(!m||m[s.route.id]===void 0);if(s.route.lazy||g){f=!0,c>=0?l=l.slice(0,c+1):l=[l[0]];break}}}return l.reduceRight((u,s,p)=>{let m,g=!1,y=null,h=null;r&&(m=d&&s.route.id?d[s.route.id]:void 0,y=s.route.errorElement||se,f&&(c<0&&p===0?(ge("route-fallback"),g=!0,h=null):c===p&&(g=!0,h=s.route.hydrateFallbackElement||null)));const P=t.concat(l.slice(0,p+1)),U=()=>{let C;return m?C=y:g?C=h:s.route.Component?C=a.createElement(s.route.Component,null):s.route.element?C=s.route.element:C=u,a.createElement(ce,{match:s,routeContext:{outlet:u,matches:P,isDataRoute:r!=null},children:C})};return r&&(s.route.ErrorBoundary||s.route.errorElement||p===0)?a.createElement(ue,{location:r.location,revalidation:r.revalidation,component:y,error:m,children:U(),routeContext:{outlet:null,matches:P,isDataRoute:!0}}):U()},null)}var q=(function(e){return e.UseBlocker="useBlocker",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate",e})(q||{}),Q=(function(e){return e.UseBlocker="useBlocker",e.UseLoaderData="useLoaderData",e.UseActionData="useActionData",e.UseRouteError="useRouteError",e.UseNavigation="useNavigation",e.UseRouteLoaderData="useRouteLoaderData",e.UseMatches="useMatches",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate",e.UseRouteId="useRouteId",e})(Q||{});function de(e){const t=a.useContext(j);return t||v(!1),t}function he(e){const t=a.useContext(re);return t||v(!1),t}function pe(e){const t=a.useContext(E);return t||v(!1),t}function Y(e){const t=pe(),r=t.matches[t.matches.length-1];return r.route.id||v(!1),r.route.id}function ve(){let e;const t=a.useContext($),r=he(),n=Y();return t!==void 0?t:(e=r.errors)==null?void 0:e[n]}function me(){const{router:e}=de(q.UseNavigateStable),t=Y(Q.UseNavigateStable),r=a.useRef(!1);return G(()=>{r.current=!0}),a.useCallback(function(o,i){i===void 0&&(i={}),r.current&&(typeof o=="number"?e.navigate(o):e.navigate(o,w({fromRouteId:t},i)))},[e,t])}const A={};function ge(e,t,r){A[e]||(A[e]=!0)}function Ce(e,t){e?.v7_startTransition,e?.v7_relativeSplatPath}function Fe(e){const{to:t,replace:r,state:n,relative:o}=e;R()||v(!1);const{future:i,static:l}=a.useContext(x),{matches:d}=a.useContext(E),{pathname:f}=b(),c=k(),u=_(t,F(d,i.v7_relativeSplatPath),f,o==="path"),s=JSON.stringify(u);return a.useEffect(()=>c(JSON.parse(s),{replace:r,state:n,relative:o}),[c,s,o,r,n]),null}function ye(e){v(!1)}function Ee(e){let{basename:t="/",children:r=null,location:n,navigationType:o=V.Pop,navigator:i,static:l=!1,future:d}=e;R()&&v(!1);const f=t.replace(/^\/*/,"/"),c=a.useMemo(()=>({basename:f,navigator:i,static:l,future:w({v7_relativeSplatPath:!1},d)}),[f,d,i,l]);typeof n=="string"&&(n=W(n));let{pathname:u="/",search:s="",hash:p="",state:m=null,key:g="default"}=n,y=a.useMemo(()=>{const h=K(u,f);return h==null?null:{location:{pathname:h,search:s,hash:p,state:m,key:g},navigationType:o}},[f,u,s,p,m,g,o]);return y==null?null:a.createElement(x.Provider,{value:c},a.createElement(N.Provider,{children:r,value:y}))}function je(e){const{children:t,location:r}=e;return oe(O(t),r)}new Promise(()=>{});function O(e,t){t===void 0&&(t=[]);const r=[];return a.Children.forEach(e,(n,o)=>{if(!a.isValidElement(n))return;const i=[...t,o];if(n.type===a.Fragment){r.push.apply(r,O(n.props.children,i));return}n.type!==ye&&v(!1),!n.props.index||!n.props.children||v(!1);const l={id:n.props.id||i.join("-"),caseSensitive:n.props.caseSensitive,element:n.props.element,Component:n.props.Component,index:n.props.index,path:n.props.path,loader:n.props.loader,action:n.props.action,errorElement:n.props.errorElement,ErrorBoundary:n.props.ErrorBoundary,hasErrorBoundary:n.props.ErrorBoundary!=null||n.props.errorElement!=null,shouldRevalidate:n.props.shouldRevalidate,handle:n.props.handle,lazy:n.props.lazy};n.props.children&&(l.children=O(n.props.children,i)),r.push(l)}),r}function B(){return B=Object.assign?Object.assign.bind():function(e){for(let t=1;t<arguments.length;t++){const r=arguments[t];for(const n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},B.apply(this,arguments)}function xe(e,t){if(e==null)return{};let r={},n=Object.keys(e),o,i;for(i=0;i<n.length;i++)o=n[i],!(t.indexOf(o)>=0)&&(r[o]=e[o]);return r}function Re(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function be(e,t){return e.button===0&&(!t||t==="_self")&&!Re(e)}function T(e){return e===void 0&&(e=""),new URLSearchParams(typeof e=="string"||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce((t,r)=>{const n=e[r];return t.concat(Array.isArray(n)?n.map(o=>[r,o]):[[r,n]])},[]))}function Pe(e,t){const r=T(e);return t&&t.forEach((n,o)=>{r.has(o)||t.getAll(o).forEach(i=>{r.append(o,i)})}),r}const we=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],Ue="6";try{window.__reactRouterVersion=Ue}catch{}const Se="startTransition",J=Z[Se];function ke(e){let{basename:t,children:r,future:n,window:o}=e,i=a.useRef();i.current==null&&(i.current=te({window:o,v5Compat:!0}));const l=i.current,[d,f]=a.useState({action:l.action,location:l.location}),{v7_startTransition:c}=n||{},u=a.useCallback(s=>{c&&J?J(()=>f(s)):f(s)},[f,c]);return a.useLayoutEffect(()=>l.listen(u),[l,u]),a.useEffect(()=>Ce(n),[n]),a.createElement(Ee,{basename:t,children:r,location:d.location,navigationType:d.action,navigator:l,future:n})}const Le=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",Ne=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Ie=a.forwardRef(function(t,r){let{onClick:n,relative:o,reloadDocument:i,replace:l,state:d,target:f,to:c,preventScrollReset:u,viewTransition:s}=t,p=xe(t,we),{basename:m}=a.useContext(x),g,y=!1;if(typeof c=="string"&&Ne.test(c)&&(g=c,Le))try{const C=new URL(window.location.href),S=c.startsWith("//")?new URL(C.protocol+c):new URL(c),I=K(S.pathname,m);S.origin===C.origin&&I!=null?c=I+S.search+S.hash:y=!0}catch{}const h=ne(c,{relative:o}),P=Oe(c,{replace:l,state:d,target:f,preventScrollReset:u,relative:o,viewTransition:s});function U(C){n&&n(C),C.defaultPrevented||P(C)}return a.createElement("a",B({},p,{href:g||h,onClick:y||i?n:U,ref:r,target:f}))});let D;(function(e){e.UseScrollRestoration="useScrollRestoration",e.UseSubmit="useSubmit",e.UseSubmitFetcher="useSubmitFetcher",e.UseFetcher="useFetcher",e.useViewTransitionState="useViewTransitionState"})(D||(D={}));let z;(function(e){e.UseFetcher="useFetcher",e.UseFetchers="useFetchers",e.UseScrollRestoration="useScrollRestoration"})(z||(z={}));function Oe(e,t){const{target:r,replace:n,state:o,preventScrollReset:i,relative:l,viewTransition:d}=t===void 0?{}:t,f=k(),c=b(),u=X(e,{relative:l});return a.useCallback(s=>{if(be(s,r)){s.preventDefault();const p=n!==void 0?n:M(c)===M(u);f(e,{replace:p,state:o,preventScrollReset:i,relative:l,viewTransition:d})}},[c,f,u,n,o,r,e,i,l,d])}function Me(e){const t=a.useRef(T(e)),r=a.useRef(!1),n=b(),o=a.useMemo(()=>Pe(n.search,r.current?null:t.current),[n.search]),i=k(),l=a.useCallback((d,f)=>{const c=T(typeof d=="function"?d(o):d);r.current=!0,i(`?${c}`,f)},[i,o]);return[o,l]}export{ke as B,Ie as L,Fe as N,je as R,b as a,ye as b,Me as c,_e as d,k as u};
|