{"version":3,"file":"ScrollToSection.BTdZhu_3.mjs","names":["forwardRef","useEffect","_jsx","__esmMin","init_npm_react_18_3_1","init_ssg_sandbox_shims","window","c","J","init_jsx_runtime","ce","isVisible","el","r","cs","findSection","id","layerName","scrollParent","p","oy","stickyHeaderBottom","bottom","xs","x","pos","blockRect","section","rects","k","top","scrollToSectionCentred","container","viewTop","viewBottom","header","visible","block","offset","MIN_GAP","behavior","withScrollToTeam","Component","props","ref","onClick","scrollToSectionTop","gap","withScrollToVideoWork","timers","ms","t","init_ScrollToSection"],"sources":["https:/framerusercontent.com/modules/Gz5XcrcQUah6W8d3rPpi/gIm2MS1iMN8ZPEM2pf2T/ScrollToSection.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{forwardRef,useEffect}from\"react\";/**\n * Scroll overrides\n *\n * withScrollToTeam: apply to the \"Meet the team\" link on /about-us.\n * Smoothly scrolls so the team block (eyebrow, photos, names and titles)\n * sits centred in the space below the sticky header. If the block is taller\n * than that space, it is placed just under the header instead.\n *\n * Robust to Framer specifics:\n * - listens for the click at document level (capture phase), so it works\n *   even if the text link doesn't pass extra props to the DOM\n * - ignores hidden copies of the section (other breakpoints)\n * - scrolls whichever element actually scrolls (window or a container)\n */const MIN_GAP=24;function isVisible(el){const r=el.getBoundingClientRect();if(r.width===0&&r.height===0)return false;const cs=getComputedStyle(el);return cs.display!==\"none\"&&cs.visibility!==\"hidden\";}function findSection(id,layerName){const candidates=[...Array.from(document.querySelectorAll(`[id=\"${id}\"]`)),...Array.from(document.querySelectorAll(`[data-framer-name=\"${layerName}\"]`))];return candidates.find(isVisible)||null;}function scrollParent(el){let p=el.parentElement;while(p&&p!==document.body&&p!==document.documentElement){const oy=getComputedStyle(p).overflowY;if((oy===\"auto\"||oy===\"scroll\"||oy===\"overlay\")&&p.scrollHeight>p.clientHeight+1)return p;p=p.parentElement;}return null// the window scrolls\n;}function stickyHeaderBottom(){let bottom=0;const xs=[window.innerWidth*.5,20,window.innerWidth-20];for(const x of xs){let el=document.elementFromPoint(x,2);while(el&&el!==document.body&&el!==document.documentElement){const pos=getComputedStyle(el).position;if(pos===\"fixed\"||pos===\"sticky\"){const r=el.getBoundingClientRect();if(r.top<=2&&r.height<window.innerHeight*.5)bottom=Math.max(bottom,r.bottom);break;}el=el.parentElement;}}return bottom;}function blockRect(section){const kids=Array.from(section.children).filter(isVisible);const rects=kids.map(k=>k.getBoundingClientRect());if(!rects.length){const r=section.getBoundingClientRect();return{top:r.top,height:r.height};}const top=Math.min(...rects.map(r=>r.top));const bottom=Math.max(...rects.map(r=>r.bottom));return{top,height:bottom-top};}export function scrollToSectionCentred(id,layerName){if(typeof window===\"undefined\")return false;const section=findSection(id,layerName);if(!section)return false;const container=scrollParent(section);const viewTop=container?Math.max(0,container.getBoundingClientRect().top):0;const viewBottom=container?Math.min(window.innerHeight,container.getBoundingClientRect().bottom):window.innerHeight;const header=Math.max(viewTop,stickyHeaderBottom());const visible=viewBottom-header;const block=blockRect(section);const offset=block.height+MIN_GAP*2<=visible?block.top-header-(visible-block.height)/2:block.top-header-MIN_GAP;const reduce=window.matchMedia?.(\"(prefers-reduced-motion: reduce)\").matches;const behavior=reduce?\"auto\":\"smooth\";if(container)container.scrollTo({top:Math.max(0,container.scrollTop+offset),behavior});else window.scrollTo({top:Math.max(0,window.scrollY+offset),behavior});return true;}export function withScrollToTeam(Component){return /*#__PURE__*/forwardRef((props,ref)=>{useEffect(()=>{if(typeof document===\"undefined\")return;const onClick=e=>{const target=e.target;const link=target?.closest?.('a[href*=\"#team\"]');if(!link)return;if(scrollToSectionCentred(\"team\",\"Team\")){e.preventDefault();e.stopPropagation();}};document.addEventListener(\"click\",onClick,true);return()=>document.removeEventListener(\"click\",onClick,true);},[]);return /*#__PURE__*/_jsx(Component,{ref:ref,...props});});}/**\n * scrollToSectionTop: scroll so the section's top sits a small gap below the\n * sticky header (used for \"Selected work\" on /projects).\n */export function scrollToSectionTop(id,layerName,gap=24){if(typeof window===\"undefined\")return false;const section=findSection(id,layerName);if(!section)return false;const container=scrollParent(section);const viewTop=container?Math.max(0,container.getBoundingClientRect().top):0;const header=Math.max(viewTop,stickyHeaderBottom());const offset=blockRect(section).top-header-gap;const reduce=window.matchMedia?.(\"(prefers-reduced-motion: reduce)\").matches;const behavior=reduce?\"auto\":\"smooth\";if(container)container.scrollTo({top:Math.max(0,container.scrollTop+offset),behavior});else window.scrollTo({top:Math.max(0,window.scrollY+offset),behavior});return true;}/**\n * withScrollToVideoWork: apply to the VIDEO button on /projects.\n * Clicking any \"#video-work\" link on the page scrolls \"Selected work\" to just\n * under the sticky header. Also handles arriving on /projects#video-work from\n * another page (Framer would otherwise jump to a hidden breakpoint copy).\n */export function withScrollToVideoWork(Component){return /*#__PURE__*/forwardRef((props,ref)=>{useEffect(()=>{if(typeof document===\"undefined\")return;const onClick=e=>{const target=e.target;const link=target?.closest?.('a[href*=\"#video-work\"]');if(!link)return;if(scrollToSectionTop(\"video-work\",\"Section Header\")){e.preventDefault();e.stopPropagation();history.replaceState(null,\"\",\"#video-work\");}};document.addEventListener(\"click\",onClick,true);let timers=[];if(window.location.hash===\"#video-work\"){// wait for images and layout to settle, then line it up (twice, in case the grid grows)\ntimers=[300,900].map(ms=>window.setTimeout(()=>scrollToSectionTop(\"video-work\",\"Section Header\"),ms));}return()=>{document.removeEventListener(\"click\",onClick,true);timers.forEach(t=>window.clearTimeout(t));};},[]);return /*#__PURE__*/_jsx(Component,{ref:ref,...props});});}\nexport const __FramerMetadata__ = {\"exports\":{\"scrollToSectionCentred\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"scrollToSectionTop\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withScrollToVideoWork\":{\"type\":\"reactHoc\",\"name\":\"withScrollToVideoWork\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withScrollToTeam\":{\"type\":\"reactHoc\",\"name\":\"withScrollToTeam\",\"annotations\":{\"framerContractVersion\":\"1\"}},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