{"version":3,"file":"BackgroundVideo.CE_BccED.mjs","names":["React.useRef","React.useState","_Fragment","p"],"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,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