{"version":3,"file":"ResponsiveVideo.B3vcF8Nm.mjs","names":["useRef","useState"],"sources":["https:/framerusercontent.com/modules/z575PYo4r9qReooMGW25/eOXdc2s9SMt0fvC3yXVs/ResponsiveVideo.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{addPropertyControls,ControlType}from\"framer\";import{useRef,useEffect,useState}from\"react\";// Renders a responsive, autoplaying video.\n//\n// 2026-09-16 — CLS FIX (Core Web Vitals):\n//  • Previously the <video> was styled `width:100%; height:auto` with no\n//    width/height attributes and no aspect-ratio. Before the browser has the\n//    video's metadata it has no intrinsic size to work from, so it fell back to\n//    the CSS default video box of 300x150 and rendered only 150px tall. When\n//    metadata arrived the box jumped to its real height (~560px at desktop\n//    width) and shoved every section below it down the page. That single jump\n//    is what Search Console was reporting as \"CLS more than 0.25 (desktop)\".\n//  • Fix: reserve the box up front with a CSS `aspect-ratio`, so the correct\n//    height exists from the very first paint (including in Framer's SSR HTML).\n//    The default is 16:9, which matches the videos currently in use.\n//  • The ratio self-corrects on `loadedmetadata`, so swapping in a video with a\n//    different shape still renders uncropped — and if the ratio already\n//    matches, nothing moves at all.\nconst DEFAULT_ASPECT=16/9;export default function ResponsiveVideo(props){const{videoFile,borderRadius,borderWidth,borderColor,backgroundColor,playOnScroll,threshold,startTime,aspectRatio}=props;const containerRef=useRef(null);const videoRef=useRef(null);const[isVisible,setIsVisible]=useState(false);// Space is reserved with this ratio before the video file loads.\nconst initialAspect=Number(aspectRatio)>0?Number(aspectRatio):DEFAULT_ASPECT;const[ratio,setRatio]=useState(initialAspect);useEffect(()=>{setRatio(initialAspect);},[initialAspect]);useEffect(()=>{if(!playOnScroll)return;const observer=new IntersectionObserver(([entry])=>{setIsVisible(entry.isIntersecting);},{threshold:threshold});if(containerRef.current){observer.observe(containerRef.current);}return()=>observer.disconnect();},[playOnScroll,threshold]);useEffect(()=>{if(!videoRef.current)return;if(!playOnScroll){videoRef.current.play().catch(()=>{});return;}if(isVisible){videoRef.current.play().catch(()=>{});}else{videoRef.current.pause();}},[isVisible,playOnScroll]);useEffect(()=>{if(videoRef.current&&startTime>0){videoRef.current.currentTime=startTime;}},[startTime]);// If the real video is not the assumed shape, correct it once metadata is\n// in. Same ratio => no state change => no layout shift.\nconst handleLoadedMetadata=e=>{const v=e.currentTarget;if(v.videoWidth>0&&v.videoHeight>0){const real=v.videoWidth/v.videoHeight;setRatio(prev=>Math.abs(prev-real)>.01?real:prev);}};return /*#__PURE__*/_jsx(\"div\",{ref:containerRef,style:{width:\"100%\",borderRadius:borderRadius,border:`${borderWidth}px solid ${borderColor}`,backgroundColor:backgroundColor,overflow:\"hidden\",lineHeight:0},children:videoFile&&/*#__PURE__*/_jsx(\"video\",{ref:videoRef,src:videoFile,autoPlay:!playOnScroll,loop:true,muted:true,playsInline:true,preload:\"metadata\",onLoadedMetadata:handleLoadedMetadata,style:{display:\"block\",width:\"100%\",height:\"auto\",// Reserves the right height before the file loads.\naspectRatio:String(ratio)}})});}ResponsiveVideo.defaultProps={videoFile:\"https://framerusercontent.com/assets/MLWPbW1dUQawJLhhun3dBwpgJak.mp4\",borderRadius:16,borderWidth:1,borderColor:\"rgb(230, 230, 235)\",backgroundColor:\"rgb(250, 249, 246)\",playOnScroll:true,threshold:.3,startTime:.5,aspectRatio:DEFAULT_ASPECT};addPropertyControls(ResponsiveVideo,{videoFile:{type:ControlType.File,title:\"Video File\",allowedFileTypes:[\"mp4\",\"webm\",\"mov\"]},aspectRatio:{type:ControlType.Number,title:\"Aspect Ratio\",defaultValue:DEFAULT_ASPECT,min:.2,max:5,step:.01,displayStepper:false,description:\"Width \\xf7 height of the video, used to reserve space before it loads. 1.78 = 16:9, 1 = square, 0.56 = 9:16. Corrects itself once the video loads.\"},playOnScroll:{type:ControlType.Boolean,title:\"Play on Scroll\",defaultValue:true,description:\"Only play when the video is visible in the viewport\"},threshold:{type:ControlType.Number,title:\"Visibility %\",defaultValue:.3,min:.1,max:1,step:.1,hidden:props=>!props.playOnScroll},startTime:{type:ControlType.Number,title:\"Start Time (s)\",defaultValue:.5,min:0,max:60,step:.5},borderRadius:{type:ControlType.Number,title:\"Border Radius\",defaultValue:16,min:0,max:50,step:1},borderWidth:{type:ControlType.Number,title:\"Border Width\",defaultValue:1,min:0,max:10,step:1},borderColor:{type:ControlType.Color,title:\"Border Color\",defaultValue:\"rgb(230, 230, 235)\"},backgroundColor:{type:ControlType.Color,title:\"Background\",defaultValue:\"rgb(250, 249, 246)\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"ResponsiveVideo\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./ResponsiveVideo.map"],"mappings":"oLAgB0B,SAAwB,EAAgB,EAAM,CAAC,GAAK,CAAC,YAAU,eAAa,cAAY,cAAY,kBAAgB,eAAa,YAAU,YAAU,eAAa,EAAY,EAAaA,EAAO,IAAI,EAAQ,EAASA,EAAO,IAAI,EAAO,CAAC,EAAU,GAAcC,EAAS,EAAK,EACpS,EAAc,OAAO,CAAW,EAAE,EAAE,OAAO,CAAW,EAAE,EAAoB,CAAC,EAAM,GAAUA,EAAS,CAAa,EAE6D,OAF3D,MAAc,CAAC,EAAS,CAAa,CAAE,EAAE,CAAC,CAAa,CAAC,EAAE,MAAc,CAAC,GAAG,CAAC,EAAa,OAAO,IAAM,EAAS,IAAI,sBAAsB,CAAC,KAAS,CAAC,EAAa,EAAM,cAAc,CAAE,EAAE,CAAW,WAAS,CAAC,EAAmE,OAA9D,EAAa,SAAS,EAAS,QAAQ,EAAa,OAAO,MAAa,EAAS,WAAW,CAAE,EAAE,CAAC,EAAa,CAAS,CAAC,EAAE,MAAc,CAAK,KAAS,QAAe,IAAG,CAAC,EAAa,CAAC,EAAS,QAAQ,KAAK,CAAC,CAAC,UAAU,CAAC,CAAC,EAAE,MAAO,CAAI,EAAW,EAAS,QAAQ,KAAK,CAAC,CAAC,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