import{useLocation as i,useNavigate as r}from"react-router-dom";import{useEffect as s,useRef as u}from"react";import{useActiveSectionId as f}from"@redocly/theme/core/hooks";import{isBrowser as h}from"../../../utils/env/is-browser";let n=!0;function v(){const t=i(),o=r(),e=f(t,!1,!1),a=u(null);s(()=>{if(e&&n){n=!1,a.current=e;return}const c=a.current!==e;h()&&e&&!t.hash&&c&&!window.location.pathname.includes(e)&&o({pathname:t.pathname,search:t.search,hash:`#${e}`},{replace:!0}),a.current=e},[e,t.pathname,t.search,t.hash,o])}export{v as useAutoScroll};
