{"version":3,"file":"AutoplayVideo.CLGbTLEe.mjs","names":["useRef","useState","__esmMin","te","init_npm_react_18_3_1","ce","init_jsx_runtime","c","p","_e","de","init_framer_Duogf4LG","ControlType","addPropertyControls","AutoplayVideo","props","videoRef","isPlaying","setIsPlaying","aspectRatio","setAspectRatio","showPlayButton","setShowPlayButton","video","playVideo","error","handlePlay","handlePause","handleVisibilityChange","handleLoadedMetadata","videoFile","isFixedWidth","calculatedHeight","autoHeight","togglePlayPause","poster","init_AutoplayVideo"],"sources":["https:/framerusercontent.com/modules/hR2iMZuw5ep5exNNNKLe/grtmIyy8fwtelcaf4ZvN/AutoplayVideo.js"],"sourcesContent":["// Autoplay video component with loop, muted for reliable browser autoplay\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{addPropertyControls,ControlType}from\"framer\";import{useRef,useEffect,useState,startTransition}from\"react\";/**\n * Autoplay Video Component\n * \n * @framerSupportedLayoutWidth fixed\n * @framerSupportedLayoutHeight any-prefer-fixed\n */export default function AutoplayVideo(props){const{videoFile=\"https://framerusercontent.com/assets/MLWPbW1dUQawJLhhun3dBwpgJak.mp4\",poster,objectFit=\"cover\",backgroundColor=\"#000000\",borderRadius=0,autoHeight=false}=props;const videoRef=useRef(null);const[isPlaying,setIsPlaying]=useState(true);const[aspectRatio,setAspectRatio]=useState(null);const[showPlayButton,setShowPlayButton]=useState(false);useEffect(()=>{const video=videoRef.current;if(!video)return;// Ensure video plays on mount\nconst playVideo=async()=>{try{await video.play();startTransition(()=>{setIsPlaying(true);setShowPlayButton(false);});}catch(error){console.warn(\"Autoplay failed:\",error);startTransition(()=>{setIsPlaying(false);setShowPlayButton(true);});}};playVideo();// Sync state with actual video playback\nconst handlePlay=()=>{startTransition(()=>{setIsPlaying(true);setShowPlayButton(false);});};const handlePause=()=>{startTransition(()=>{setIsPlaying(false);setShowPlayButton(true);});};// Handle visibility change to resume playback\nconst handleVisibilityChange=()=>{if(!document.hidden&&video.paused){playVideo();}};// Get video dimensions for aspect ratio\nconst handleLoadedMetadata=()=>{if(video.videoWidth&&video.videoHeight){startTransition(()=>{setAspectRatio(video.videoHeight/video.videoWidth);});}};video.addEventListener(\"play\",handlePlay);video.addEventListener(\"pause\",handlePause);video.addEventListener(\"loadedmetadata\",handleLoadedMetadata);document.addEventListener(\"visibilitychange\",handleVisibilityChange);return()=>{video.removeEventListener(\"play\",handlePlay);video.removeEventListener(\"pause\",handlePause);video.removeEventListener(\"loadedmetadata\",handleLoadedMetadata);document.removeEventListener(\"visibilitychange\",handleVisibilityChange);};},[videoFile]);const isFixedWidth=props?.style&&props.style.width===\"100%\";const calculatedHeight=autoHeight&&isFixedWidth&&aspectRatio?`${aspectRatio*100}%`:\"100%\";const togglePlayPause=async e=>{e.preventDefault();e.stopPropagation();const video=videoRef.current;if(!video)return;try{if(video.paused){await video.play();}else{video.pause();}}catch(error){console.warn(\"Play/pause failed:\",error);// Force show play button if play fails\nstartTransition(()=>setShowPlayButton(true));}};return /*#__PURE__*/_jsxs(\"div\",{style:{width:\"100%\",height:calculatedHeight,position:\"relative\",backgroundColor,borderRadius,overflow:\"hidden\"},children:[/*#__PURE__*/_jsx(\"video\",{ref:videoRef,src:videoFile,poster:poster?.src,autoPlay:true,loop:true,muted:true,playsInline:true,onClick:togglePlayPause,style:{width:\"100%\",height:\"100%\",objectFit,display:\"block\",cursor:\"pointer\"},\"aria-label\":\"Autoplay video\"}),showPlayButton&&/*#__PURE__*/_jsx(\"div\",{onClick:togglePlayPause,style:{position:\"absolute\",top:\"50%\",left:\"50%\",transform:\"translate(-50%, -50%)\",width:64,height:64,borderRadius:\"50%\",backgroundColor:\"rgba(255, 255, 255, 0.9)\",display:\"flex\",alignItems:\"center\",justifyContent:\"center\",cursor:\"pointer\",boxShadow:\"0 2px 8px rgba(0, 0, 0, 0.1)\"},children:/*#__PURE__*/_jsx(\"svg\",{width:\"28\",height:\"28\",viewBox:\"0 0 24 24\",fill:\"none\",xmlns:\"http://www.w3.org/2000/svg\",style:{marginLeft:3},children:/*#__PURE__*/_jsx(\"path\",{d:\"M8 5v14l11-7L8 5z\",fill:\"#666666\"})})})]});}addPropertyControls(AutoplayVideo,{videoFile:{type:ControlType.File,title:\"Video\",allowedFileTypes:[\"mp4\",\"webm\",\"mov\"]},poster:{type:ControlType.ResponsiveImage,title:\"Poster\"},autoHeight:{type:ControlType.Boolean,title:\"Auto Height\",defaultValue:false,enabledTitle:\"On\",disabledTitle:\"Off\"},objectFit:{type:ControlType.Enum,title:\"Fit\",options:[\"contain\",\"cover\",\"fill\",\"none\",\"scale-down\"],optionTitles:[\"Contain\",\"Cover\",\"Fill\",\"None\",\"Scale Down\"],defaultValue:\"cover\",displaySegmentedControl:false},backgroundColor:{type:ControlType.Color,title:\"Background\",defaultValue:\"#000000\"},borderRadius:{type:ControlType.Number,title:\"Radius\",defaultValue:0,min:0,max:100,step:1,unit:\"px\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"AutoplayVideo\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"fixed\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"any-prefer-fixed\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./AutoplayVideo.map"],"mappings":"A,sMAMG,SAAwBc,EAAc,EAAM,CAAC,GAAK,CAAC,YAAU,uEAAuE,SAAO,YAAU,QAAQ,kBAAgB,UAAU,eAAa,EAAE,aAAW,IAAOC,EAAYC,EAAShB,EAAO,IAAI,EAAO,CAACiB,EAAUC,GAAcjB,EAAS,EAAI,EAAO,CAACkB,EAAYC,GAAgBnB,EAAS,IAAI,EAAO,CAACoB,EAAeC,GAAmBrB,EAAS,EAAK,EAAEI,MAAc,CAAC,IAAMkB,EAAMP,EAAS,QAAQ,GAAG,CAACO,EAAM,OACzc,IAAMC,EAAU,SAAS,CAAC,GAAG,CAAC,MAAMD,EAAM,KAAK,EAAEpB,MAAoB,CAACe,EAA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