{"version":3,"file":"SmoothScroll_Prod.R1xsaIL6.mjs","names":["useRef"],"sources":["https:/framerusercontent.com/modules/Yppqt3Cs3Y8TZqvASnXl/PGrowqBrgWCViHduGfsA/SmoothScroll_Prod.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{addPropertyControls,ControlType,withCSS}from\"framer\";import Lenis from\"lenis\";import{useEffect,useRef}from\"react\";function SmoothScrollComponent(props){const{intensity}=props;const lenis=useRef(null);useEffect(()=>{if(lenis.current){try{lenis.current.scrollTo(0,{immediate:true});}catch(error){console.error(\"Error scrolling to top:\",error);}}},[lenis]);// Watch for stop scroll elements\nuseEffect(()=>{const checkForStopScroll=()=>{try{const stopScrollElement=document.querySelector(\"[data-frameruni-stop-scroll]\");const htmlElement=document.documentElement;const hasHiddenOverflow=htmlElement&&htmlElement.style&&htmlElement.style.overflow===\"hidden\";if(lenis.current){if(stopScrollElement||hasHiddenOverflow){lenis.current.stop();}else{lenis.current.start();}}}catch(error){console.error(\"Error in checkForStopScroll:\",error);}};// Initial check\ncheckForStopScroll();// Set up observers\nlet stopScrollObserver;let htmlStyleObserver;try{stopScrollObserver=new MutationObserver(checkForStopScroll);htmlStyleObserver=new MutationObserver(checkForStopScroll);// Observe document for data-frameruni-stop-scroll attribute\nif(document&&document.documentElement){stopScrollObserver.observe(document.documentElement,{childList:true,subtree:true,attributes:true,attributeFilter:[\"data-frameruni-stop-scroll\"]});// Observe only the HTML element for style changes\nhtmlStyleObserver.observe(document.documentElement,{attributes:true,attributeFilter:[\"style\"]});}}catch(error){console.error(\"Error setting up observers:\",error);}return()=>{try{if(stopScrollObserver)stopScrollObserver.disconnect();if(htmlStyleObserver)htmlStyleObserver.disconnect();}catch(error){console.error(\"Error disconnecting observers:\",error);}};},[]);useEffect(()=>{try{if(!document)return;const allElements=document.getElementsByTagName(\"*\");for(let i=0;i<allElements.length;i++){const element=allElements[i];if(!element)continue;try{const computedStyle=window.getComputedStyle(element);if(computedStyle&&computedStyle.getPropertyValue(\"overflow\")===\"auto\"){element.setAttribute(\"data-lenis-prevent\",\"true\");}}catch(styleError){console.error(\"Error getting computed style:\",styleError);}}}catch(error){console.error(\"Error in overflow detection:\",error);}},[]);useEffect(()=>{try{if(typeof Lenis!==\"function\"){console.error(\"Lenis is not available\");return;}lenis.current=new Lenis({duration:(intensity||10)/10});const raf=time=>{if(lenis.current){try{lenis.current.raf(time);requestAnimationFrame(raf);}catch(error){console.error(\"Error in animation frame:\",error);}}};const animationId=requestAnimationFrame(raf);return()=>{cancelAnimationFrame(animationId);if(lenis.current){try{lenis.current.destroy();lenis.current=null;}catch(error){console.error(\"Error destroying Lenis:\",error);}}};}catch(error){console.error(\"Error initializing Lenis:\",error);return()=>{};}},[intensity]);//https://github.com/darkroomengineering/lenis?tab=readme-ov-file#anchor-links\nuseEffect(()=>{try{if(!document||!lenis.current)return;// Get all anchor links and store click handlers with their targets\nconst anchorLinksData=Array.from(document.querySelectorAll(\"a[href]\")||[]).filter(element=>{if(!element)return false;const anchor=element;if(!anchor.href)return false;// Only handle internal anchor links\nconst isInternalLink=anchor.href.startsWith(window.location.origin)||anchor.href.startsWith(\"./\")||anchor.href.startsWith(\"/\");const hasHash=anchor.href.includes(\"#\");return isInternalLink&&hasHash;}).map(anchor=>{try{const anchorElement=anchor;const href=anchorElement.href.includes(\"#\")?`#${anchorElement.href.split(\"#\").pop()}`:\"\";const decodedHref=href?decodeURIComponent(href):\"\";let scrollMargin=0;try{if(decodedHref){const targetElement=document.querySelector(decodedHref);if(targetElement){const marginStyle=window.getComputedStyle(targetElement).scrollMarginTop;scrollMargin=marginStyle?parseInt(marginStyle)||0:0;}}}catch(targetError){console.error(\"Error finding target element:\",targetError);}return{href,scrollMargin,anchorElement:anchorElement};}catch(anchorError){console.error(\"Error processing anchor:\",anchorError);return null;}}).filter(Boolean);const handleClick=(e,href,scrollMargin)=>{try{if(e&&e.preventDefault)e.preventDefault();if(lenis.current&&href){lenis.current.scrollTo(href,{offset:-(scrollMargin||0)});}}catch(error){console.error(\"Error in anchor click handler:\",error);}};const handlers=anchorLinksData.map(({href,scrollMargin})=>e=>handleClick(e,href,scrollMargin));anchorLinksData.forEach(({anchorElement},index)=>{if(anchorElement&&handlers[index]){anchorElement.addEventListener(\"click\",handlers[index]);}});return()=>{anchorLinksData.forEach(({anchorElement},index)=>{if(anchorElement&&handlers[index]){anchorElement.removeEventListener(\"click\",handlers[index]);}});};}catch(error){console.error(\"Error setting up anchor links:\",error);return()=>{};}},[lenis]);return /*#__PURE__*/_jsx(\"div\",{style:props.style});}/**\n * @framerSupportedLayoutWidth auto\n * @framerSupportedLayoutHeight auto\n *\n * @framerDisableUnlink\n */const SmoothScroll=withCSS(SmoothScrollComponent,[\"html.lenis { height: auto; }\",\".lenis.lenis-smooth { scroll-behavior: auto !important; }\",\".lenis.lenis-smooth [data-lenis-prevent] { overscroll-behavior: contain; }\",\".lenis.lenis-stopped { overflow: hidden; }\",\".lenis.lenis-scrolling iframe { pointer-events: none; }\"],\"\");export default SmoothScroll;SmoothScroll.displayName=\"Smooth Scroll\";addPropertyControls(SmoothScroll,{intensity:{title:\"Intensity\",type:ControlType.Number,defaultValue:10,min:0,description:\"More components at [Framer University](https://frameruni.link/cc).\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"SmoothScroll\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"auto\",\"framerDisableUnlink\":\"\",\"framerSupportedLayoutHeight\":\"auto\",\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./SmoothScroll_Prod.map"],"mappings":"iYAAoK,SAAS,EAAsB,EAAM,CAAC,GAAK,CAAC,YAAU,CAAC,EAAY,EAAMA,EAAO,MAQ40C,OARt0C,MAAc,CAAC,GAAG,EAAM,QAAS,GAAG,CAAC,EAAM,QAAQ,SAAS,EAAE,CAAC,UAAU,GAAK,CAAG,OAAM,EAAM,CAAC,QA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