{"version":3,"file":"ScrollReset.C5NaZvMx.mjs","names":[],"sources":["https:/framerusercontent.com/modules/xNv2xxvZ2CIftjSc5uej/iAM7DIZayXc8zimGUOFy/ScrollReset.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{forwardRef,useEffect}from\"react\";let instanceCount=0;let originalPushState=null;let originalReplaceState=null;let patchedPushState=null;let patchedReplaceState=null;let previousScrollRestoration=null;let resetVersion=0;let cancelPendingReset=null;function resetScroll(){if(typeof window===\"undefined\")return;const version=++resetVersion;cancelPendingReset?.();let cancelled=false;const timers=[];const cancelEvents=[\"wheel\",\"touchstart\",\"pointerdown\",\"keydown\"];const apply=()=>{if(cancelled||version!==resetVersion)return;window.scrollTo({top:0,left:0,behavior:\"auto\"});document.documentElement.scrollTop=0;document.body.scrollTop=0;};const cleanup=()=>{if(cancelled)return;cancelled=true;timers.forEach(timer=>window.clearTimeout(timer));cancelEvents.forEach(eventName=>window.removeEventListener(eventName,cleanup));if(cancelPendingReset===cleanup)cancelPendingReset=null;};cancelEvents.forEach(eventName=>window.addEventListener(eventName,cleanup,{once:true,passive:true}));apply();requestAnimationFrame(()=>{apply();requestAnimationFrame(apply);});[80,180,350,650].forEach((delay,index,delays)=>{timers.push(window.setTimeout(()=>{apply();if(index===delays.length-1)cleanup();},delay));});cancelPendingReset=cleanup;}function mountSingleton(){instanceCount++;if(instanceCount>1||typeof window===\"undefined\")return;previousScrollRestoration=window.history.scrollRestoration;window.history.scrollRestoration=\"manual\";originalPushState=window.history.pushState;originalReplaceState=window.history.replaceState;patchedPushState=function(...args){originalPushState.apply(window.history,args);resetScroll();};patchedReplaceState=function(...args){originalReplaceState.apply(window.history,args);resetScroll();};window.history.pushState=patchedPushState;window.history.replaceState=patchedReplaceState;window.addEventListener(\"popstate\",resetScroll);window.addEventListener(\"pageshow\",resetScroll);}function unmountSingleton(){instanceCount--;if(instanceCount>0||typeof window===\"undefined\")return;instanceCount=0;cancelPendingReset?.();window.removeEventListener(\"popstate\",resetScroll);window.removeEventListener(\"pageshow\",resetScroll);if(originalPushState&&patchedPushState&&window.history.pushState===patchedPushState){window.history.pushState=originalPushState;}if(originalReplaceState&&patchedReplaceState&&window.history.replaceState===patchedReplaceState){window.history.replaceState=originalReplaceState;}if(previousScrollRestoration){window.history.scrollRestoration=previousScrollRestoration;}originalPushState=null;originalReplaceState=null;patchedPushState=null;patchedReplaceState=null;previousScrollRestoration=null;}export function withScrollReset(Component){return /*#__PURE__*/forwardRef(function WithScrollReset(props,ref){useEffect(()=>{if(typeof window===\"undefined\")return;mountSingleton();resetScroll();return()=>unmountSingleton();},[]);return /*#__PURE__*/_jsx(Component,{ref:ref,...props});});}\nexport const __FramerMetadata__ = {\"exports\":{\"withScrollReset\":{\"type\":\"reactHoc\",\"name\":\"withScrollReset\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./ScrollReset.map"],"mappings":"uIAAyS,SAAS,GAAa,CAAC,GAAU,IAAS,OAAY,OAAO,IAAM,EAAQ,EAAE,EAAa,IAAqB,EAAE,IAAI,EAAU,GAAY,EAAO,CAAC,EAAQ,EAAa,CAAC,QAAQ,aAAa,cAAc,SAAS,EAAQ,MAAU,CAAI,GAAW,IAAU,IAAoB,EAAO,SAAS,CAAC,IAAI,EAAE,KAAK,EAAE,SAAS,MAAM,CAAC,EAAE,SAAS,gBAAgB,UAAU,EAAE,SAAS,KAAK,UAAU,EAAE,EAAQ,MAAY,CAAI,IAAiB,EAAU,GAAK,EAAO,QAAQ,GAAO,EAAO,aAAa,CAAK,CAAC,EAAE,EAAa,QAAQ,GAAW,EAAO,oBAAoB,EAAU,CAAO,CAAC,EAAK,IAAqB,IAAQ,EAAmB,MAAK,EAAE,EAAa,QAAQ,GAAW,EAAO,iBAAiB,EAAU,EAAQ,CAAC,KAAK,GAAK,QAAQ,EAAI,CAAC,CAAC,EAAE,EAAM,EAAE,0BAA0B,CAAC,EAAM,EAAE,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