{"version":3,"file":"PlayInView.D9144fr9.mjs","names":["useRef"],"sources":["https:/framerusercontent.com/modules/RUokIVwPSlhaVCaluk9n/PZAkaDsaa1RPks8sjynm/PlayInView.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect,useRef}from\"react\";// Plays any <video> inside this layer only while it is visible; pauses when scrolled away,\n// and rewinds to the start whenever it is not in view.\nexport function withPlayInView(Component){return props=>{const ref=useRef(null);useEffect(()=>{const el=ref.current;if(!el||typeof IntersectionObserver===\"undefined\")return;const videos=()=>Array.from(el.querySelectorAll(\"video\"));const io=new IntersectionObserver(([entry])=>{videos().forEach(v=>{if(entry.isIntersecting&&entry.intersectionRatio>=.5){v.play().catch(()=>{});}else{v.pause();v.currentTime=0;}});},{threshold:[0,.5,1]});io.observe(el);// keep it paused on load until it is actually in view\nconst t=setTimeout(()=>{const r=el.getBoundingClientRect();if(r.bottom<0||r.top>window.innerHeight)videos().forEach(v=>v.pause());},300);return()=>{io.disconnect();clearTimeout(t);};},[]);return /*#__PURE__*/_jsx(\"div\",{ref:ref,style:{width:\"100%\",height:\"100%\",position:\"relative\"},children:/*#__PURE__*/_jsx(Component,{...props})});};}\nexport const __FramerMetadata__ = {\"exports\":{\"withPlayInView\":{\"type\":\"reactHoc\",\"name\":\"withPlayInView\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./PlayInView.map"],"mappings":"uIAEA,SAAgB,EAAe,EAAU,CAAC,MAAO,IAAO,CAAC,IAAM,EAAIA,EAAO,IAAI,EAC8G,OAD5G,MAAc,CAAC,IAAM,EAAG,EAAI,QAAQ,GAAG,CAAC,GAAI,OAAO,qBAAuB,IAAY,OAAO,IAAM,MAAW,MAAM,KAAK,EAAG,iBAAiB,OAAO,CAAC,EAAQ,EAAG,IAAI,sBAAsB,CAAC,KAAS,CAAC,EAAO,CAAC,CAAC,QAAQ,GAAG,CAAI,EAAM,gBAAgB,EAAM,mBAAmB,GAAI,EAAE,KAAK,CAAC,CAAC,UAAU,CAAC,CAAC,GAAQ,EAAE,MAAM,EAAE,EAAE,YAAY,EAAG,CAAC,CAAE,EAAE,CAAC,UAAU,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,EAAG,QAAQ,CAAE,EAChc,IAAM,EAAE,eAAe,CAAC,IAAM,EAAE,EAAG,sBAAsB,GAAK,EAAE,OAAO,GAAG,EAAE,IAAI,EAAO,cAAY,EAAO,CAAC,CAAC,QAAQ,GAAG,EAAE,MAAM,CAAC,CAAE,EAAE,GAAG,EAAE,UAAU,CAAC,EAAG,WAAW,EAAE,aAAa,CAAC,CAAE,CAAE,EAAE,CAAC,CAAC,EAAsB,EAAK,MAAM,CAAK,MAAI,MAAM,CAAC,MAAM,OAAO,OAAO,OAAO,SAAS,UAAU,EAAE,SAAsB,EAAK,EAAU,CAAC,GAAG,CAAK,CAAC,CAAC,CAAC,CAAE,CAAE,qBAHtS,IAAoC"}