{"version":3,"file":"SmartSticky.CIJbn2uM.mjs","names":["useRef","useEffect","_jsxs","_jsx","__esmMin","init_ssg_sandbox_shims","init_npm_react_18_3_1","window","de","init_jsx_runtime","c","p","ce","SmartSticky","Component","props","markerRef","state","TOP_OFFSET","marker","el","update","scrollY","vh","elHeight","delta","BOTTOM_OFFSET","minTop","newTop","init_SmartSticky"],"sources":["https:/framerusercontent.com/modules/4IK698u16poZ91ZbzI0F/byAOzitkpuhC7vmqbnxb/SmartSticky.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useEffect,useRef}from\"react\";/**\n * SmartSticky override\n * Apply to the RightSidebar node on the /tools/:slug page.\n *\n * Behaviour:\n * - Sidebar shorter than viewport → sticks at top (normal sticky)\n * - Sidebar taller than viewport → scrolls down until its bottom hits\n *   the viewport bottom minus BOTTOM_OFFSET, then locks.\n *   Scrolls back up when you reverse.\n */const TOP_OFFSET=100// px from top — match your nav height\n;const BOTTOM_OFFSET=32// px gap from bottom of viewport\n;export function SmartSticky(Component){return function SmartStickyComponent(props){const markerRef=useRef(null);const state=useRef({lastY:0,top:TOP_OFFSET});useEffect(()=>{state.current.lastY=window.scrollY;const marker=markerRef.current;if(!marker)return;const el=marker.parentElement;if(!el)return;el.style.position=\"sticky\";el.style.top=`${TOP_OFFSET}px`;el.style.alignSelf=\"flex-start\";el.style.height=\"fit-content\";const update=()=>{const scrollY=window.scrollY;const vh=window.innerHeight;const elHeight=el.offsetHeight;const delta=scrollY-state.current.lastY;if(elHeight+TOP_OFFSET+BOTTOM_OFFSET<=vh){// Fits in viewport — always stick at top offset\nel.style.top=`${TOP_OFFSET}px`;}else{// Taller than viewport — track with bottom gap\nconst minTop=vh-elHeight-BOTTOM_OFFSET;let newTop=state.current.top;if(delta>0){// Scrolling down — shift top up until bottom hits viewport minus gap\nnewTop=Math.max(minTop,newTop-delta);}else{// Scrolling up — shift top down until it hits TOP_OFFSET\nnewTop=Math.min(TOP_OFFSET,newTop-delta);}state.current.top=newTop;el.style.top=`${newTop}px`;}state.current.lastY=scrollY;};window.addEventListener(\"scroll\",update,{passive:true});return()=>window.removeEventListener(\"scroll\",update);},[]);return /*#__PURE__*/_jsxs(Component,{...props,children:[props.children,/*#__PURE__*/_jsx(\"div\",{ref:markerRef,style:{position:\"absolute\",width:0,height:0,pointerEvents:\"none\",visibility:\"hidden\",overflow:\"hidden\"}})]});};}\nexport const __FramerMetadata__ = {\"exports\":{\"SmartSticky\":{\"type\":\"reactHoc\",\"name\":\"SmartSticky\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./SmartSticky.map"],"mappings":"A,8IAWC,SAAgBa,EAAYC,EAAU,CAAC,OAAO,SAA8BC,EAAM,CAAC,IAAMC,EAAUhB,EAAO,IAAI,EAAQiB,EAAMjB,EAAO,CAAC,MAAM,EAAE,IAAIkB,CAAU,CAAC,EAIqF,OAJnFjB,MAAc,CAACgB,EAAM,QAAQ,MAAMV,EAAO,QAAQ,IAAMY,EAAOH,EAAU,QAAQ,GAAG,CAACG,EAAO,OAAO,IAAMC,EAAGD,EAAO,cAAc,GAAG,CAACC,EAAG,OAAOA,EAAG,MAAM,SAAS,SAASA,EAAG,MAAM,IAAI,GAAGF,EAAW,IAAIE,EAAG,MAAM,UAAU,aAAaA,EAAG,MAAM,OAAO,cAAc,IAAMC,MAAW,CAAC,IAAMC,EAAQf,EAAO,QAAcgB,EAAGhB,EAAO,YAAkBiB,EAASJ,EAAG,aAAmBK,EAAMH,EAAQL,EAAM,QAAQ,MAAM,GAAGO,EAASN,EAAWQ,GAAeH,EAC7lBH,EAAG,MAAM,IAAI,GAAGF,EAAW,QAAS,CACpC,IAAMS,EAAOJ,EAAGC,EAASE,EAAkBE,EAAOX,EAAM,QAAQ,IAEhEW,EAFuEH,EAAM,EACtE,KAAK,IAAIE,EAAOC,EAAOH,CAAK,EAC5B,KAAK,IAAIP,EAAWU,EAAOH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