{"version":3,"file":"VisibleFrameLoop.NzAze95R.mjs","names":["useRef","useEffect","__esmMin","window","init_ssg_sandbox_shims","init_npm_react_18_3_1","de","ce","prefersReducedMotion","useOnScreen","ref","onChange","rootMargin","watchKey","visibleRef","onChangeRef","el","inView","update","next","io","entries","useVisibleFrameLoop","tick","options","enabled","ignoreReducedMotion","tickRef","state","controls","stop","s","frame","time","dt","start","visible","init_VisibleFrameLoop"],"sources":["https:/framerusercontent.com/modules/x1Zu9I12gbJxEvx0LjYW/C4Q4JCo5onFQz8wFl5xb/VisibleFrameLoop.js"],"sourcesContent":["import{useEffect,useRef}from\"react\";export function prefersReducedMotion(){return typeof window!==\"undefined\"&&!!window.matchMedia?.(\"(prefers-reduced-motion: reduce)\").matches;}// Tracks whether an element is near the viewport and the tab is visible.\n// `onChange` fires on every flip; the returned ref can be read any time.\n// Change `watchKey` to re-attach when the element mounts after first render.\nexport function useOnScreen(ref,onChange,rootMargin=\"200px\",watchKey){const visibleRef=useRef(false);const onChangeRef=useRef(onChange);onChangeRef.current=onChange;useEffect(()=>{const el=ref.current;if(!el||typeof window===\"undefined\")return;let inView=typeof IntersectionObserver===\"undefined\";const update=()=>{const next=inView&&!document.hidden;if(next===visibleRef.current)return;visibleRef.current=next;onChangeRef.current?.(next);};const io=typeof IntersectionObserver===\"undefined\"?null:new IntersectionObserver(entries=>{inView=entries[entries.length-1].isIntersecting;update();},{rootMargin});io?.observe(el);document.addEventListener(\"visibilitychange\",update);update();return()=>{io?.disconnect();document.removeEventListener(\"visibilitychange\",update);if(visibleRef.current){visibleRef.current=false;onChangeRef.current?.(false);}};},[ref,rootMargin,watchKey]);return visibleRef;}// Runs tick(time, dt) every frame while the element is on screen.\n// Return false from tick to go idle until wake() is called.\nexport function useVisibleFrameLoop(ref,tick,options={}){const{enabled=true,rootMargin=\"200px\",ignoreReducedMotion=false}=options;const tickRef=useRef(tick);tickRef.current=tick;const state=useRef({raf:0,last:-1,allowed:false,visible:false});const controls=useRef({wake:()=>{},isVisible:()=>state.current.visible});const stop=()=>{const s=state.current;if(s.raf)cancelAnimationFrame(s.raf);s.raf=0;s.last=-1;};const frame=time=>{const s=state.current;s.raf=0;if(!s.allowed||!s.visible)return;const dt=s.last<0?0:Math.min(time-s.last,250);s.last=time;if(tickRef.current(time,dt)===false){s.last=-1;return;}s.raf=requestAnimationFrame(frame);};const start=()=>{const s=state.current;if(s.raf||!s.allowed||!s.visible)return;s.raf=requestAnimationFrame(frame);};controls.current.wake=start;useOnScreen(ref,visible=>{state.current.visible=visible;if(visible)start();else stop();},rootMargin);useEffect(()=>{const s=state.current;s.allowed=enabled&&typeof window!==\"undefined\"&&(ignoreReducedMotion||!prefersReducedMotion());if(s.allowed)start();else stop();return stop;},[enabled,ignoreReducedMotion]);return controls.current;}\nexport const __FramerMetadata__ = {\"exports\":{\"FrameTick\":{\"type\":\"tsType\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"prefersReducedMotion\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"useVisibleFrameLoop\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"VisibleLoopControls\":{\"type\":\"tsType\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"VisibleLoopOptions\":{\"type\":\"tsType\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"useOnScreen\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./VisibleFrameLoop.map"],"mappings":"A,yHAAoC,SAAgBQ,GAAsB,CAAC,OAAcL,IAAS,QAAa,CAAC,CAACA,EAAO,aAAa,kCAAkC,CAAC,CAAC,OAAQ,CAGjL,SAAgBM,EAAYC,EAAIC,EAASC,EAAW,QAAQC,EAAS,CAAC,IAAMC,EAAWd,EAAO,EAAK,EAAQe,EAAYf,EAAOW,CAAQ,EAAsuB,MAApuBI,GAAY,QAAQJ,EAASV,MAAc,CAAC,IAAMe,EAAG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