{"version":3,"file":"Autoplay.DaklEmbk.mjs","names":["useEffect","__legacyOverrideHOC_useContext","__legacyOverrideHOC_DataObserverContext","_jsx","__esmMin","init_npm_react_18_3_1","oe","ce","init_jsx_runtime","c","init_framer_ChujFWHC","DataObserverContext","PlayWithSound","video","playCount","lastTime","timeUpdateHandler","endedHandler","playPromise","stopAndCleanup","current","withPlayWithSound","C","props","init_Autoplay"],"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":"A,0KAAwE,SAAgBY,GAAe,CAUiI,OAVhIZ,MAAc,CAAC,IAAMa,EAAM,SAAS,cAAc,OAAO,EAAE,GAAG,CAACA,EAAM,OAAOA,EAAM,MAAM,GAAMA,EAAM,KAAK,GAAK,IAAIC,EAAU,EAAuBC,EAAS,EAAMC,EAAsBC,EAG1RC,EAAYL,EAAM,KAAK,EAAKK,IAAc,IAAA,IAAWA,EAAY,UAAU,CAACL,EAAM,MAAM,GAAKA,EAAM,KAAK,CAAC,CAAC,UAAU,CAAC,CAAC,CAAE,CAAC,EAC/HI,MAAiB,CAACH,IAAeA,GAAW,GAAUK,EAAe,CAAG,EAAEN,EAAM,iBAAiB,QAAQI,CAAY,EACrHD,MAAsB,CAAC,IAAMI,EAAQP,EAAM,YACxCO,EAAQ,GAAGL,IAAUD,IAAeA,GAAW,GAAUK,EAAe,GAAIJ,EAASK,CAAQ,EAAEP,EAAM,iBAAiB,aAAaG,CAAiB,EAAE,SAASG,GAAgB,CAClLN,EAAM,KAAK,GACX,GAAG,CAACA,EAAM,MAAM,EAAEA,EAAM,YAAY,CAAE,MAAW,CACjD,CACAA,EAAM,oBAAoB,aAAaG,CAAiB,EAAEH,EAAM,oBAAoB,QAAQI,CAAY,CAAE,CAAC,UAAU,CAACJ,EAAM,oBAAoB,aAAaG,CAAiB,EAAEH,EAAM,oBAAoB,QAAQI,CAAY,CAAE,CAAE,EAAE,CAAC,CAAC,EAAQ,CAAC,CAAE,CAAoJ,SAAgBI,EAAkBC,EAAE,CAAC,MAAOC,KAAQtB,EAA+BC,CAAuC,EAASC,EAAKmB,EAAE,CAAC,GAAGC,EAAM,GAAGX,EAAcW,CAAK,CAAC,CAAC,EAAI,C,0CAACF,EAAkB,YAAY,e"}