const PAGE_WRAPPER_SELECTOR=".page-wrapper",SQUEEZE_QUERY=window.matchMedia("(min-width: 990px)");function getScrollContainer(){return SQUEEZE_QUERY.matches?document.querySelector(PAGE_WRAPPER_SELECTOR)??document.scrollingElement??document.documentElement:document.scrollingElement??document.documentElement}function getScrollTop(){return getScrollContainer().scrollTop}function scrollTo(options){getScrollContainer().scrollTo(options)}SQUEEZE_QUERY.matches&&(history.scrollRestoration="manual"),SQUEEZE_QUERY.addEventListener("change",()=>{history.scrollRestoration=SQUEEZE_QUERY.matches?"manual":"auto"});function saveScrollPosition(){try{const currentState=typeof history.state=="object"&&history.state!==null?history.state:{};history.replaceState({...currentState,scrollTop:getScrollContainer().scrollTop},"")}catch{}}window.addEventListener("pagehide",saveScrollPosition);function restoreSavedScrollTop(savedScrollTop){if(!Number.isFinite(savedScrollTop)||savedScrollTop<0)return;const container=getScrollContainer(),maxScrollTop=Math.max(0,container.scrollHeight-container.clientHeight),targetScrollTop=Math.min(savedScrollTop,maxScrollTop);container.scrollTo({top:targetScrollTop,behavior:"instant"})}window.addEventListener("pageshow",()=>{const scrollTop=history.state?.scrollTop;scrollTop!=null&&requestAnimationFrame(()=>{restoreSavedScrollTop(scrollTop)})});const originalPushState=history.pushState.bind(history);history.pushState=function(state,title,url){saveScrollPosition(),originalPushState(state,title,url)},window.addEventListener("popstate",()=>{const scrollTop=history.state?.scrollTop;scrollTop!=null&&requestAnimationFrame(()=>{restoreSavedScrollTop(scrollTop)})});function getScrollEventTarget(){return SQUEEZE_QUERY.matches?document.querySelector(PAGE_WRAPPER_SELECTOR)??document:document}function getIntersectionRoot(){return SQUEEZE_QUERY.matches?document.querySelector(PAGE_WRAPPER_SELECTOR)??null:null}export{getScrollContainer,getScrollTop,scrollTo,getScrollEventTarget,getIntersectionRoot,SQUEEZE_QUERY as scrollContainerMediaQuery};
//# sourceMappingURL=/s/files/1/0677/1399/0759/t/1/assets/scroll-container.js.map?v=1783078800
