{"version":3,"file":"AmbientVideo_2.DYzc0pO2.mjs","names":["useRef","useState"],"sources":["https:/framerusercontent.com/modules/fTZYoyVn1qKN0zai2u8i/RMqSG6EuaaUzq6O6RnUr/AmbientVideo_2.js"],"sourcesContent":["// Ambient Mode Glow Effect - A video component with dynamic glow based on video content\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useEffect,useRef,useState,startTransition}from\"react\";import{addPropertyControls,ControlType,useIsStaticRenderer}from\"framer\";/**\n * @framerSupportedLayoutWidth fixed\n * @framerSupportedLayoutHeight fixed\n */function AmbientVideo(props){const{videoFile=\"https://framerusercontent.com/assets/MLWPbW1dUQawJLhhun3dBwpgJak.mp4\",poster,autoplay=true,muted=true,loop=true,controls=true,glowIntensity=.6,glowBlur=40,glowSpread=20,borderRadius=12}=props;const videoRef=useRef(null);const canvasRef=useRef(null);const[glowColor,setGlowColor]=useState(\"rgba(100, 100, 100, 0.3)\");const isStatic=useIsStaticRenderer();useEffect(()=>{if(isStatic)return;if(!videoRef.current||!canvasRef.current)return;const video=videoRef.current;const canvas=canvasRef.current;const ctx=canvas.getContext(\"2d\");if(!ctx)return;let intervalId;const extractColorFromFrame=()=>{if(video.readyState<2)return null;try{canvas.width=1;canvas.height=1;ctx.drawImage(video,0,0,1,1);const imageData=ctx.getImageData(0,0,1,1);const[r,g,b]=imageData.data;return`rgba(${r}, ${g}, ${b}, ${glowIntensity})`;}catch(error){return null;}};const updateGlowColor=()=>{if(video.readyState<2)return;const newColor=extractColorFromFrame();if(newColor){startTransition(()=>{setGlowColor(newColor);});}};const startGlowUpdates=()=>{// Clear any existing interval\nif(intervalId){clearInterval(intervalId);}// Start immediate extraction\nupdateGlowColor();// Continue extracting at regular intervals\nintervalId=setInterval(updateGlowColor,50);};const stopGlowUpdates=()=>{if(intervalId){clearInterval(intervalId);intervalId=0;}};// Start glow updates as soon as video can play\nconst handleCanPlay=()=>{startGlowUpdates();};const handlePlay=()=>{startGlowUpdates();};const handlePause=()=>{stopGlowUpdates();};const handleEnded=()=>{stopGlowUpdates();};// Add event listeners\nvideo.addEventListener(\"canplay\",handleCanPlay);video.addEventListener(\"loadedmetadata\",handleCanPlay);video.addEventListener(\"play\",handlePlay);video.addEventListener(\"pause\",handlePause);video.addEventListener(\"ended\",handleEnded);// If video is already ready, start immediately\nif(video.readyState>=3){startGlowUpdates();}return()=>{stopGlowUpdates();video.removeEventListener(\"canplay\",handleCanPlay);video.removeEventListener(\"loadedmetadata\",handleCanPlay);video.removeEventListener(\"play\",handlePlay);video.removeEventListener(\"pause\",handlePause);video.removeEventListener(\"ended\",handleEnded);};},[glowIntensity,isStatic]);const outerContainerStyle={width:\"100%\",height:\"100%\",display:\"flex\",alignItems:\"center\",justifyContent:\"center\"};const innerContainerStyle={position:\"relative\",width:\"100%\",height:\"100%\",borderRadius,overflow:\"visible\"};const videoStyle={position:\"relative\",width:\"100%\",height:\"100%\",objectFit:\"cover\",borderRadius,zIndex:1,display:\"block\",boxShadow:`0 0 ${glowBlur}px ${glowSpread}px ${glowColor}`,transition:\"box-shadow 0.4s ease-in-out\"};return /*#__PURE__*/_jsxs(\"div\",{style:outerContainerStyle,children:[/*#__PURE__*/_jsx(\"div\",{style:innerContainerStyle,children:/*#__PURE__*/_jsx(\"video\",{ref:videoRef,src:videoFile,poster:poster?.src||undefined,autoPlay:autoplay&&!isStatic,muted:muted,loop:loop,controls:controls,style:videoStyle,playsInline:true,crossOrigin:\"anonymous\"})}),/*#__PURE__*/_jsx(\"canvas\",{ref:canvasRef,style:{display:\"none\"},width:1,height:1})]});}export default AmbientVideo;addPropertyControls(AmbientVideo,{videoFile:{type:ControlType.String,title:\"Video URL\",defaultValue:\"https://framerusercontent.com/assets/MLWPbW1dUQawJLhhun3dBwpgJak.mp4\",placeholder:\"Paste video URL…\"},poster:{type:ControlType.ResponsiveImage,title:\"Poster Image\"},autoplay:{type:ControlType.Boolean,title:\"Autoplay\",defaultValue:true},muted:{type:ControlType.Boolean,title:\"Muted\",defaultValue:true},loop:{type:ControlType.Boolean,title:\"Loop\",defaultValue:true},controls:{type:ControlType.Boolean,title:\"Show Controls\",defaultValue:true},glowIntensity:{type:ControlType.Number,title:\"Glow Intensity\",defaultValue:.6,min:0,max:1,step:.1},glowBlur:{type:ControlType.Number,title:\"Glow Blur\",defaultValue:50,min:10,max:100,step:5,unit:\"px\"},glowSpread:{type:ControlType.Number,title:\"Glow Spread\",defaultValue:20,min:0,max:50,step:5,unit:\"px\"},borderRadius:{type:ControlType.Number,title:\"Border Radius\",defaultValue:12,min:0,max:50,step:1,unit:\"px\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"AmbientVideo\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"fixed\",\"framerSupportedLayoutHeight\":\"fixed\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./AmbientVideo_2.map"],"mappings":"8MAIG,SAAS,EAAa,EAAM,CAAC,GAAK,CAAC,YAAU,uEAAuE,SAAO,WAAS,GAAK,QAAM,GAAK,OAAK,GAAK,WAAS,GAAK,gBAAc,GAAG,WAAS,GAAG,aAAW,GAAG,eAAa,IAAI,EAAY,EAASA,EAAO,KAAK,CAAO,EAAUA,EAAO,KAAK,CAAM,CAAC,EAAU,GAAcC,EAAS,2BAA2B,CAAO,EAAS,GAAqB,CAAC,MAAc,CAAoB,GAAhB,GAAmB,CAAC,EAAS,SAAS,CAAC,EAAU,QAAQ,OAAO,IAAM,EAAM,EAAS,QAAc,EAAO,EAAU,QAAc,EAAI,EAAO,WAAW,KAAK,CAAC,GAAG,CAAC,EAAI,OAAO,IAAI,EAAiB,MAA0B,CAAC,GAAG,EAAM,WAAW,EAAE,OAAO,KAAK,GAAG,CAAC,EAAO,MAAM,EAAE,EAAO,OAAO,EAAE,EAAI,UAAU,EAAM,EAAE,EAAE,EAAE,EAAE,CAA2C,GAAK,CAAC,EAAE,EAA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