{"version":3,"file":"Parallax.Beh2GNHe.mjs","names":["useRef"],"sources":["https:/framerusercontent.com/modules/Kan4srgxbVAEtgILWqxA/plKDYneVW5vN0SkDx7VR/Parallax.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect,useRef}from\"react\";import{RenderTarget}from\"framer\";/**\n * Parallax\n *\n * Moves an image layer against the scroll, measured from the layer's own\n * position in the viewport (not from the page's total scroll), so a layer far\n * down the page moves exactly like one at the top.\n *\n * progress runs from +1 (layer centre one half-screen below the viewport\n * centre) to -1 (one half-screen above). The layer shifts by -progress * RANGE\n * and is scaled up just enough that the shift never shows its edges inside its\n * clipping parent. Apply it to an image frame whose parent clips.\n *//** Share of the layer's height it travels each way. */const AMOUNT=.06;/** Cap on the travel each way, in CSS pixels. */const MAX=72;export function withParallax(Component){return props=>{const wrapper=useRef(null);const isCanvas=RenderTarget.current()===RenderTarget.canvas;useEffect(()=>{if(isCanvas||typeof window===\"undefined\")return;const root=wrapper.current;if(!root)return;const target=root.firstElementChild;if(!target)return;if(window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches)return;let shift=0;let scale=1;const paint=()=>{const rect=target.getBoundingClientRect();// Rect values carry the page zoom (the site's zoom layer) and\n// this layer's own scale; style values are pre-zoom CSS pixels.\nconst height=rect.height/scale;const layout=target.offsetHeight;if(height<=0||layout<=0)return;const zoom=height/layout;const viewport=window.innerHeight;// The scale keeps the centre in place, so only the shift moves it.\nconst centre=rect.top+height/2-shift;let progress=(centre-viewport/2)/(viewport/2+height/2);progress=progress<-1?-1:progress>1?1:progress;const range=Math.min(height*AMOUNT,MAX);shift=-progress*range;scale=1+(2*range+8)/height;target.style.translate=`0px ${(shift/zoom).toFixed(2)}px`;target.style.scale=scale.toFixed(4);};let frame=0;let lastY=NaN;let lastH=NaN;const tick=()=>{const y=window.scrollY;const h=window.innerHeight;if(y!==lastY||h!==lastH){lastY=y;lastH=h;paint();}frame=requestAnimationFrame(tick);};paint();frame=requestAnimationFrame(tick);const onScroll=()=>paint();window.addEventListener(\"scroll\",onScroll,{passive:true});window.addEventListener(\"resize\",onScroll);let observer=null;if(typeof ResizeObserver!==\"undefined\"){observer=new ResizeObserver(onScroll);observer.observe(target);}return()=>{cancelAnimationFrame(frame);window.removeEventListener(\"scroll\",onScroll);window.removeEventListener(\"resize\",onScroll);if(observer)observer.disconnect();target.style.translate=\"\";target.style.scale=\"\";};},[isCanvas]);if(isCanvas)return /*#__PURE__*/_jsx(Component,{...props});return /*#__PURE__*/_jsx(\"div\",{ref:wrapper,style:{display:\"contents\"},children:/*#__PURE__*/_jsx(Component,{...props})});};}\nexport const __FramerMetadata__ = {\"exports\":{\"withParallax\":{\"type\":\"reactHoc\",\"name\":\"withParallax\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Parallax.map"],"mappings":"yLAWyI,SAAgB,EAAa,EAAU,CAAC,MAAO,IAAO,CAAC,IAAM,EAAQA,EAAO,IAAI,EAAQ,EAAS,EAAa,QAAQ,IAAI,EAAa,OAGuzB,OAHhzB,MAAc,CAAC,GAAG,GAAiB,IAAS,OAAY,OAAO,IAAM,EAAK,EAAQ,QAAQ,GAAG,CAAC,EAAK,OAAO,IAAM,EAAO,EAAK,kBAAoC,GAAf,CAAC,GAAiB,EAAO,WAAW,kCAAkC,CAAC,CAAC,QAAQ,OAAO,IAAI,EAAM,EAAM,EAAM,EAAQ,MAAU,CAAC,IAAM,EAAK,EAAO,sBAAsB,EAE1kB,EAAO,EAAK,OAAO,EAAY,EAAO,EAAO,aAAa,GAAG,GAAQ,GAAG,GAAQ,EAAE,OAAO,IAAM,EAAK,EAAO,EAAa,EAAS,EAAO,YACrG,GAA5B,EAAK,IAAI,EAAO,EAAE,EAA2B,EAAS,IAAI,EAAS,EAAE,EAAO,GAAG,EAAS,EAAS,GAAG,GAAG,EAAS,EAAE,EAAE,EAAS,IAAM,EAAM,KAAK,IAAI,EAAO,EA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