@ngrok/mantle 0.54.3 → 0.55.0

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.
@@ -0,0 +1,43 @@
1
+ /**
2
+ * React component that auto-scrolls to the element matching the current URL hash (e.g., `#subscription`).
3
+ *
4
+ * Behavior:
5
+ * - Runs on mount and whenever the `hash` changes.
6
+ * - Schedules the scroll in `requestAnimationFrame` to ensure the target element
7
+ * exists after DOM updates/paint.
8
+ * - Respects the user's motion preference via `useScrollBehavior()` (i.e., `"auto"` when
9
+ * reduced motion is enabled; `"smooth"` otherwise).
10
+ * - Safe for SSR via `useIsomorphicLayoutEffect`.
11
+ *
12
+ * @example
13
+ * <AutoScrollToHash />
14
+ *
15
+ * @remarks
16
+ * If your content is loaded asynchronously and may not exist by the next animation
17
+ * frame, consider enhancing the hook with a short retry loop or a `MutationObserver`.
18
+ */
19
+ declare function AutoScrollToHash(): null;
20
+ type Props = {
21
+ /** Disable automatic scrolling to hash targets. */
22
+ disabled?: boolean;
23
+ };
24
+ /**
25
+ * Hook that scrolls the element identified by `location.hash` into view.
26
+ *
27
+ * - Exits early when `disabled` or when `hash` is empty.
28
+ * - Attempts both the raw ID and a decoded ID (`decodeURIComponent`) for robustness.
29
+ * - Uses `useScrollBehavior()` so motion-sensitive users get `"auto"` instead of `"smooth"`.
30
+ *
31
+ * @param options.disabled When `true`, suppresses scrolling.
32
+ *
33
+ * @example
34
+ * function Page() {
35
+ * useAutoScrollToHash();
36
+ * return <>{page content}</>;
37
+ * }
38
+ *
39
+ * @see {@link useScrollBehavior} for how the scroll behavior is chosen.
40
+ */
41
+ declare function useAutoScrollToHash({ disabled }?: Props): void;
42
+
43
+ export { AutoScrollToHash, useAutoScrollToHash };
@@ -0,0 +1,19 @@
1
+ import{a as ve,c as Re}from"./chunk-V4TWM6RF.js";import*as P from"react";import*as f from"react";import*as C from"react";import*as fe from"react";import*as Ie from"react";import*as g from"react";import*as er from"react";import*as tr from"react";import*as rr from"react";import*as h from"react";import*as et from"react";function b(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function L(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function Z({pathname:e="/",search:t="",hash:r=""}){return t&&t!=="?"&&(e+=t.charAt(0)==="?"?t:"?"+t),r&&r!=="#"&&(e+=r.charAt(0)==="#"?r:"#"+r),e}function $(e){let t={};if(e){let r=e.indexOf("#");r>=0&&(t.hash=e.substring(r),e=e.substring(0,r));let n=e.indexOf("?");n>=0&&(t.search=e.substring(n),e=e.substring(0,n)),e&&(t.pathname=e)}return t}var rt;rt=new WeakMap;function oe(e,t,r="/"){return at(e,t,r,!1)}function at(e,t,r,n){let a=typeof t=="string"?$(t):t,o=N(a.pathname||"/",r);if(o==null)return null;let i=Se(e);ot(i);let u=null;for(let s=0;u==null&&s<i.length;++s){let l=yt(o);u=mt(i[s],l,n)}return u}function nt(e,t){let{route:r,pathname:n,params:a}=e;return{id:r.id,pathname:n,params:a,data:t[r.id],loaderData:t[r.id],handle:r.handle}}function Se(e,t=[],r=[],n="",a=!1){let o=(i,u,s=a,l)=>{let c={relativePath:l===void 0?i.path||"":l,caseSensitive:i.caseSensitive===!0,childrenIndex:u,route:i};if(c.relativePath.startsWith("/")){if(!c.relativePath.startsWith(n)&&s)return;b(c.relativePath.startsWith(n),`Absolute route path "${c.relativePath}" nested under path "${n}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),c.relativePath=c.relativePath.slice(n.length)}let d=M([n,c.relativePath]),m=r.concat(c);i.children&&i.children.length>0&&(b(i.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${d}".`),Se(i.children,t,m,d,s)),!(i.path==null&&!i.index)&&t.push({path:d,score:ft(d,i.index),routesMeta:m})};return e.forEach((i,u)=>{if(i.path===""||!i.path?.includes("?"))o(i,u);else for(let s of be(i.path))o(i,u,!0,s)}),t}function be(e){let t=e.split("/");if(t.length===0)return[];let[r,...n]=t,a=r.endsWith("?"),o=r.replace(/\?$/,"");if(n.length===0)return a?[o,""]:[o];let i=be(n.join("/")),u=[];return u.push(...i.map(s=>s===""?o:[o,s].join("/"))),a&&u.push(...i),u.map(s=>e.startsWith("/")&&s===""?"/":s)}function ot(e){e.sort((t,r)=>t.score!==r.score?r.score-t.score:ht(t.routesMeta.map(n=>n.childrenIndex),r.routesMeta.map(n=>n.childrenIndex)))}var it=/^:[\w-]+$/,lt=3,st=2,ut=1,ct=10,dt=-2,ge=e=>e==="*";function ft(e,t){let r=e.split("/"),n=r.length;return r.some(ge)&&(n+=dt),t&&(n+=st),r.filter(a=>!ge(a)).reduce((a,o)=>a+(it.test(o)?lt:o===""?ut:ct),n)}function ht(e,t){return e.length===t.length&&e.slice(0,-1).every((n,a)=>n===t[a])?e[e.length-1]-t[t.length-1]:0}function mt(e,t,r=!1){let{routesMeta:n}=e,a={},o="/",i=[];for(let u=0;u<n.length;++u){let s=n[u],l=u===n.length-1,c=o==="/"?t:t.slice(o.length)||"/",d=W({path:s.relativePath,caseSensitive:s.caseSensitive,end:l},c),m=s.route;if(!d&&l&&r&&!n[n.length-1].route.index&&(d=W({path:s.relativePath,caseSensitive:s.caseSensitive,end:!1},c)),!d)return null;Object.assign(a,d.params),i.push({params:a,pathname:M([o,d.pathname]),pathnameBase:gt(M([o,d.pathnameBase])),route:m}),d.pathnameBase!=="/"&&(o=M([o,d.pathnameBase]))}return i}function W(e,t){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[r,n]=pt(e.path,e.caseSensitive,e.end),a=t.match(r);if(!a)return null;let o=a[0],i=o.replace(/(.)\/+$/,"$1"),u=a.slice(1);return{params:n.reduce((l,{paramName:c,isOptional:d},m)=>{if(c==="*"){let R=u[m]||"";i=o.slice(0,o.length-R.length).replace(/(.)\/+$/,"$1")}let y=u[m];return d&&!y?l[c]=void 0:l[c]=(y||"").replace(/%2F/g,"/"),l},{}),pathname:o,pathnameBase:i,pattern:e}}function pt(e,t=!1,r=!0){L(e==="*"||!e.endsWith("*")||e.endsWith("/*"),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,"/*")}".`);let n=[],a="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(i,u,s)=>(n.push({paramName:u,isOptional:s!=null}),s?"/?([^\\/]+)?":"/([^\\/]+)")).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return e.endsWith("*")?(n.push({paramName:"*"}),a+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):r?a+="\\/*$":e!==""&&e!=="/"&&(a+="(?:(?=\\/|$))"),[new RegExp(a,t?void 0:"i"),n]}function yt(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return L(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${t}).`),e}}function N(e,t){if(t==="/")return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let r=t.endsWith("/")?t.length-1:t.length,n=e.charAt(r);return n&&n!=="/"?null:e.slice(r)||"/"}function Ce(e,t="/"){let{pathname:r,search:n="",hash:a=""}=typeof e=="string"?$(e):e;return{pathname:r?r.startsWith("/")?r:vt(r,t):t,search:wt(n),hash:Et(a)}}function vt(e,t){let r=t.replace(/\/+$/,"").split("/");return e.split("/").forEach(a=>{a===".."?r.length>1&&r.pop():a!=="."&&r.push(a)}),r.length>1?r.join("/"):"/"}function ee(e,t,r,n){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(n)}]. Please separate it out to the \`to.${r}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function Rt(e){return e.filter((t,r)=>r===0||t.route.path&&t.route.path.length>0)}function Pe(e){let t=Rt(e);return t.map((r,n)=>n===t.length-1?r.pathname:r.pathnameBase)}function xe(e,t,r,n=!1){let a;typeof e=="string"?a=$(e):(a={...e},b(!a.pathname||!a.pathname.includes("?"),ee("?","pathname","search",a)),b(!a.pathname||!a.pathname.includes("#"),ee("#","pathname","hash",a)),b(!a.search||!a.search.includes("#"),ee("#","search","hash",a)));let o=e===""||a.pathname==="",i=o?"/":a.pathname,u;if(i==null)u=r;else{let d=t.length-1;if(!n&&i.startsWith("..")){let m=i.split("/");for(;m[0]==="..";)m.shift(),d-=1;a.pathname=m.join("/")}u=d>=0?t[d]:"/"}let s=Ce(a,u),l=i&&i!=="/"&&i.endsWith("/"),c=(o||i===".")&&r.endsWith("/");return!s.pathname.endsWith("/")&&(l||c)&&(s.pathname+="/"),s}var M=e=>e.join("/").replace(/\/\/+/g,"/"),gt=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),wt=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,Et=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e;function Le(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}var De=["POST","PUT","PATCH","DELETE"],hr=new Set(De),St=["GET",...De],mr=new Set(St);var pr=Symbol("ResetLoaderData");var O=P.createContext(null);O.displayName="DataRouter";var I=P.createContext(null);I.displayName="DataRouterState";var yr=P.createContext(!1);var ie=P.createContext({isTransitioning:!1});ie.displayName="ViewTransition";var Fe=P.createContext(new Map);Fe.displayName="Fetchers";var bt=P.createContext(null);bt.displayName="Await";var x=P.createContext(null);x.displayName="Navigation";var H=P.createContext(null);H.displayName="Location";var T=P.createContext({outlet:null,matches:[],isDataRoute:!1});T.displayName="Route";var le=P.createContext(null);le.displayName="RouteError";var re=!0;function Ne(e,{relative:t}={}){b(U(),"useHref() may be used only in the context of a <Router> component.");let{basename:r,navigator:n}=f.useContext(x),{hash:a,pathname:o,search:i}=j(e,{relative:t}),u=o;return r!=="/"&&(u=o==="/"?r:M([r,o])),n.createHref({pathname:u,search:i,hash:a})}function U(){return f.useContext(H)!=null}function D(){return b(U(),"useLocation() may be used only in the context of a <Router> component."),f.useContext(H).location}var Te="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function Me(e){f.useContext(x).static||f.useLayoutEffect(e)}function Ae(){let{isDataRoute:e}=f.useContext(T);return e?Ot():Ct()}function Ct(){b(U(),"useNavigate() may be used only in the context of a <Router> component.");let e=f.useContext(O),{basename:t,navigator:r}=f.useContext(x),{matches:n}=f.useContext(T),{pathname:a}=D(),o=JSON.stringify(Pe(n)),i=f.useRef(!1);return Me(()=>{i.current=!0}),f.useCallback((s,l={})=>{if(L(i.current,Te),!i.current)return;if(typeof s=="number"){r.go(s);return}let c=xe(s,JSON.parse(o),a,l.relative==="path");e==null&&t!=="/"&&(c.pathname=c.pathname==="/"?t:M([t,c.pathname])),(l.replace?r.replace:r.push)(c,l.state,l)},[t,r,o,a,e])}var vr=f.createContext(null);function j(e,{relative:t}={}){let{matches:r}=f.useContext(T),{pathname:n}=D(),a=JSON.stringify(Pe(r));return f.useMemo(()=>xe(e,JSON.parse(a),n,t==="path"),[e,a,n,t])}function Pt(e,t,r,n,a){b(U(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:o}=f.useContext(x),{matches:i}=f.useContext(T),u=i[i.length-1],s=u?u.params:{},l=u?u.pathname:"/",c=u?u.pathnameBase:"/",d=u&&u.route;if(re){let p=d&&d.path||"";ke(l,!d||p.endsWith("*")||p.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${l}" (under <Route path="${p}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
2
+
3
+ Please change the parent <Route path="${p}"> to <Route path="${p==="/"?"*":`${p}/*`}">.`)}let m=D(),y;if(t){let p=typeof t=="string"?$(t):t;b(c==="/"||p.pathname?.startsWith(c),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${c}" but pathname "${p.pathname}" was given in the \`location\` prop.`),y=p}else y=m;let R=y.pathname||"/",E=R;if(c!=="/"){let p=c.replace(/^\//,"").split("/");E="/"+R.replace(/^\//,"").split("/").slice(p.length).join("/")}let w=oe(e,{pathname:E});re&&(L(d||w!=null,`No routes matched location "${y.pathname}${y.search}${y.hash}" `),L(w==null||w[w.length-1].route.element!==void 0||w[w.length-1].route.Component!==void 0||w[w.length-1].route.lazy!==void 0,`Matched leaf route at location "${y.pathname}${y.search}${y.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`));let v=Nt(w&&w.map(p=>Object.assign({},p,{params:Object.assign({},s,p.params),pathname:M([c,o.encodeLocation?o.encodeLocation(p.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:p.pathname]),pathnameBase:p.pathnameBase==="/"?c:M([c,o.encodeLocation?o.encodeLocation(p.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:p.pathnameBase])})),i,r,n,a);return t&&v?f.createElement(H.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...y},navigationType:"POP"}},v):v}function xt(){let e=_e(),t=Le(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),r=e instanceof Error?e.stack:null,n="rgba(200,200,200, 0.5)",a={padding:"0.5rem",backgroundColor:n},o={padding:"2px 4px",backgroundColor:n},i=null;return re&&(console.error("Error handled by React Router default ErrorBoundary:",e),i=f.createElement(f.Fragment,null,f.createElement("p",null,"\u{1F4BF} Hey developer \u{1F44B}"),f.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",f.createElement("code",{style:o},"ErrorBoundary")," or"," ",f.createElement("code",{style:o},"errorElement")," prop on your route."))),f.createElement(f.Fragment,null,f.createElement("h2",null,"Unexpected Application Error!"),f.createElement("h3",{style:{fontStyle:"italic"}},t),r?f.createElement("pre",{style:a},r):null,i)}var Lt=f.createElement(xt,null),Dt=class extends f.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,t){return t.location!==e.location||t.revalidation!=="idle"&&e.revalidation==="idle"?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error!==void 0?e.error:t.error,location:t.location,revalidation:e.revalidation||t.revalidation}}componentDidCatch(e,t){this.props.unstable_onError?this.props.unstable_onError(e,t):console.error("React Router caught the following error during render",e)}render(){return this.state.error!==void 0?f.createElement(T.Provider,{value:this.props.routeContext},f.createElement(le.Provider,{value:this.state.error,children:this.props.component})):this.props.children}};function Ft({routeContext:e,match:t,children:r}){let n=f.useContext(O);return n&&n.static&&n.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(n.staticContext._deepestRenderedBoundaryId=t.route.id),f.createElement(T.Provider,{value:e},r)}function Nt(e,t=[],r=null,n=null,a=null){if(e==null){if(!r)return null;if(r.errors)e=r.matches;else if(t.length===0&&!r.initialized&&r.matches.length>0)e=r.matches;else return null}let o=e,i=r?.errors;if(i!=null){let l=o.findIndex(c=>c.route.id&&i?.[c.route.id]!==void 0);b(l>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(i).join(",")}`),o=o.slice(0,Math.min(o.length,l+1))}let u=!1,s=-1;if(r)for(let l=0;l<o.length;l++){let c=o[l];if((c.route.HydrateFallback||c.route.hydrateFallbackElement)&&(s=l),c.route.id){let{loaderData:d,errors:m}=r,y=c.route.loader&&!d.hasOwnProperty(c.route.id)&&(!m||m[c.route.id]===void 0);if(c.route.lazy||y){u=!0,s>=0?o=o.slice(0,s+1):o=[o[0]];break}}}return o.reduceRight((l,c,d)=>{let m,y=!1,R=null,E=null;r&&(m=i&&c.route.id?i[c.route.id]:void 0,R=c.route.errorElement||Lt,u&&(s<0&&d===0?(ke("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),y=!0,E=null):s===d&&(y=!0,E=c.route.hydrateFallbackElement||null)));let w=t.concat(o.slice(0,d+1)),v=()=>{let p;return m?p=R:y?p=E:c.route.Component?p=f.createElement(c.route.Component,null):c.route.element?p=c.route.element:p=l,f.createElement(Ft,{match:c,routeContext:{outlet:l,matches:w,isDataRoute:r!=null},children:p})};return r&&(c.route.ErrorBoundary||c.route.errorElement||d===0)?f.createElement(Dt,{location:r.location,revalidation:r.revalidation,component:R,error:m,children:v(),routeContext:{outlet:null,matches:w,isDataRoute:!0},unstable_onError:n}):v()},null)}function se(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Tt(e){let t=f.useContext(O);return b(t,se(e)),t}function ue(e){let t=f.useContext(I);return b(t,se(e)),t}function Mt(e){let t=f.useContext(T);return b(t,se(e)),t}function ce(e){let t=Mt(e),r=t.matches[t.matches.length-1];return b(r.route.id,`${e} can only be used on routes that contain a unique "id"`),r.route.id}function At(){return ce("useRouteId")}function Oe(){return ue("useNavigation").navigation}function de(){let{matches:e,loaderData:t}=ue("useMatches");return f.useMemo(()=>e.map(r=>nt(r,t)),[e,t])}function _e(){let e=f.useContext(le),t=ue("useRouteError"),r=ce("useRouteError");return e!==void 0?e:t.errors?.[r]}function Ot(){let{router:e}=Tt("useNavigate"),t=ce("useNavigate"),r=f.useRef(!1);return Me(()=>{r.current=!0}),f.useCallback(async(a,o={})=>{L(r.current,Te),r.current&&(typeof a=="number"?e.navigate(a):await e.navigate(a,{fromRouteId:t,...o}))},[e,t])}var we={};function ke(e,t,r){!t&&!we[e]&&(we[e]=!0,L(!1,r))}var Rr=C.memo(_t);function _t({routes:e,future:t,state:r,unstable_onError:n}){return Pt(e,void 0,r,n,t)}function $e({basename:e="/",children:t=null,location:r,navigationType:n="POP",navigator:a,static:o=!1}){b(!U(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let i=e.replace(/^\/*/,"/"),u=C.useMemo(()=>({basename:i,navigator:a,static:o,future:{}}),[i,a,o]);typeof r=="string"&&(r=$(r));let{pathname:s="/",search:l="",hash:c="",state:d=null,key:m="default"}=r,y=C.useMemo(()=>{let R=N(s,i);return R==null?null:{location:{pathname:R,search:l,hash:c,state:d,key:m},navigationType:n}},[i,s,l,c,d,m,n]);return L(y!=null,`<Router basename="${i}"> is not able to match the URL "${s}${l}${c}" because it does not start with the basename, so the <Router> won't render anything.`),y==null?null:C.createElement(x.Provider,{value:u},C.createElement(H.Provider,{children:t,value:y}))}var X="get",Q="application/x-www-form-urlencoded";function q(e){return e!=null&&typeof e.tagName=="string"}function kt(e){return q(e)&&e.tagName.toLowerCase()==="button"}function $t(e){return q(e)&&e.tagName.toLowerCase()==="form"}function It(e){return q(e)&&e.tagName.toLowerCase()==="input"}function Ht(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function Ut(e,t){return e.button===0&&(!t||t==="_self")&&!Ht(e)}var K=null;function jt(){if(K===null)try{new FormData(document.createElement("form"),0),K=!1}catch{K=!0}return K}var Bt=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function te(e){return e!=null&&!Bt.has(e)?(L(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${Q}"`),null):e}function zt(e,t){let r,n,a,o,i;if($t(e)){let u=e.getAttribute("action");n=u?N(u,t):null,r=e.getAttribute("method")||X,a=te(e.getAttribute("enctype"))||Q,o=new FormData(e)}else if(kt(e)||It(e)&&(e.type==="submit"||e.type==="image")){let u=e.form;if(u==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let s=e.getAttribute("formaction")||u.getAttribute("action");if(n=s?N(s,t):null,r=e.getAttribute("formmethod")||u.getAttribute("method")||X,a=te(e.getAttribute("formenctype"))||te(u.getAttribute("enctype"))||Q,o=new FormData(u,e),!jt()){let{name:l,type:c,value:d}=e;if(c==="image"){let m=l?`${l}.`:"";o.append(`${m}x`,"0"),o.append(`${m}y`,"0")}else l&&o.append(l,d)}}else{if(q(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');r=X,n=null,a=Q,i=e}return o&&a==="text/plain"&&(i=o,o=void 0),{action:n,method:r.toLowerCase(),encType:a,formData:o,body:i}}var gr=Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function he(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}var Wt=Symbol("SingleFetchRedirect");function Vt(e,t,r){let n=typeof e=="string"?new URL(e,typeof window>"u"?"server://singlefetch/":window.location.origin):e;return n.pathname==="/"?n.pathname=`_root.${r}`:t&&N(n.pathname,t)==="/"?n.pathname=`${t.replace(/\/$/,"")}/_root.${r}`:n.pathname=`${n.pathname.replace(/\/$/,"")}.${r}`,n}async function Yt(e,t){if(e.id in t)return t[e.id];try{let r=await import(e.module);return t[e.id]=r,r}catch(r){if(console.error(`Error loading route module \`${e.module}\`, reloading page...`),console.error(r),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode&&import.meta.hot)throw r;return window.location.reload(),new Promise(()=>{})}}function Jt(e){return e!=null&&typeof e.page=="string"}function Kt(e){return e==null?!1:e.href==null?e.rel==="preload"&&typeof e.imageSrcSet=="string"&&typeof e.imageSizes=="string":typeof e.rel=="string"&&typeof e.href=="string"}async function Gt(e,t,r){let n=await Promise.all(e.map(async a=>{let o=t.routes[a.route.id];if(o){let i=await Yt(o,r);return i.links?i.links():[]}return[]}));return qt(n.flat(1).filter(Kt).filter(a=>a.rel==="stylesheet"||a.rel==="preload").map(a=>a.rel==="stylesheet"?{...a,rel:"prefetch",as:"style"}:{...a,rel:"prefetch"}))}function Ee(e,t,r,n,a,o){let i=(s,l)=>r[l]?s.route.id!==r[l].route.id:!0,u=(s,l)=>r[l].pathname!==s.pathname||r[l].route.path?.endsWith("*")&&r[l].params["*"]!==s.params["*"];return o==="assets"?t.filter((s,l)=>i(s,l)||u(s,l)):o==="data"?t.filter((s,l)=>{let c=n.routes[s.route.id];if(!c||!c.hasLoader)return!1;if(i(s,l)||u(s,l))return!0;if(s.route.shouldRevalidate){let d=s.route.shouldRevalidate({currentUrl:new URL(a.pathname+a.search+a.hash,window.origin),currentParams:r[0]?.params||{},nextUrl:new URL(e,window.origin),nextParams:s.params,defaultShouldRevalidate:!0});if(typeof d=="boolean")return d}return!0}):[]}function Xt(e,t,{includeHydrateFallback:r}={}){return Qt(e.map(n=>{let a=t.routes[n.route.id];if(!a)return[];let o=[a.module];return a.clientActionModule&&(o=o.concat(a.clientActionModule)),a.clientLoaderModule&&(o=o.concat(a.clientLoaderModule)),r&&a.hydrateFallbackModule&&(o=o.concat(a.hydrateFallbackModule)),a.imports&&(o=o.concat(a.imports)),o}).flat(1))}function Qt(e){return[...new Set(e)]}function Zt(e){let t={},r=Object.keys(e).sort();for(let n of r)t[n]=e[n];return t}function qt(e,t){let r=new Set,n=new Set(t);return e.reduce((a,o)=>{if(t&&!Jt(o)&&o.as==="script"&&o.href&&n.has(o.href))return a;let u=JSON.stringify(Zt(o));return r.has(u)||(r.add(u),a.push({key:u,link:o})),a},[])}function He(){let e=g.useContext(O);return he(e,"You must render this element inside a <DataRouterContext.Provider> element"),e}function ar(){let e=g.useContext(I);return he(e,"You must render this element inside a <DataRouterStateContext.Provider> element"),e}var V=g.createContext(void 0);V.displayName="FrameworkContext";function Ue(){let e=g.useContext(V);return he(e,"You must render this element inside a <HydratedRouter> element"),e}function nr(e,t){let r=g.useContext(V),[n,a]=g.useState(!1),[o,i]=g.useState(!1),{onFocus:u,onBlur:s,onMouseEnter:l,onMouseLeave:c,onTouchStart:d}=t,m=g.useRef(null);g.useEffect(()=>{if(e==="render"&&i(!0),e==="viewport"){let E=v=>{v.forEach(p=>{i(p.isIntersecting)})},w=new IntersectionObserver(E,{threshold:.5});return m.current&&w.observe(m.current),()=>{w.disconnect()}}},[e]),g.useEffect(()=>{if(n){let E=setTimeout(()=>{i(!0)},100);return()=>{clearTimeout(E)}}},[n]);let y=()=>{a(!0)},R=()=>{a(!1),i(!1)};return r?e!=="intent"?[o,m,{}]:[o,m,{onFocus:z(u,y),onBlur:z(s,R),onMouseEnter:z(l,y),onMouseLeave:z(c,R),onTouchStart:z(d,y)}]:[!1,m,{}]}function z(e,t){return r=>{e&&e(r),r.defaultPrevented||t(r)}}function je({page:e,...t}){let{router:r}=He(),n=g.useMemo(()=>oe(r.routes,e,r.basename),[r.routes,e,r.basename]);return n?g.createElement(ir,{page:e,matches:n,...t}):null}function or(e){let{manifest:t,routeModules:r}=Ue(),[n,a]=g.useState([]);return g.useEffect(()=>{let o=!1;return Gt(e,t,r).then(i=>{o||a(i)}),()=>{o=!0}},[e,t,r]),n}function ir({page:e,matches:t,...r}){let n=D(),{manifest:a,routeModules:o}=Ue(),{basename:i}=He(),{loaderData:u,matches:s}=ar(),l=g.useMemo(()=>Ee(e,t,s,a,n,"data"),[e,t,s,a,n]),c=g.useMemo(()=>Ee(e,t,s,a,n,"assets"),[e,t,s,a,n]),d=g.useMemo(()=>{if(e===n.pathname+n.search+n.hash)return[];let R=new Set,E=!1;if(t.forEach(v=>{let p=a.routes[v.route.id];!p||!p.hasLoader||(!l.some(S=>S.route.id===v.route.id)&&v.route.id in u&&o[v.route.id]?.shouldRevalidate||p.hasClientLoader?E=!0:R.add(v.route.id))}),R.size===0)return[];let w=Vt(e,i,"data");return E&&R.size>0&&w.searchParams.set("_routes",t.filter(v=>R.has(v.route.id)).map(v=>v.route.id).join(",")),[w.pathname+w.search]},[i,u,n,a,l,t,e,o]),m=g.useMemo(()=>Xt(c,a),[c,a]),y=or(c);return g.createElement(g.Fragment,null,d.map(R=>g.createElement("link",{key:R,rel:"prefetch",as:"fetch",href:R,...r})),m.map(R=>g.createElement("link",{key:R,rel:"modulepreload",href:R,...r})),y.map(({key:R,link:E})=>g.createElement("link",{key:R,nonce:r.nonce,...E})))}function lr(...e){return t=>{e.forEach(r=>{typeof r=="function"?r(t):r!=null&&(r.current=t)})}}var Be=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{Be&&(window.__reactRouterVersion="7.9.3")}catch{}function ze({basename:e,children:t,history:r}){let[n,a]=h.useState({action:r.action,location:r.location}),o=h.useCallback(i=>{h.startTransition(()=>a(i))},[a]);return h.useLayoutEffect(()=>r.listen(o),[r,o]),h.createElement($e,{basename:e,children:t,location:n.location,navigationType:n.action,navigator:r})}ze.displayName="unstable_HistoryRouter";var We=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,me=h.forwardRef(function({onClick:t,discover:r="render",prefetch:n="none",relative:a,reloadDocument:o,replace:i,state:u,target:s,to:l,preventScrollReset:c,viewTransition:d,...m},y){let{basename:R}=h.useContext(x),E=typeof l=="string"&&We.test(l),w,v=!1;if(typeof l=="string"&&E&&(w=l,Be))try{let F=new URL(window.location.href),k=l.startsWith("//")?new URL(F.protocol+l):new URL(l),ye=N(k.pathname,R);k.origin===F.origin&&ye!=null?l=ye+k.search+k.hash:v=!0}catch{L(!1,`<Link to="${l}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}let p=Ne(l,{relative:a}),[S,_,A]=nr(n,m),Y=Ge(l,{replace:i,state:u,target:s,preventScrollReset:c,relative:a,viewTransition:d});function B(F){t&&t(F),F.defaultPrevented||Y(F)}let J=h.createElement("a",{...m,...A,href:w||p,onClick:v||o?t:B,ref:lr(y,_),target:s,"data-discover":!E&&r==="render"?"true":void 0});return S&&!E?h.createElement(h.Fragment,null,J,h.createElement(je,{page:p})):J});me.displayName="Link";var Ve=h.forwardRef(function({"aria-current":t="page",caseSensitive:r=!1,className:n="",end:a=!1,style:o,to:i,viewTransition:u,children:s,...l},c){let d=j(i,{relative:l.relative}),m=D(),y=h.useContext(I),{navigator:R,basename:E}=h.useContext(x),w=y!=null&&qe(d)&&u===!0,v=R.encodeLocation?R.encodeLocation(d).pathname:d.pathname,p=m.pathname,S=y&&y.navigation&&y.navigation.location?y.navigation.location.pathname:null;r||(p=p.toLowerCase(),S=S?S.toLowerCase():null,v=v.toLowerCase()),S&&E&&(S=N(S,E)||S);let _=v!=="/"&&v.endsWith("/")?v.length-1:v.length,A=p===v||!a&&p.startsWith(v)&&p.charAt(_)==="/",Y=S!=null&&(S===v||!a&&S.startsWith(v)&&S.charAt(v.length)==="/"),B={isActive:A,isPending:Y,isTransitioning:w},J=A?t:void 0,F;typeof n=="function"?F=n(B):F=[n,A?"active":null,Y?"pending":null,w?"transitioning":null].filter(Boolean).join(" ");let k=typeof o=="function"?o(B):o;return h.createElement(me,{...l,"aria-current":J,className:F,ref:c,style:k,to:i,viewTransition:u},typeof s=="function"?s(B):s)});Ve.displayName="NavLink";var Ye=h.forwardRef(({discover:e="render",fetcherKey:t,navigate:r,reloadDocument:n,replace:a,state:o,method:i=X,action:u,onSubmit:s,relative:l,preventScrollReset:c,viewTransition:d,...m},y)=>{let R=Xe(),E=Qe(u,{relative:l}),w=i.toLowerCase()==="get"?"get":"post",v=typeof u=="string"&&We.test(u);return h.createElement("form",{ref:y,method:w,action:E,onSubmit:n?s:S=>{if(s&&s(S),S.defaultPrevented)return;S.preventDefault();let _=S.nativeEvent.submitter,A=_?.getAttribute("formmethod")||i;R(_||S.currentTarget,{fetcherKey:t,method:A,navigate:r,replace:a,state:o,relative:l,preventScrollReset:c,viewTransition:d})},...m,"data-discover":!v&&e==="render"?"true":void 0})});Ye.displayName="Form";function Je({getKey:e,storageKey:t,...r}){let n=h.useContext(V),{basename:a}=h.useContext(x),o=D(),i=de();Ze({getKey:e,storageKey:t});let u=h.useMemo(()=>{if(!n||!e)return null;let l=ne(o,i,a,e);return l!==o.key?l:null},[]);if(!n||n.isSpaMode)return null;let s=((l,c)=>{if(!window.history.state||!window.history.state.key){let d=Math.random().toString(32).slice(2);window.history.replaceState({key:d},"")}try{let m=JSON.parse(sessionStorage.getItem(l)||"{}")[c||window.history.state.key];typeof m=="number"&&window.scrollTo(0,m)}catch(d){console.error(d),sessionStorage.removeItem(l)}}).toString();return h.createElement("script",{...r,suppressHydrationWarning:!0,dangerouslySetInnerHTML:{__html:`(${s})(${JSON.stringify(t||ae)}, ${JSON.stringify(u)})`}})}Je.displayName="ScrollRestoration";function Ke(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function pe(e){let t=h.useContext(O);return b(t,Ke(e)),t}function sr(e){let t=h.useContext(I);return b(t,Ke(e)),t}function Ge(e,{target:t,replace:r,state:n,preventScrollReset:a,relative:o,viewTransition:i}={}){let u=Ae(),s=D(),l=j(e,{relative:o});return h.useCallback(c=>{if(Ut(c,t)){c.preventDefault();let d=r!==void 0?r:Z(s)===Z(l);u(e,{replace:d,state:n,preventScrollReset:a,relative:o,viewTransition:i})}},[s,u,l,r,n,t,e,a,o,i])}var ur=0,cr=()=>`__${String(++ur)}__`;function Xe(){let{router:e}=pe("useSubmit"),{basename:t}=h.useContext(x),r=At();return h.useCallback(async(n,a={})=>{let{action:o,method:i,encType:u,formData:s,body:l}=zt(n,t);if(a.navigate===!1){let c=a.fetcherKey||cr();await e.fetch(c,r,a.action||o,{preventScrollReset:a.preventScrollReset,formData:s,body:l,formMethod:a.method||i,formEncType:a.encType||u,flushSync:a.flushSync})}else await e.navigate(a.action||o,{preventScrollReset:a.preventScrollReset,formData:s,body:l,formMethod:a.method||i,formEncType:a.encType||u,replace:a.replace,state:a.state,fromRouteId:r,flushSync:a.flushSync,viewTransition:a.viewTransition})},[e,t,r])}function Qe(e,{relative:t}={}){let{basename:r}=h.useContext(x),n=h.useContext(T);b(n,"useFormAction must be used inside a RouteContext");let[a]=n.matches.slice(-1),o={...j(e||".",{relative:t})},i=D();if(e==null){o.search=i.search;let u=new URLSearchParams(o.search),s=u.getAll("index");if(s.some(c=>c==="")){u.delete("index"),s.filter(d=>d).forEach(d=>u.append("index",d));let c=u.toString();o.search=c?`?${c}`:""}}return(!e||e===".")&&a.route.index&&(o.search=o.search?o.search.replace(/^\?/,"?index&"):"?index"),r!=="/"&&(o.pathname=o.pathname==="/"?r:M([r,o.pathname])),Z(o)}var ae="react-router-scroll-positions",G={};function ne(e,t,r,n){let a=null;return n&&(r!=="/"?a=n({...e,pathname:N(e.pathname,r)||e.pathname},t):a=n(e,t)),a==null&&(a=e.key),a}function Ze({getKey:e,storageKey:t}={}){let{router:r}=pe("useScrollRestoration"),{restoreScrollPosition:n,preventScrollReset:a}=sr("useScrollRestoration"),{basename:o}=h.useContext(x),i=D(),u=de(),s=Oe();h.useEffect(()=>(window.history.scrollRestoration="manual",()=>{window.history.scrollRestoration="auto"}),[]),dr(h.useCallback(()=>{if(s.state==="idle"){let l=ne(i,u,o,e);G[l]=window.scrollY}try{sessionStorage.setItem(t||ae,JSON.stringify(G))}catch(l){L(!1,`Failed to save scroll positions in sessionStorage, <ScrollRestoration /> will not work properly (${l}).`)}window.history.scrollRestoration="auto"},[s.state,e,o,i,u,t])),typeof document<"u"&&(h.useLayoutEffect(()=>{try{let l=sessionStorage.getItem(t||ae);l&&(G=JSON.parse(l))}catch{}},[t]),h.useLayoutEffect(()=>{let l=r?.enableScrollRestoration(G,()=>window.scrollY,e?(c,d)=>ne(c,d,o,e):void 0);return()=>l&&l()},[r,o,e]),h.useLayoutEffect(()=>{if(n!==!1){if(typeof n=="number"){window.scrollTo(0,n);return}try{if(i.hash){let l=document.getElementById(decodeURIComponent(i.hash.slice(1)));if(l){l.scrollIntoView();return}}}catch{L(!1,`"${i.hash.slice(1)}" is not a decodable element ID. The view will not scroll to it.`)}a!==!0&&window.scrollTo(0,0)}},[i,n,a]))}function dr(e,t){let{capture:r}=t||{};h.useEffect(()=>{let n=r!=null?{capture:r}:void 0;return window.addEventListener("pagehide",e,n),()=>{window.removeEventListener("pagehide",e,n)}},[e,r])}function qe(e,{relative:t}={}){let r=h.useContext(ie);b(r!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:n}=pe("useViewTransitionState"),a=j(e,{relative:t});if(!r.isTransitioning)return!1;let o=N(r.currentLocation.pathname,n)||r.currentLocation.pathname,i=N(r.nextLocation.pathname,n)||r.nextLocation.pathname;return W(a.pathname,i)!=null||W(a.pathname,o)!=null}function fr(){return tt(),null}function tt({disabled:e=!1}={}){let{hash:t}=D(),r=Re();ve(()=>{if(e||!t)return;let n=t.replace(/^#/,""),a=[n];try{let i=window.decodeURIComponent(n);i&&i!==n&&a.push(i)}catch{}let o=0;return o=window.requestAnimationFrame(()=>{(document.getElementById(a[0]??"")??document.getElementById(a[1]??""))?.scrollIntoView({behavior:r})}),()=>{window.cancelAnimationFrame(o)}},[t,e,r])}export{fr as AutoScrollToHash,tt as useAutoScrollToHash};
4
+ /*! Bundled license information:
5
+
6
+ react-router/dist/development/chunk-NISHYRIK.mjs:
7
+ react-router/dist/development/index.mjs:
8
+ (**
9
+ * react-router v7.9.3
10
+ *
11
+ * Copyright (c) Remix Software Inc.
12
+ *
13
+ * This source code is licensed under the MIT license found in the
14
+ * LICENSE.md file in the root directory of this source tree.
15
+ *
16
+ * @license MIT
17
+ *)
18
+ */
19
+ //# sourceMappingURL=auto-scroll-to-hash.js.map