{"version":3,"file":"ControlledVideo.Ck562fvC.mjs","names":["useRef","useState"],"sources":["https:/framerusercontent.com/modules/v3tilvFEjuTYGf6hPQiX/81TdKhumhedxUykuCJbh/ControlledVideo.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useRef,useEffect,useState}from\"react\";import{addPropertyControls,ControlType,RenderTarget}from\"framer\";export default function ControlledVideo(props){const videoRef=useRef(null);const isCanvas=RenderTarget.current()===RenderTarget.canvas;const[isPlaying,setIsPlaying]=useState(false);const thumbUrl=props.videoUrl?props.videoUrl.replace(/\\.[^/.]+$/,\".jpg\"):\"\";useEffect(()=>{const video=videoRef.current;if(!video)return;if(isCanvas){video.pause();return;}if(props.isPaused){video.pause();setIsPlaying(false);}else{video.currentTime=0;video.play().then(()=>setIsPlaying(true)).catch(()=>setIsPlaying(false));}},[props.isPaused,props.videoUrl,isCanvas]);return /*#__PURE__*/_jsxs(\"div\",{style:{width:\"100%\",height:\"100%\",position:\"relative\",overflow:\"hidden\",backgroundColor:props.backgroundColor},children:[/*#__PURE__*/_jsx(\"video\",{ref:videoRef,src:props.videoUrl,poster:thumbUrl,controls:props.showControls,style:{width:\"100%\",height:\"100%\",objectFit:props.videoFit,display:\"block\"},muted:true,loop:props.loop,playsInline:true,onPlay:()=>setIsPlaying(true),onPause:()=>setIsPlaying(false)}),(!isPlaying||isCanvas)&&/*#__PURE__*/_jsx(\"div\",{style:{position:\"absolute\",top:0,left:0,width:\"100%\",height:\"100%\",backgroundImage:`url(${thumbUrl})`,backgroundSize:props.thumbFit,backgroundPosition:\"center\",backgroundRepeat:\"no-repeat\",backgroundColor:props.backgroundColor,zIndex:2,pointerEvents:props.showControls?\"none\":\"auto\"},onClick:()=>{if(videoRef.current){videoRef.current.currentTime=0;videoRef.current.play();}}})]});}addPropertyControls(ControlledVideo,{videoUrl:{type:ControlType.String,title:\"Video URL\",defaultValue:\"\"},startTime:{type:ControlType.Number,title:\"Start Time\",min:0,max:100,step:.1,defaultValue:0,unit:\"s\"},isPaused:{type:ControlType.Boolean,title:\"Paused\",defaultValue:false},videoFit:{type:ControlType.Enum,title:\"Video Fit\",options:[\"cover\",\"contain\",\"fill\"],defaultValue:\"cover\"},thumbFit:{type:ControlType.Enum,title:\"Thumb Fit\",options:[\"cover\",\"contain\"],defaultValue:\"cover\"},backgroundColor:{type:ControlType.Color,title:\"Background\",defaultValue:\"#000\"},showControls:{type:ControlType.Boolean,title:\"Controls\",defaultValue:false},loop:{type:ControlType.Boolean,title:\"Loop\",defaultValue:true}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"ControlledVideo\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./ControlledVideo.map"],"mappings":"sMAAuK,SAAwB,EAAgB,EAAM,CAAC,IAAM,EAASA,EAAO,KAAK,CAAO,EAAS,EAAa,SAAS,GAAG,EAAa,OAAY,CAAC,EAAU,GAAcC,EAAS,GAAM,CAAO,EAAS,EAAM,SAAS,EAAM,SAAS,QAAQ,YAAY,OAAO,CAAC,GAAwS,OAArS,MAAc,CAAC,IAAM,EAAM,EAAS,QAAY,KAAa,IAAG,EAAS,CAAC,EAAM,OAAO,CAAC,OAAW,EAAM,UAAU,EAAM,OAAO,CAAC,EAAa,GAAM,GAAO,EAAM,YAAY,EAAE,EAAM,MAAM,CAAC,SAAS,EAAa,GAAK,CAAC,CAAC,UAAU,EAAa,GAAM,CAAC,IAAI,CAAC,EAAM,SAAS,EAAM,SAAS,EAAS,CAAC,CAAqB,EAAM,MAAM,CAAC,MAAM,CAAC,MAAM,OAAO,OAAO,OAAO,SAAS,WAAW,SAAS,SAAS,gBAAgB,EAAM,gBAAgB,CAAC,SAAS,CAAc,EAAK,QAAQ,CAAC,IAAI,EAAS,IAAI,EAAM,SAAS,OAAO,EAAS,SAAS,EAAM,aAAa,MAAM,CAAC,MAAM,OA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