import{j as b}from"./jsx-runtime-C4_65a1U.js";import{r as f}from"./index-B9zr-vzA.js";import{k as S,u as m}from"./chunk-JZWAC4HX-5kJHQiQ9.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};t.SENTRY_RELEASE={id:"8a6db0ac5fe78363b0c97fe458a96ce773bf357c"};var a=new t.Error().stack;a&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[a]="2319aae9-788b-4b9f-8e41-47e7b9cb8ae9",t._sentryDebugIdIdentifier="sentry-dbid-2319aae9-788b-4b9f-8e41-47e7b9cb8ae9")}catch{}})();const w={vertical:"scrollTop",horizontal:"scrollLeft"};function v({elementQuery:t,direction:a="vertical",...d}){const r=`position:${t}`,p=S(),u=m(),l=w[a],i=f.useCallback(()=>{const e=document.querySelector(t);if(!e)return;let o={};try{const s=JSON.parse(sessionStorage.getItem(r)||"{}");typeof s=="object"&&s!==null&&(o=s)}catch(s){console.warn("Error parsing scroll positions from sessionStorage:",s)}const n={...o,[u.key]:e[l]};sessionStorage.setItem(r,JSON.stringify(n))},[r,t,u.key]);f.useEffect(()=>{if(p.state==="idle"){const e=document.querySelector(t);if(!e)return;try{const n=JSON.parse(sessionStorage.getItem(r)||"{}")[window.history.state.key];typeof n=="number"&&(e[l]=n)}catch(o){console.error(o),sessionStorage.removeItem(r)}}else i()},[r,t,p.state,i]),f.useEffect(()=>(window.addEventListener("pagehide",i),()=>{window.removeEventListener("pagehide",i)}),[i]);function y(e,o,n){const s=document.querySelector(o);if(!s){console.warn(`Element not found: ${o}. Cannot restore scroll.`);return}if(!window.history.state||!window.history.state.key){const c=Math.random().toString(32).slice(2);window.history.replaceState({key:c},"")}try{const g=JSON.parse(sessionStorage.getItem(e)||"{}")[window.history.state.key];typeof g=="number"&&(s[n]=g)}catch(c){console.error(c),sessionStorage.removeItem(e)}}return b.jsx("script",{...d,suppressHydrationWarning:!0,dangerouslySetInnerHTML:{__html:`(${y})(${JSON.stringify(r)}, ${JSON.stringify(t)}, ${JSON.stringify(l)})`}})}export{v as E};
//# sourceMappingURL=index-zkt0glVO.js.map
