{"version":3,"file":"FilmLoop.DTu7FCi1.mjs","names":["useRef","useState","__esmMin","init_ssg_sandbox_shims","init_npm_react_18_3_1","_e","de","p","ce","window","addPropertyControls","init_framer_DcGZRLrs","RenderTarget","ControlType","FilmLoop","props","ref","wrap","near","setNear","reduce","setReduce","onCanvas","el","io","entry","v","play","src","enter","leave","fill","fit","showVideo","radius","poster","init_FilmLoop","init_jsx_runtime"],"sources":["https:/framerusercontent.com/modules/XlQeRavjvnvpnrrhOio1/kI7oMhKu6lSLUaMk6XOg/FilmLoop.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useEffect,useRef,useState}from\"react\";import{addPropertyControls,ControlType,RenderTarget}from\"framer\";/**\n * Muted looping film clip with a poster still. Loads only near the viewport,\n * pauses offscreen, and shows just the poster under reduced motion.\n *\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight any-prefer-fixed\n */export default function FilmLoop(props){const{src=\"\",poster,play=\"inView\",fit=\"cover\",radius=0}=props;const ref=useRef(null);const wrap=useRef(null);const[near,setNear]=useState(false);const[reduce,setReduce]=useState(false);const onCanvas=RenderTarget.current()===RenderTarget.canvas;useEffect(()=>{if(typeof window===\"undefined\")return;setReduce(window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches);const el=wrap.current;if(!el||!(\"IntersectionObserver\"in window)){setNear(true);return;}const io=new IntersectionObserver(([entry])=>{const v=ref.current;if(entry.isIntersecting)setNear(true);if(!v||play!==\"inView\")return;if(entry.isIntersecting)v.play().catch(()=>{});else v.pause();},{rootMargin:\"200px\"});io.observe(el);return()=>io.disconnect();},[play]);useEffect(()=>{const v=ref.current;if(v&&near&&play===\"inView\")v.play().catch(()=>{});},[near,play,src]);const enter=()=>play===\"hover\"&&ref.current?.play().catch(()=>{});const leave=()=>{if(play!==\"hover\"||!ref.current)return;ref.current.pause();ref.current.currentTime=0;};const fill={position:\"absolute\",inset:0,width:\"100%\",height:\"100%\",objectFit:fit,display:\"block\"};const showVideo=!!src&&!reduce&&!onCanvas;return /*#__PURE__*/_jsxs(\"div\",{ref:wrap,onMouseEnter:enter,onMouseLeave:leave,style:{position:\"relative\",width:\"100%\",height:\"100%\",overflow:\"hidden\",borderRadius:radius,...props.style},children:[poster?.src&&/*#__PURE__*/_jsx(\"img\",{src:poster.src,srcSet:poster.srcSet,alt:poster.alt||\"\",style:fill,decoding:\"async\"}),showVideo&&/*#__PURE__*/_jsx(\"video\",{ref:ref,src:near?src:undefined,muted:true,loop:true,playsInline:true,preload:\"none\",\"aria-hidden\":true,style:fill})]});}addPropertyControls(FilmLoop,{src:{type:ControlType.File,title:\"Video\",allowedFileTypes:[\"mp4\",\"webm\",\"mov\"]},poster:{type:ControlType.ResponsiveImage,title:\"Poster\"},play:{type:ControlType.Enum,title:\"Play\",options:[\"inView\",\"hover\"],optionTitles:[\"In view\",\"On hover\"],defaultValue:\"inView\",displaySegmentedControl:true},fit:{type:ControlType.Enum,title:\"Fit\",options:[\"cover\",\"contain\"],defaultValue:\"cover\",displaySegmentedControl:true},radius:{type:ControlType.Number,title:\"Radius\",defaultValue:0,min:0,max:40,unit:\"px\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"FilmLoop\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerSupportedLayoutHeight\":\"any-prefer-fixed\",\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./FilmLoop.map"],"mappings":"A,2MAMG,SAAwBc,EAAS,EAAM,CAAC,GAAK,CAAC,MAAI,GAAG,SAAO,OAAK,SAAS,MAAI,QAAQ,SAAO,GAAGC,EAAYC,EAAIhB,EAAO,IAAI,EAAQiB,EAAKjB,EAAO,IAAI,EAAO,CAACkB,EAAKC,GAASlB,EAAS,EAAK,EAAO,CAACmB,EAAOC,GAAWpB,EAAS,EAAK,EAAQqB,EAASV,E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