{"version":3,"file":"Autoplay.jVGdKC2F.mjs","names":["__legacyOverrideHOC_DataObserverContext","_jsx"],"sources":["https:/framerusercontent.com/modules/TcUoNfS6PrYDiIew9X5g/KzZSN71qjGVJlRh4OlzG/Autoplay.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect}from\"react\";export function PlayWithSound(){useEffect(()=>{const video=document.querySelector(\"video\");if(!video)return;video.muted=false;video.loop=true;let playCount=0;const maxPlays=5;let lastTime=0;let timeUpdateHandler;let endedHandler;// Try with sound first: browsers allow it after a click on 60fps.design. Before any click\n// (a visitor landing from Google) they refuse sound, and the video used to stay paused.\n// So play muted instead. The player's mute button turns the sound on.\nconst playPromise=video.play();if(playPromise!==undefined){playPromise.catch(()=>{video.muted=true;video.play().catch(()=>{});});}// Fallback: ended event\nendedHandler=()=>{playCount++;if(playCount>=maxPlays){stopAndCleanup();}};video.addEventListener(\"ended\",endedHandler);// More robust detection: detect when currentTime wraps back to near zero\ntimeUpdateHandler=()=>{const current=video.currentTime;// If currentTime is less than lastTime by a noticeable margin, the video looped\nif(current+.1<lastTime){playCount++;if(playCount>=maxPlays){stopAndCleanup();}}lastTime=current;};video.addEventListener(\"timeupdate\",timeUpdateHandler);function stopAndCleanup(){// Prevent further automatic restarts\nvideo.loop=false;// Pause and reset to start\ntry{video.pause();video.currentTime=0;}catch(err){// some browsers may throw if setting currentTime too early, ignore\n}// Remove listeners\nvideo.removeEventListener(\"timeupdate\",timeUpdateHandler);video.removeEventListener(\"ended\",endedHandler);}return()=>{video.removeEventListener(\"timeupdate\",timeUpdateHandler);video.removeEventListener(\"ended\",endedHandler);};},[]);return{};}import{useContext as __legacyOverrideHOC_useContext}from\"react\";import{DataObserverContext as __legacyOverrideHOC_DataObserverContext}from\"framer\";export function withPlayWithSound(C){return props=>{__legacyOverrideHOC_useContext(__legacyOverrideHOC_DataObserverContext);return _jsx(C,{...props,...PlayWithSound(props)});};}withPlayWithSound.displayName=\"PlayWithSound\";\nexport const __FramerMetadata__ = {\"exports\":{\"PlayWithSound\":{\"type\":\"override\",\"name\":\"PlayWithSound\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withPlayWithSound\":{\"type\":\"reactHoc\",\"name\":\"withPlayWithSound\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Autoplay.map"],"mappings":"2KAAwE,SAAgB,GAAe,CAUiI,OAVhI,MAAc,CAAC,IAAM,EAAM,SAAS,cAAc,OAAO,EAAE,GAAG,CAAC,EAAM,OAAO,EAAM,MAAM,GAAM,EAAM,KAAK,GAAK,IAAI,EAAU,EAAuB,EAAS,EAAM,EAAsB,EAG1R,EAAY,EAAM,KAAK,EAAK,IAAc,IAAA,IAAW,EAAY,UAAU,CAAC,EAAM,MAAM,GAAK,EAAM,KAAK,CAAC,CAAC,UAAU,CAAC,CAAC,CAAE,CAAC,EAC/H,MAAiB,CAAC,IAAe,GAAW,GAAU,EAAe,CAAG,EAAE,EAAM,iBAAiB,QAAQ,CAAY,EACrH,MAAsB,CAAC,IAAM,EAAQ,EAAM,YACxC,EAAQ,GAAG,IAAU,IAAe,GAAW,GAAU,EAAe,GAAI,EAAS,CAAQ,EAAE,EAAM,iBAAiB,aAAa,CAAiB,EAAE,SAAS,GAAgB,CAClL,EAAM,KAAK,GACX,GAAG,CAAC,EAAM,MAAM,EAAE,EAAM,YAAY,CAAE,MAAW,CACjD,CACA,EAAM,oBAAoB,aAAa,CAAiB,EAAE,EAAM,oBAAoB,QAAQ,CAAY,CAAE,CAAC,UAAU,CAAC,EAAM,oBAAoB,aAAa,CAAiB,EAAE,EAAM,oBAAoB,QAAQ,CAAY,CAAE,CAAE,EAAE,CAAC,CAAC,EAAQ,CAAC,CAAE,CAAoJ,SAAgB,EAAkB,EAAE,CAAC,MAAO,KAAQ,EAA+BA,CAAuC,EAASC,EAAK,EAAE,CAAC,GAAG,EAAM,GAAG,EAAc,CAAK,CAAC,CAAC,EAAI,iBAV3gB,IAA6B,IAU6T,EAAkL,EAAkB,YAAY"}