{"version":3,"file":"BackgroundVideo.CfaRt02n.mjs","names":["React.useRef","React.useState","_Fragment"],"sources":["https:/framerusercontent.com/modules/aypkjSmLiM0Vk8HPJDxl/VEf2MBhGon1QNwSk4Wtk/BackgroundVideo.js"],"sourcesContent":["// Responsive background video component (Vimeo iframe or MP4 video)\n// - Fill modes: cover / coverWidth / coverHeight\n// - Load strategies: eager / nativeLazy / ioLazy\nimport{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from\"react/jsx-runtime\";import{addPropertyControls,ControlType}from\"framer\";import*as React from\"react\";/**\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight any\n */export default function BackgroundVideo(props){const{videoUrl=\"https://framerusercontent.com/assets/MLWPbW1dUQawJLhhun3dBwpgJak.mp4\",fillMode=\"cover\",vimeoAspect=\"16 / 9\",loadStrategy=\"eager\",ioRootMargin=600}=props;const hostRef=React.useRef(null);const[isLoaded,setIsLoaded]=React.useState(false);const[shouldLoad,setShouldLoad]=React.useState(loadStrategy!==\"ioLazy\");// Reset load state on URL changes\nReact.useEffect(()=>{setIsLoaded(false);setShouldLoad(loadStrategy!==\"ioLazy\");},[videoUrl,loadStrategy]);// IntersectionObserver lazy (real lazy)\nReact.useEffect(()=>{if(loadStrategy!==\"ioLazy\")return;const el=hostRef.current;if(!el)return;const rm=Math.max(0,ioRootMargin);const io=new IntersectionObserver(entries=>{const anyIn=entries.some(e=>e.isIntersecting);if(anyIn){setShouldLoad(true);io.disconnect();}},{root:null,rootMargin:`${rm}px`,threshold:.01});io.observe(el);return()=>io.disconnect();},[loadStrategy,ioRootMargin]);// Detect Vimeo\nconst isVimeo=videoUrl.includes(\"vimeo.com\");// Extract Vimeo video ID if it's a Vimeo URL\nconst getVimeoEmbedUrl=url=>{const match=url.match(/vimeo\\.com\\/(\\d+)/);if(match&&match[1]){const videoId=match[1];return`https://player.vimeo.com/video/${videoId}?autoplay=1&loop=1&muted=1&background=1&controls=0&playsinline=1&playlist=${videoId}`;}return url;};const mode=fillMode;const isCoverWidth=mode===\"coverWidth\";const isCoverHeight=mode===\"coverHeight\";// Native lazy attribute for iframes\nconst iframeLoadingAttr=loadStrategy===\"nativeLazy\"?\"lazy\":loadStrategy===\"eager\"?\"eager\":undefined;return /*#__PURE__*/_jsxs(\"div\",{ref:hostRef,style:{position:\"relative\",width:\"100%\",height:\"100%\",overflow:\"hidden\"},children:[isVimeo&&shouldLoad&&/*#__PURE__*/_jsxs(_Fragment,{children:[/*#__PURE__*/_jsx(\"link\",{rel:\"preconnect\",href:\"https://player.vimeo.com\"}),/*#__PURE__*/_jsx(\"link\",{rel:\"preconnect\",href:\"https://i.vimeocdn.com\"}),/*#__PURE__*/_jsx(\"link\",{rel:\"preconnect\",href:\"https://f.vimeocdn.com\"})]}),isVimeo?// Vimeo: we use a wrapper so we can implement coverWidth/coverHeight deterministically\n/*#__PURE__*/_jsx(\"div\",{style:{position:\"absolute\",left:isCoverHeight?\"50%\":0,top:isCoverWidth?\"50%\":0,// coverWidth: width = 100%, height auto via aspect-ratio, center vertically\nwidth:isCoverWidth?\"100%\":isCoverHeight?\"auto\":\"100%\",height:isCoverHeight?\"100%\":isCoverWidth?\"auto\":\"100%\",aspectRatio:isCoverWidth||isCoverHeight?vimeoAspect:undefined,transform:isCoverWidth?\"translateY(-50%)\":isCoverHeight?\"translateX(-50%)\":\"none\"},children:/*#__PURE__*/_jsx(\"iframe\",{// ✅ ioLazy: don't set src until in/near view\nsrc:shouldLoad?getVimeoEmbedUrl(videoUrl):undefined,allow:\"autoplay; fullscreen; picture-in-picture\",loading:iframeLoadingAttr,onLoad:()=>setIsLoaded(true),style:{width:\"100%\",height:\"100%\",border:\"none\",opacity:isLoaded?1:0,transition:\"opacity 1.2s ease\"}})}):/*#__PURE__*/_jsx(\"video\",{// ✅ ioLazy: don't set src until in/near view\nsrc:shouldLoad?videoUrl:undefined,autoPlay:shouldLoad,loop:true,muted:true,playsInline:true,// eager = auto, lazy strategies = metadata\npreload:loadStrategy===\"eager\"?\"auto\":\"metadata\",onLoadedData:()=>setIsLoaded(true),style:{position:\"absolute\",left:isCoverHeight?\"50%\":0,top:isCoverWidth?\"50%\":0,// coverWidth: width 100% (no side crop), height auto\nwidth:isCoverWidth?\"100%\":isCoverHeight?\"auto\":\"100%\",height:isCoverHeight?\"100%\":isCoverWidth?\"auto\":\"100%\",transform:isCoverWidth?\"translateY(-50%)\":isCoverHeight?\"translateX(-50%)\":\"none\",// cover: classic fill-both\nobjectFit:mode===\"cover\"?\"cover\":\"contain\",opacity:isLoaded?1:0,transition:\"opacity 1.2s ease\"}})]});}addPropertyControls(BackgroundVideo,{videoUrl:{type:ControlType.String,title:\"Video URL\",defaultValue:\"https://framerusercontent.com/assets/MLWPbW1dUQawJLhhun3dBwpgJak.mp4\",placeholder:\"Enter video URL...\"},fillMode:{type:ControlType.Enum,title:\"Fill\",options:[\"cover\",\"coverWidth\",\"coverHeight\"],optionTitles:[\"Cover (crop any)\",\"Cover Width (crop height)\",\"Cover Height (crop width)\"],defaultValue:\"cover\"},vimeoAspect:{type:ControlType.String,title:\"Vimeo Aspect\",defaultValue:\"16 / 9\",hidden:p=>p.fillMode===\"cover\",placeholder:\"16 / 9\"},loadStrategy:{type:ControlType.Enum,title:\"Load\",options:[\"eager\",\"nativeLazy\",\"ioLazy\"],optionTitles:[\"Eager\",\"Native Lazy\",\"IO Lazy (real)\"],defaultValue:\"eager\"},ioRootMargin:{type:ControlType.Number,title:\"IO Margin\",defaultValue:600,min:0,max:4e3,step:50,hidden:p=>p.loadStrategy!==\"ioLazy\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"BackgroundVideo\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"any\",\"framerSupportedLayoutHeight\":\"any\",\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./BackgroundVideo.map"],"mappings":"sMAMG,SAAwB,EAAgB,EAAM,C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