{"version":3,"file":"StickToCenteredContent.WnestBd8.mjs","names":["useRef"],"sources":["https:/framerusercontent.com/modules/v4Fv3haDrGJyrKWFtGkE/uxJMY6L43PkWQXEuLvZC/StickToCenteredContent.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect,useRef}from\"react\";import{addPropertyControls,ControlType}from\"framer\";function isVisibleBox(el){if(!(el instanceof HTMLElement))return false;const rect=el.getBoundingClientRect();return rect.width>1&&rect.height>1;}function findWrapperAndContent(start){let node=start;for(let i=0;i<16&&node;i++){const parentEl=node.parentElement;if(!parentEl)break;const kids=[];for(const child of Array.from(parentEl.children)){if(isVisibleBox(child))kids.push(child);}if(kids.length>=2){const others=kids.filter(child=>child!==node);others.sort((a,b)=>b.getBoundingClientRect().width-a.getBoundingClientRect().width);const content=others[0];const wrapperWidth=node.getBoundingClientRect().width;const contentWidth=content?.getBoundingClientRect().width??0;if(content&&contentWidth>wrapperWidth){return{wrapper:node,content,parent:parentEl};}}node=parentEl;}return null;}export default function StickToCenteredContent(props){const{gap=40}=props;const ref=useRef(null);useEffect(()=>{if(typeof window===\"undefined\")return;const el=ref.current;if(!el)return;const apply=()=>{const found=findWrapperAndContent(el);if(!found)return;const{wrapper,content,parent}=found;const parentRect=parent.getBoundingClientRect();const contentRect=content.getBoundingClientRect();const tocWidth=wrapper.getBoundingClientRect().width;const left=Math.max(0,Math.round(contentRect.left-parentRect.left-tocWidth-gap));wrapper.style.setProperty(\"position\",\"absolute\",\"important\");wrapper.style.setProperty(\"left\",`${left}px`,\"important\");wrapper.style.setProperty(\"right\",\"auto\",\"important\");wrapper.style.setProperty(\"top\",\"0px\",\"important\");wrapper.style.setProperty(\"height\",\"100%\",\"important\");};apply();window.requestAnimationFrame(apply);const observer=new ResizeObserver(()=>{apply();window.requestAnimationFrame(apply);});observer.observe(document.documentElement);const found=findWrapperAndContent(el);if(found){observer.observe(found.parent);observer.observe(found.content);}window.addEventListener(\"resize\",apply);return()=>{observer.disconnect();window.removeEventListener(\"resize\",apply);};},[gap]);return /*#__PURE__*/_jsx(\"div\",{ref:ref,\"aria-hidden\":\"true\",style:{width:1,height:1,overflow:\"hidden\",pointerEvents:\"none\",opacity:0,position:\"absolute\"}});}addPropertyControls(StickToCenteredContent,{gap:{type:ControlType.Number,title:\"Gap\",defaultValue:40,min:0,max:80,step:2}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"StickToCenteredContent\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./StickToCenteredContent.map"],"mappings":"+LAAmI,SAAS,EAAa,EAAG,CAAC,GAAG,EAAE,aAAc,aAAa,MAAO,GAAM,IAAM,EAAK,EAAG,sBAAsB,EAAE,OAAO,EAAK,MAAM,GAAG,EAAK,OAAO,CAAE,CAAC,SAAS,EAAsB,EAAM,CAAC,IAAI,EAAK,EAAM,IAAI,IAAI,EAAE,EAAE,EAAE,IAAI,EAAK,IAAI,CAAC,IAAM,EAAS,EAAK,cAAc,GAAG,CAAC,EAAS,MAAM,IAAM,EAAK,CAAC,EAAE,IAAI,IAAM,KAAS,MAAM,KAAK,EAAS,QAAQ,EAAM,EAAa,CAAK,GAAE,EAAK,KAAK,CAAK,EAAG,GAAG,EAAK,QAAQ,EAAE,CAAC,IAAM,EAAO,EAAK,OAAO,GAAO,IAAQ,CAAI,EAAE,EAAO,MAAM,EAAE,IAAI,EAAE,sBAAsB,CAAC,CAAC,MAAM,EAAE,sBAAsB,CAAC,CAAC,KAAK,EAAE,IAAM,EAAQ,EAAO,GAAS,EAAa,EAAK,sBAAsB,CAAC,CAAC,MAAY,EAAa,GAAS,sBAAsB,CAAC,CAAC,OAAO,EAAE,GAAG,GAAS,EAAa,EAAc,MAAM,CAAC,QAAQ,EAAK,UAAQ,OAAO,CAAQ,CAAG,CAAC,EAAK,CAAS,CAAC,OAAO,IAAK,CAAC,SAAwB,EAAu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