{"version":3,"file":"LoopVideo.Cbd_KeaN.mjs","names":["useRef","useState"],"sources":["https:/framerusercontent.com/modules/TmlrnBuLSGA8iQZiZXNl/Vl8jpNNZ7737VzVgweqs/LoopVideo.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{addPropertyControls,ControlType,useIsStaticRenderer}from\"framer\";import{useEffect,useRef,useState}from\"react\";/**\n * LoopVideo — a silent background loop laid over a photo.\n * The photo underneath stays as the poster: the video loads after the page has finished loading,\n * fades in once it is actually playing, pauses when it scrolls out of view, and is skipped\n * entirely for visitors who prefer reduced motion.\n *\n * @framerSupportedLayoutWidth fixed\n * @framerSupportedLayoutHeight fixed\n */export default function LoopVideo(props){const{video=\"\",focus=\"50% 50%\",fade=1.2}=props;const isStatic=useIsStaticRenderer();const ref=useRef(null);const[src,setSrc]=useState(\"\");const[playing,setPlaying]=useState(false);// Load after the page (and its photos) have loaded, unless motion is reduced.\nuseEffect(()=>{if(isStatic||!video)return;if(window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches)return;let t=0;const go=()=>{t=window.setTimeout(()=>setSrc(video),250);};if(document.readyState===\"complete\")go();else window.addEventListener(\"load\",go,{once:true});return()=>{window.clearTimeout(t);window.removeEventListener(\"load\",go);};},[isStatic,video]);// Only play while on screen.\nuseEffect(()=>{const el=ref.current;if(!el||!src)return;const io=new IntersectionObserver(([e])=>{if(e.isIntersecting)el.play().catch(()=>{});else el.pause();},{threshold:.05});io.observe(el);return()=>io.disconnect();},[src]);if(isStatic||!video)return /*#__PURE__*/_jsx(\"div\",{\"aria-hidden\":\"true\",style:{...props.style,pointerEvents:\"none\"}});return /*#__PURE__*/_jsx(\"div\",{\"aria-hidden\":\"true\",style:{...props.style,position:\"relative\",overflow:\"hidden\",pointerEvents:\"none\"},children:/*#__PURE__*/_jsx(\"video\",{ref:ref,src:src||undefined,muted:true,loop:true,playsInline:true,autoPlay:true,preload:src?\"auto\":\"none\",disablePictureInPicture:true,onPlaying:()=>setPlaying(true),style:{position:\"absolute\",inset:0,width:\"100%\",height:\"100%\",objectFit:\"cover\",objectPosition:focus,opacity:playing?1:0,transition:`opacity ${fade}s ease`}})});}addPropertyControls(LoopVideo,{video:{type:ControlType.File,title:\"Video\",allowedFileTypes:[\"mp4\",\"webm\",\"mov\"]},focus:{type:ControlType.String,title:\"Focus\",defaultValue:\"50% 50%\",description:\"Which part stays in view when cropped, e.g. 50% 60%.\"},fade:{type:ControlType.Number,title:\"Fade in\",defaultValue:1.2,min:0,max:4,step:.1,unit:\"s\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"LoopVideo\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"fixed\",\"framerSupportedLayoutWidth\":\"fixed\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./LoopVideo.map"],"mappings":"8MAQG,SAAwB,EAAU,EAAM,CAAC,GAAK,CAAC,QAAM,GAAG,QAAM,UAAU,OAAK,KAAK,EAAY,EAAS,EAAoB,EAAQ,EAAIA,EAAO,IAAI,EAAO,CAAC,EAAI,GAAQC,EAAS,EAAE,EAAO,CAAC,EAAQ,GAAYA,EAAS,EAAK,EAE4H,OAD1V,MAAc,CAA4B,GAAxB,GAAU,CAAC,GAAgB,EAAO,WAAW,kCAAkC,CAAC,CAAC,QAAQ,OAAO,IAAI,EAAE,EAAQ,MAAO,CAAC,EAAE,EAAO,eAAe,EAAO,CAAK,EAAE,GAAG,CAAE,EAA+F,OAA1F,SAAS,aAAa,WAAW,EAAG,EAAO,EAAO,iBAAiB,OAAO,EAAG,CAAC,KAAK,EAAI,CAAC,MAAY,CAAC,EAAO,aAAa,CAAC,EAAE,EAAO,oBAAoB,OAAO,CAAE,CAAE,CAAE,EAAE,CAAC,EAAS,CAAK,CAAC,EAC9W,MAAc,CAAC,IAAM,EAAG,EAAI,QAAQ,GAAG,CAAC,GAAI,CAAC,EAAI,OA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