{"version":3,"file":"StickyRailOverride.C8dbYcf4.mjs","names":["useRef","useState","useCallback"],"sources":["https:/framerusercontent.com/modules/7SnZFLzPEdj1e6UsvBjc/iRSNajSARduEZIAqOYg9/StickyRailOverride.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useCallback,useEffect,useLayoutEffect,useRef,useState}from\"react\";/**\n * Pins the product rail the way `position: sticky` would, but bounded by the\n * VIEWPORT rather than by a parent.\n *\n * CSS sticky cannot leave its containing block. On the shop detail page the\n * rail's column ends ~2000px before the section it is meant to reach, and every\n * section also carries `overflow: clip`. Fixed positioning sidesteps both. No\n * ancestor here sets `transform` / `filter` / `will-change`, which would\n * otherwise become the containing block and re-trap it.\n *\n * No placeholder is needed: the rail's column is `height: 1fr` in a horizontal\n * stack, so its height comes from the buy column beside it and does not\n * collapse when the rail leaves the flow.\n */const TOP_OFFSET=120;const STOP_ELEMENT_ID=\"related-products\";const STOP_GAP=48;// Breathing room kept below a rail that is too tall to sit at TOP_OFFSET.\nconst BOTTOM_GAP=24;// Below this the product grid stacks vertically and the rail's column becomes\n// `height: auto` — pinning there would collapse the column and pin a card over\n// most of the screen. Tablet (810) and Desktop (1200) keep the two-column grid.\nconst MIN_WIDTH=810;/** Shop detail page: the related-products section, by id. */function stopAtRelatedProducts(){const element=document.getElementById(STOP_ELEMENT_ID);return element?{top:element.getBoundingClientRect().top,element}:null;}/*\n * Dark product pages (/solutions/buuz, /solutions/nt-vrl). Every section is a\n * direct child of the \"Shell\" frame, and the sections after the rail's own\n * keep its column empty with a spacer: \"Rail Spacer\" in the two-column rows,\n * \"Space\" at the left of the image banners. The rail rides over all of those\n * to the end of the last section and stops flush with its content, the way\n * CSS sticky ends at the bottom of its container. A section that does not\n * keep the column free stops it earlier.\n */const SHELL_NAME=\"Shell\";const RAIL_KEEPERS='[data-framer-name=\"Rail Spacer\"], [data-framer-name=\"Space\"]';function sectionOf(element){let node=element;while(node&&node.parentElement){if(node.parentElement.getAttribute(\"data-framer-name\")===SHELL_NAME)return node;node=node.parentElement;}return null;}// The banners' \"Space\" sits 4px inside the rail column (124 to 544 against\n// 120 to 540 at 1440), so the edges only have to line up within a few pixels.\nconst RAIL_SLACK=12;function keepsRailFree(section,rail){for(const spacer of Array.from(section.querySelectorAll(RAIL_KEEPERS))){const r=spacer.getBoundingClientRect();// A spacer narrower than the rail (BUUZ \"Details 3\" is 360px against\n// a 420px rail) would put the card on top of that row's content.\nif(r.width>0&&r.left<=rail.left+RAIL_SLACK&&r.right>=rail.right-RAIL_SLACK)return true;}return false;}function stopAtFirstFullSection(holder){const column=holder.parentElement;const section=sectionOf(holder);if(!column||!section||!section.parentElement)return null;const rail=column.getBoundingClientRect();let last=section;for(let next=section.nextElementSibling;next;next=next.nextElementSibling){const rect=next.getBoundingClientRect();// Hidden at this breakpoint: it measures 0 and would stop the rail\n// at the top of the viewport.\nif(rect.height===0)continue;if(!keepsRailFree(next,rail))return{top:rect.top,element:next};last=next;}// The section's \"Container\" ends where its content does; the section\n// itself carries the bottom padding.\nconst container=Array.from(last.children).find(child=>child.getAttribute(\"data-framer-name\")===\"Container\");const end=(container??last).getBoundingClientRect().bottom;return{top:end,element:section.parentElement,gap:0};}function samePin(a,b){if(a===b)return true;if(!a||!b)return false;if(a.absolute!==b.absolute)return false;if(a.absolute&&b.absolute)return a.top===b.top;if(!a.absolute&&!b.absolute)return a.top===b.top&&a.left===b.left&&a.width===b.width;return false;}export function withStickyRail(Component){return stickyRail(Component,stopAtRelatedProducts);}/** The same pin, for the BUUZ and NT-VRL product cards. */export function withStickyRailToFullSection(Component){return stickyRail(Component,stopAtFirstFullSection);}function stickyRail(Component,findStop){return props=>{const holderRef=useRef(null);const pinRef=useRef(null);const[pin,setPin]=useState(null);// Re-rendering on every scroll with an equal value is what produced the\n// second, smaller correction right after the first one.\nconst commit=useCallback(value=>{if(samePin(pinRef.current,value))return;pinRef.current=value;setPin(value);},[]);const measure=useCallback(()=>{const holder=holderRef.current;const column=holder?.parentElement;if(!holder||!column)return;if(window.innerWidth<MIN_WIDTH){commit(null);return;}const columnRect=column.getBoundingClientRect();// Still above the pin point — hand the rail back to normal flow.\nif(columnRect.top>TOP_OFFSET){commit(null);return;}const rail=holder.firstElementChild;const railHeight=rail?rail.offsetHeight:holder.offsetHeight;if(!railHeight)return;// A rail taller than the viewport cannot sit at TOP_OFFSET: it is\n// `fixed`, so whatever falls below the fold never scrolls into\n// reach. The Card face is ~690px, which already overflows a 13\"\n// laptop at TOP_OFFSET. Anchor those to the BOTTOM instead, so the\n// order button and bundle banner stay reachable; the top is simply\n// clipped by the navbar, which is the lesser loss.\nconst available=window.innerHeight-TOP_OFFSET-BOTTOM_GAP;const anchorTop=railHeight>available?window.innerHeight-BOTTOM_GAP-railHeight:TOP_OFFSET;// Once the stop section arrives, stop holding the rail against the\n// viewport and park it in the document instead. Every term below is\n// a document coordinate, so the value does not change as the user\n// keeps scrolling — no per-frame correction, and no bounce.\nconst stop=findStop(holder);if(stop){const stopTop=stop.top;const gap=stop.gap??STOP_GAP;if(stopTop-gap<anchorTop+railHeight){// The holder is `position: static`, so its offsetParent is\n// the same containing block the pinned rail will resolve\n// against.\nconst base=holder.offsetParent;const baseTop=base?base.getBoundingClientRect().top+window.scrollY:0;const restTop=stopTop+window.scrollY-gap-railHeight;commit({absolute:true,top:restTop-baseTop});return;}}commit({absolute:false,left:columnRect.left,width:columnRect.width,top:anchorTop});},[commit]);// Measure straight from the event rather than deferring to\n// requestAnimationFrame. Passive scroll already fires at most once per\n// frame, `measure` is two getBoundingClientRect calls, and going\n// through rAF makes the pin invisible wherever rAF is throttled.\nconst schedule=useCallback(()=>{measure();},[measure]);useLayoutEffect(()=>{if(typeof window===\"undefined\")return;measure();window.addEventListener(\"scroll\",schedule,{passive:true});window.addEventListener(\"resize\",schedule);// Late images and webfonts reflow the page after mount, and a\n// back-navigation restores this page from the bfcache without\n// firing either of the two above.\nwindow.addEventListener(\"load\",schedule);window.addEventListener(\"pageshow\",schedule);return()=>{window.removeEventListener(\"scroll\",schedule);window.removeEventListener(\"resize\",schedule);window.removeEventListener(\"load\",schedule);window.removeEventListener(\"pageshow\",schedule);};},[measure,schedule]);// The rail changes height when it swaps face, and the column beside it\n// reflows — re-measure instead of trusting the first read.\nuseEffect(()=>{if(typeof ResizeObserver===\"undefined\")return;const observer=new ResizeObserver(schedule);const holder=holderRef.current;if(holder){observer.observe(holder);if(holder.parentElement)observer.observe(holder.parentElement);if(holder.firstElementChild)observer.observe(holder.firstElementChild);}// The parked offset is a DOCUMENT coordinate derived from where the\n// stop section sits, and it is only recomputed on scroll or resize.\n// Anything else that reflows the page above it — a late image, the\n// async related-products catalog, a font swap — moves that section\n// without firing either event, so the rail keeps a stale offset.\n// Measured: shifting the content above by 400px left the parked\n// rail 352px INSIDE the related-products grid, and a single scroll\n// event healed it — which is why it only ever survives as a\n// screenshot and never reproduces by hand. Watching the document\n// and the stop section closes that window.\nconst stop=holder?findStop(holder):null;if(stop)observer.observe(stop.element);if(document.body)observer.observe(document.body);return()=>observer.disconnect();},[schedule]);return /*#__PURE__*/_jsx(\"div\",{ref:holderRef,style:{width:\"100%\",// Never let the holder itself box the pinned rail in.\nposition:\"static\"},children:/*#__PURE__*/_jsx(Component,{...props,style:{...props.style,...pin===null?{position:\"relative\"}:pin.absolute?{position:\"absolute\",left:0,width:\"100%\",top:pin.top,zIndex:1}:{position:\"fixed\",left:pin.left,width:pin.width,top:pin.top,zIndex:1}}})});};}\nexport const __FramerMetadata__ = {\"exports\":{\"withStickyRail\":{\"type\":\"reactHoc\",\"name\":\"withStickyRail\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withStickyRailToFullSection\":{\"type\":\"reactHoc\",\"name\":\"withStickyRailToFullSection\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./StickyRailOverride.map"],"mappings":"4JAiBiF,SAAS,GAAuB,CAAC,IAAM,EAAQ,SAAS,eAAe,CAAe,E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