{"version":3,"file":"LoopVideo.DMweiTda.mjs","names":["useRef","useCallback"],"sources":["https:/framerusercontent.com/modules/kqpArTZOKJhjRSMH0PgD/Vc15TVnbGdvI2apySsUt/LoopVideo.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{addPropertyControls,ControlType,useIsStaticRenderer}from\"framer\";import{useCallback,useRef}from\"react\";/**\n * Lightweight replacement for Lottie animations: a muted, inline MP4 that\n * only downloads when it comes near the viewport and pauses when off-screen.\n *\n * Everything after the first render is handled directly on the <video>\n * element (no React state), so hydration is never interrupted.\n *\n * @framerIntrinsicWidth 600\n * @framerIntrinsicHeight 400\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight any-prefer-fixed\n */export default function LoopVideo(props){const{video,poster,label=\"\",loop=true,lazy=true,fit=\"contain\",background=\"rgba(0,0,0,0)\",radius=0,style}=props;const isStatic=useIsStaticRenderer();const cleanup=useRef(null);const posterSrc=poster?.src;const attach=useCallback(el=>{cleanup.current?.();cleanup.current=null;if(!el||isStatic||typeof window===\"undefined\"||!video)return;const reduceMotion=window.matchMedia?.(\"(prefers-reduced-motion: reduce)\").matches??false;el.muted=true;const load=()=>{if(el.getAttribute(\"src\"))return;if(posterSrc)el.poster=posterSrc;el.preload=\"auto\";el.src=video;};const play=()=>{if(reduceMotion||el.ended&&!loop)return;load();el.play().catch(()=>{});};// Without motion, show the finished state of one-shot animations.\nconst onMeta=()=>{if(reduceMotion&&!loop&&Number.isFinite(el.duration))el.currentTime=el.duration;};el.addEventListener(\"loadedmetadata\",onMeta);if(reduceMotion)el.pause();if(typeof IntersectionObserver===\"undefined\"){play();cleanup.current=()=>el.removeEventListener(\"loadedmetadata\",onMeta);return;}// Start downloading shortly before the video scrolls into view. Copies hidden on\n// other breakpoints never intersect, so they never download anything.\nconst loader=new IntersectionObserver(entries=>{if(entries.some(e=>e.isIntersecting)){load();loader.disconnect();}},{rootMargin:\"400px 0px\"});// Only play while visible.\nconst player=new IntersectionObserver(entries=>{if(entries.some(e=>e.isIntersecting))play();else el.pause();});loader.observe(el);player.observe(el);cleanup.current=()=>{loader.disconnect();player.disconnect();el.removeEventListener(\"loadedmetadata\",onMeta);};},[video,posterSrc,lazy,loop,isStatic]);// The poster is in the HTML for hero videos (lazy off); the video file itself is only\n// requested once, from the breakpoint that is actually visible.\nconst showPoster=!lazy||isStatic;return /*#__PURE__*/_jsx(\"video\",{ref:attach,poster:showPoster?posterSrc:undefined,\"aria-label\":label||undefined,\"aria-hidden\":label?undefined:true,muted:true,playsInline:true,loop:loop,preload:\"none\",disablePictureInPicture:true,style:{...style,position:\"relative\",display:\"block\",width:\"100%\",height:\"100%\",objectFit:fit,background,borderRadius:radius,pointerEvents:\"none\"}});}addPropertyControls(LoopVideo,{video:{type:ControlType.File,title:\"Video\",allowedFileTypes:[\"mp4\",\"webm\"]},poster:{type:ControlType.ResponsiveImage,title:\"Poster\"},label:{type:ControlType.String,title:\"Label\",placeholder:\"Describe the animation (leave empty if decorative)\",defaultValue:\"\"},loop:{type:ControlType.Boolean,title:\"Loop\",defaultValue:true},lazy:{type:ControlType.Boolean,title:\"Lazy Load\",description:\"Turn off for videos in the first screen (hero).\",defaultValue:true},fit:{type:ControlType.Enum,title:\"Fit\",options:[\"contain\",\"cover\"],optionTitles:[\"Contain\",\"Cover\"],displaySegmentedControl:true,defaultValue:\"contain\"},background:{type:ControlType.Color,title:\"Background\",defaultValue:\"rgba(0,0,0,0)\"},radius:{type:ControlType.Number,title:\"Radius\",min:0,max:100,unit:\"px\",defaultValue:0}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"LoopVideo\",\"slots\":[],\"annotations\":{\"framerIntrinsicHeight\":\"400\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerSupportedLayoutHeight\":\"any-prefer-fixed\",\"framerIntrinsicWidth\":\"600\",\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}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