{"version":3,"file":"VideoPlayer.CjABZBdB.mjs","names":["useMemo","useRef","useState"],"sources":["https:/framerusercontent.com/modules/zkuqkBiDGj8ySt9J81op/MJd68YFExQbFUbuqHMZ0/VideoPlayer.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{addPropertyControls,ControlType}from\"framer\";import{useEffect,useMemo,useRef,useState}from\"react\";/**\n * @framerSupportedLayoutWidth fixed\n * @framerSupportedLayoutHeight auto\n */export default function VideoPlayer(props){const{videoType=\"upload\",src=\"https://framerusercontent.com/assets/MLWPbW1dUQawJLhhun3dBwpgJak.mp4\",videoUrl=\"\",posterType=\"upload\",posterImage={src:\"https://framerusercontent.com/images/GfGkADagM4KEibNcIiRUWlfrR0.jpg\",alt:\"VideoPlayer poster\"},posterUrl=\"\",autoPlay=false,loop=false,muted=false,controls=true,playsInline=true,objectFit=\"cover\",lazyLoad=true,borderRadius=0,unloadDelay=1200,style}=props;const videoSrc=useMemo(()=>videoType===\"url\"?videoUrl:src,[videoType,videoUrl,src]);const posterSrc=useMemo(()=>posterType===\"url\"?posterUrl:posterImage?.src,[posterType,posterUrl,posterImage]);const videoRef=useRef(null);// \"seen\" means we load at least once; avoids reloading again and again\nconst[hasEverBeenInView,setHasEverBeenInView]=useState(!lazyLoad);const[isInView,setIsInView]=useState(!lazyLoad);const unloadTimerRef=useRef(null);useEffect(()=>{if(!lazyLoad||typeof window===\"undefined\")return;const el=videoRef.current;if(!el)return;const obs=new IntersectionObserver(([entry])=>{const nowInView=entry.isIntersecting;setIsInView(nowInView);if(nowInView){setHasEverBeenInView(true);// cancel pending unload\nif(unloadTimerRef.current){window.clearTimeout(unloadTimerRef.current);unloadTimerRef.current=null;}}else if(unloadDelay>0){// schedule unload later to prevent thrashing\nif(unloadTimerRef.current)window.clearTimeout(unloadTimerRef.current);unloadTimerRef.current=window.setTimeout(()=>{// trigger unload by flipping hasEverBeenInView off? no — we keep it,\n// we unload by returning src null below.\n// We can force a re-render by setting state:\nsetIsInView(false);},unloadDelay);}},{rootMargin:\"200px 0px\",threshold:.01});obs.observe(el);return()=>{obs.disconnect();if(unloadTimerRef.current){window.clearTimeout(unloadTimerRef.current);unloadTimerRef.current=null;}};},[lazyLoad,unloadDelay]);// Pause when out of view (don’t constantly unload)\nuseEffect(()=>{const v=videoRef.current;if(!v)return;if(!isInView)v.pause();},[isInView]);// Decide whether src should be attached\n// - If lazyLoad: only attach once it has ever been seen\n// - Optionally unload src when offscreen (controlled by unloadDelay)\nconst shouldAttachSrc=!lazyLoad||hasEverBeenInView&&(isInView||unloadDelay===0);return /*#__PURE__*/_jsx(\"video\",{ref:videoRef,src:shouldAttachSrc?videoSrc:undefined,poster:posterSrc,preload:shouldAttachSrc?\"metadata\":\"none\",autoPlay:autoPlay,loop:loop,muted:muted,controls:controls,playsInline:playsInline,style:{width:\"100%\",height:\"auto\",objectFit,borderRadius,display:\"block\",// remove GPU forcing flags unless you truly need them\n...style}});}addPropertyControls(VideoPlayer,{videoType:{type:ControlType.Enum,title:\"Video Type\",options:[\"upload\",\"url\"],defaultValue:\"upload\"},src:{type:ControlType.File,title:\"Video\",allowedFileTypes:[\"mp4\",\"webm\",\"mov\",\"ogg\"],hidden:({videoType})=>videoType===\"url\"},videoUrl:{type:ControlType.String,title:\"Video URL\",hidden:({videoType})=>videoType===\"upload\"},posterType:{type:ControlType.Enum,title:\"Poster Type\",options:[\"upload\",\"url\"],defaultValue:\"upload\"},posterImage:{type:ControlType.ResponsiveImage,title:\"Poster Image\",hidden:({posterType})=>posterType===\"url\"},posterUrl:{type:ControlType.String,title:\"Poster URL\",hidden:({posterType})=>posterType===\"upload\"},lazyLoad:{type:ControlType.Boolean,title:\"Lazy Load\",defaultValue:true},unloadDelay:{type:ControlType.Number,title:\"Unload Delay\",defaultValue:1200,min:0,max:5e3,step:100,unit:\"ms\"},controls:{type:ControlType.Boolean,title:\"Controls\",defaultValue:true},autoPlay:{type:ControlType.Boolean,title:\"Auto Play\",defaultValue:false},loop:{type:ControlType.Boolean,title:\"Loop\",defaultValue:false},muted:{type:ControlType.Boolean,title:\"Muted\",defaultValue:false},playsInline:{type:ControlType.Boolean,title:\"Plays Inline\",defaultValue:true},objectFit:{type:ControlType.Enum,title:\"Object Fit\",options:[\"contain\",\"cover\",\"fill\",\"none\",\"scale-down\"],defaultValue:\"cover\"},borderRadius:{type:ControlType.Number,title:\"Border Radius\",defaultValue:0,min:0,max:100,step:1,unit:\"px\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"VideoPlayer\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"fixed\",\"framerSupportedLayoutHeight\":\"auto\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./VideoPlayer.map"],"mappings":"8MAGG,SAAwB,EAAY,EAAM,CAAC,GAAK,CAAC,YAAU,SAAS,MAAI,uEAAuE,WAAS,GAAG,aAAW,SAAS,cAAY,CAAC,IAAI,sEAAsE,IAAI,qBAAqB,CAAC,YAAU,GAAG,WAAS,GAAM,OAAK,GAAM,QAAM,GAAM,WAAS,GAAK,cAAY,GAAK,YAAU,QAAQ,WAAS,GAAK,eAAa,EAAE,cAAY,KAAK,SAAO,EAAY,EAASA,MAAY,IAAY,MAAM,EAAS,EAAI,CAAC,EAAU,EAAS,EAAI,CAAC,CAAO,EAAUA,MAAY,IAAa,MAAM,EAAU,GAAa,IAAI,CAAC,EAAW,EAAU,EAAY,CAAC,CAAO,EAASC,EAAO,KAAK,CAC1pB,CAAC,EAAkB,GAAsBC,EAAS,CAAC,EAAS,CAAM,CAAC,EAAS,GAAaA,EAAS,CAAC,EAAS,CAAO,EAAeD,EAAO,KAAK,CAAC,MAAc,CAAC,GAAG,CAAC,GAAiB,IAAS,OAAY,OAAO,IAAM,EAAG,EAAS,QAAQ,GAAG,CAAC,EAAG,OAAO,IAAM,EAAI,IAAI,sBAAsB,CAAC,KAAS,CAAC,IAA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