{"version":3,"file":"ResponsiveVideo.CyKC_vv_.mjs","names":["useRef","useState","useEffect","_jsx","__esmMin","init_npm_react_18_3_1","ce","init_jsx_runtime","c","_e","de","addPropertyControls","init_framer_ChujFWHC","ResponsiveVideo","props","videoFile","borderRadius","borderWidth","borderColor","backgroundColor","playOnScroll","threshold","startTime","aspectRatio","containerRef","videoRef","isVisible","setIsVisible","initialAspect","DEFAULT_ASPECT","ratio","setRatio","observer","entry","v","real","prev","init_ResponsiveVideo","ControlType"],"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":"A,oLAgB0B,SAAwBa,EAAgBC,EAAM,CAAC,GAAK,CAACC,YAAUC,eAAaC,cAAYC,cAAYC,kBAAgBC,eAAaC,YAAUC,YAAUC,eAAaT,EAAYU,EAAaxB,EAAO,IAAI,EAAQyB,EAASzB,EAAO,IAAI,EAAO,CAAC0B,EAAUC,GAAc1B,EAAS,EAAK,EACpS2B,EAAc,OAAOL,CAAW,EAAE,EAAE,OAAOA,CAAW,EAAEM,EAAoB,CAACC,EAAMC,GAAU9B,EAAS2B,CAAa,EAE6D,OAF3D1B,MAAc,CAAC6B,EAASH,CAAa,CAAE,EAAE,CAACA,CAAa,CAAC,EAAE1B,MAAc,CAAC,GAAG,CAACkB,EAAa,OAAO,IAAMY,EAAS,IAAI,sBAAsB,CAACC,KAAS,CAACN,EAAaM,EAAM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