{"version":3,"file":"VideoPlayerOnce.Ar9AcFQ9.mjs","names":["useRef","useState"],"sources":["https:/framerusercontent.com/modules/SndVJyPQgW1twRJRXzeQ/TTSZFRCMGqDdqxTV9eqQ/VideoPlayerOnce.js"],"sourcesContent":["// Play video once when it enters viewport, then show poster only\nimport{jsx as _jsx}from\"react/jsx-runtime\";import{useRef,useEffect,useState,startTransition}from\"react\";import{addPropertyControls,ControlType,useInView}from\"framer\";/**\n * Video Once In View\n *\n * Plays video once when it enters viewport, then shows poster only\n *\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight any-prefer-fixed\n */export default function VideoPlayerOnce(props){const{videoFile=\"https://framerusercontent.com/assets/MLWPbW1dUQawJLhhun3dBwpgJak.mp4\",posterImage={src:\"https://framerusercontent.com/images/GfGkADagM4KEibNcIiRUWlfrR0.jpg\",alt:\"Poster\"},style}=props;const videoRef=useRef(null);const[played,setPlayed]=useState(false);const inView=useInView(videoRef);useEffect(()=>{if(!played&&inView&&videoRef.current){videoRef.current.play();}},[inView,played]);useEffect(()=>{const vid=videoRef.current;if(!vid)return;const handleEnded=()=>{startTransition(()=>setPlayed(true));};vid.addEventListener(\"ended\",handleEnded);return()=>vid.removeEventListener(\"ended\",handleEnded);},[]);if(played){return /*#__PURE__*/_jsx(\"img\",{src:posterImage.src,alt:posterImage.alt,style:{width:\"100%\",height:\"100%\",objectFit:\"cover\",display:\"block\",...style}});}return /*#__PURE__*/_jsx(\"video\",{ref:videoRef,src:videoFile,poster:posterImage.src,style:{width:\"100%\",height:\"100%\",objectFit:\"cover\",display:\"block\",...style},playsInline:true,muted:true,controls:false});}addPropertyControls(VideoPlayerOnce,{videoFile:{type:ControlType.File,allowedFileTypes:[\"mp4\",\"webm\",\"mov\"]},posterImage:{type:ControlType.ResponsiveImage,title:\"Poster Image\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"VideoPlayerOnce\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutHeight\":\"any-prefer-fixed\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./VideoPlayerOnce.map"],"mappings":"yOAQG,SAAwB,EAAgB,EAAM,CAAC,GAAK,CAAC,YAAU,uEAAuE,cAAY,CAAC,IAAI,sEAAsE,IAAI,SAAS,CAAC,SAAO,EAAY,EAASA,EAAO,KAAK,CAAM,CAAC,EAAO,GAAWC,EAAS,GAAM,CAAO,EAAO,EAAU,EAAS,CAAoe,OAAne,MAAc,CAAI,CAAC,GAAQ,GAAQ,EAAS,SAAS,EAAS,QAAQ,MAAM,EAAI,CAAC,EAAO,EAAO,CAAC,CAAC,MAAc,CAAC,IAAM,EAAI,EAAS,QAAQ,GAAG,CAAC,EAAI,OAAO,IAAM,MAAgB,CAAC,MAAoB,EAAU,GAAK,CAAC,EAA6C,OAA1C,EAAI,iBAAiB,QAAQ,EAAY,KAAW,EAAI,oBAAoB,QAAQ,EAAY,EAAG,EAAE,CAAC,CAAI,EAA4B,EAAK,MAAM,CAAC,IAAI,EAAY,IAAI,IAAI,EAAY,IAAI,MAAM,CAAC,MAAM,OAAO,OAAO,OAAO,UAAU,QAAQ,QAAQ,QAAQ,GAAG,EAAM,CAAC,CAAC,CAAsB,EAAK,QAAQ,CAAC,IAAI,EAAS,IAAI,EAAU,OAAO,EAAY,IAAI,MAAM,CAAC,MAAM,OAAO,OAAO,OAAO,UAAU,QAAQ,QAAQ,QAAQ,GAAG,EAAM,CAAC,YAAY,GAAK,MAAM,GAAK,SAAS,GAAM,CAAC,kBAPt+B,IAA6D,IAA8D,CAO62B,EAAoB,EAAgB,CAAC,UAAU,CAAC,KAAK,EAAY,KAAK,iBAAiB,CAAC,MAAM,OAAO,MAAM,CAAC,CAAC,YAAY,CAAC,KAAK,EAAY,gBAAgB,MAAM,eAAe,CAAC,CAAC"}