{"version":3,"file":"Carousel.CSvEXBCH.mjs","names":["React.useState","React.useRef","current"],"sources":["https:/framerusercontent.com/modules/u4AcYpSdv8qyz5r5PEYx/oSKlxoM1eWhMJ8SvaNRP/Carousel.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import*as React from\"react\";import{motion,AnimatePresence}from\"framer-motion\";import{addPropertyControls,ControlType}from\"framer\";export function AutoCarousel(props){const{imageDuration,showControlsWrap,controlsWrapPosition,showProgress,progressBarContainerWidth,progressBarGap,progressBarHeight,progressBarBackgroundOpacity,showPlayPause,playIcon,pauseIcon,customImage1,customImage2,customImage3,media:originalMedia}=props;const[current,setCurrent]=React.useState(0);const[isPlaying,setIsPlaying]=React.useState(true);const[videoDurations,setVideoDurations]=React.useState({})// To store video durations\n;const videoRefs=React.useRef([])// Store refs for videos\n;// Combine media, prioritize videos, and include CMS images\nconst media=[...originalMedia.map(item=>{if(item.video){return{src:item.video,type:\"video\",alt:item.alt||\"Video\"};}else if(item.image){return{src:item.image,type:\"image\",alt:item.alt||\"Image\"};}return null;}),{src:customImage1,type:\"image\",alt:\"CMS Image 1\"},{src:customImage2,type:\"image\",alt:\"CMS Image 2\"},{src:customImage3,type:\"image\",alt:\"CMS Image 3\"}].filter(item=>item&&item.src);const mediaCount=media.length>0?media.length:1;React.useEffect(()=>{let timeout;// Determine duration for the current slide\nconst currentMedia=media[current];const duration=(currentMedia===null||currentMedia===void 0?void 0:currentMedia.type)===\"video\"&&videoDurations[current]?videoDurations[current]*1e3// Video duration in milliseconds\n:imageDuration*1e3;if(isPlaying&&media.length>0){timeout=setTimeout(()=>{setCurrent(current=>(current+1)%mediaCount);},duration);// Ensure videos play when their slide is active\nif((currentMedia===null||currentMedia===void 0?void 0:currentMedia.type)===\"video\"&&videoRefs.current[current]){videoRefs.current[current].currentTime=0// Reset to the start\n;videoRefs.current[current].play()// Play the video\n;}}return()=>timeout&&clearTimeout(timeout);},[current,mediaCount,isPlaying,media,imageDuration,videoDurations]);const handleVideoLoaded=(index,duration)=>{setVideoDurations(prev=>({...prev,[index]:duration}));};const togglePlayPause=()=>setIsPlaying(!isPlaying);return /*#__PURE__*/_jsxs(\"div\",{style:{width:\"100%\",height:\"100%\",position:\"relative\"},children:[media.length===0?/*#__PURE__*/_jsx(\"div\",{style:{display:\"flex\",alignItems:\"center\",justifyContent:\"center\",height:\"100%\",color:\"#888\",backgroundColor:\"#eee\",fontSize:\"20px\"},children:\"Add your media\"}):/*#__PURE__*/_jsx(AnimatePresence,{children:media.map((item,index)=>item.type===\"video\"?/*#__PURE__*/_jsx(motion.video,{ref:el=>videoRefs.current[index]=el,src:item.src,title:item.alt||\"Carousel video\",muted:true,loop:false,onLoadedMetadata:e=>handleVideoLoaded(index,e.target.duration),initial:{opacity:0},animate:{opacity:index===current?1:0},exit:{opacity:0},transition:{duration:.5},style:{position:\"absolute\",width:\"100%\",height:\"100%\",top:0,left:0,objectFit:\"cover\"}},index):/*#__PURE__*/_jsx(motion.img,{src:item.src,alt:item.alt||\"Carousel image\",loading:\"lazy\",initial:{opacity:0},animate:{opacity:index===current?1:0},exit:{opacity:0},transition:{duration:.5},style:{position:\"absolute\",width:\"100%\",height:\"100%\",top:0,left:0,objectFit:\"cover\"}},index))}),showControlsWrap&&/*#__PURE__*/_jsxs(\"div\",{style:{display:\"flex\",justifyContent:\"space-between\",alignItems:\"center\",width:\"100%\",position:\"absolute\",[controlsWrapPosition]:0,padding:\"10px\"},children:[showPlayPause&&/*#__PURE__*/_jsx(\"button\",{style:{background:\"none\",border:\"none\",cursor:\"pointer\"},onClick:togglePlayPause,children:/*#__PURE__*/_jsx(\"img\",{src:isPlaying?pauseIcon||defaultPauseIcon:playIcon||defaultPlayIcon,alt:\"Play/Pause\",style:{width:32,height:32}})}),showProgress&&media.length>0&&/*#__PURE__*/_jsx(\"div\",{style:{display:\"flex\",justifyContent:\"center\",gap:progressBarGap,width:progressBarContainerWidth},children:media.map((_,index)=>/*#__PURE__*/_jsx(\"div\",{onClick:()=>setCurrent(index),style:{flex:1,cursor:\"pointer\",position:\"relative\",padding:\"8px 0\"},children:/*#__PURE__*/_jsx(\"div\",{style:{height:progressBarHeight,backgroundColor:`rgba(255, 255, 255, ${progressBarBackgroundOpacity})`,position:\"relative\"},children:/*#__PURE__*/_jsx(motion.div,{initial:{width:\"0%\"},animate:{width:index===current&&isPlaying?\"100%\":\"0%\"},transition:{duration:index===current&&isPlaying?videoDurations[index]||imageDuration:0,ease:\"linear\"},style:{height:\"100%\",backgroundColor:\"#FFF\",position:\"absolute\",top:0,left:0}},current===index?\"active\":\"inactive\")})},index))})]})]});}AutoCarousel.defaultProps={media:[],imageDuration:3,showControlsWrap:true,controlsWrapPosition:\"bottom\",showProgress:true,progressBarContainerWidth:\"50%\",progressBarGap:6,progressBarHeight:2,progressBarBackgroundOpacity:.4,showPlayPause:true,playIcon:\"\",pauseIcon:\"\"};addPropertyControls(AutoCarousel,{media:{type:ControlType.Array,control:{type:ControlType.Object,controls:{image:{type:ControlType.Image,title:\"Image\"},video:{type:ControlType.File,title:\"Video\",allowedFileTypes:[\"mp4\",\"webm\",\"ogg\"]},alt:{type:ControlType.String,title:\"Alt/Title\"}}},maxCount:10,title:\"Media\"},imageDuration:{type:ControlType.Number,title:\"Image Duration (s)\",defaultValue:3,min:1,max:10,step:1},showControlsWrap:{type:ControlType.Boolean,title:\"Show Controls\",defaultValue:true},controlsWrapPosition:{type:ControlType.Enum,title:\"Controls Position\",options:[\"top\",\"bottom\"],defaultValue:\"bottom\"},showProgress:{type:ControlType.Boolean,title:\"Show Progress\",defaultValue:true},progressBarContainerWidth:{type:ControlType.String,title:\"Progress Bar Width\",defaultValue:\"50%\"},progressBarGap:{type:ControlType.Number,title:\"Progress Bar Gap\",defaultValue:6,min:0,max:50},progressBarHeight:{type:ControlType.Number,title:\"Progress Bar Height\",defaultValue:2,min:1,max:20},progressBarBackgroundOpacity:{type:ControlType.Number,title:\"Bar Background\",defaultValue:.4,min:0,max:1},showPlayPause:{type:ControlType.Boolean,title:\"Show Play/Pause\",defaultValue:true},playIcon:{type:ControlType.Image,title:\"Play Icon\"},pauseIcon:{type:ControlType.Image,title:\"Pause Icon\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"AutoCarousel\":{\"type\":\"reactComponent\",\"name\":\"AutoCarousel\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Carousel.map"],"mappings":"wPAA2L,SAAgB,EAAa,EAAM,CAAC,GAAK,CAAC,gBAAc,mBAAiB,uBAAqB,eAAa,4BAA0B,iBAAe,oBAAkB,+BAA6B,gBAAc,WAAS,YAAU,eAAa,eAAa,eAAa,MAAM,GAAe,EAAW,CAAC,EAAQ,GAAYA,EAAe,EAAE,CAAM,CAAC,EAAU,GAAcA,EAAe,GAAK,CAAM,CAAC,EAAe,GAAmBA,EAAe,EAAE,CAAC,CACnnB,EAAUC,EAAa,EAAE,CAAC,CAE3B,EAAM,CAAC,GAAG,EAAc,IAAI,GAAU,EAAK,MAAa,CAAC,IAAI,EAAK,MAAM,KAAK,QAAQ,IAAI,EAAK,KAAK,QAAQ,CAAU,EAAK,MAAa,CAAC,IAAI,EAAK,MAAM,KAAK,QAAQ,IAAI,EAAK,KAAK,QAAQ,CAAS,KAAO,CAAC,CAAC,IAAI,EAAa,KAAK,QAAQ,IAAI,cAAc,CAAC,CAAC,IAAI,EAAa,KAAK,QAAQ,IAAI,cAAc,CAAC,CAAC,IAAI,EAAa,KAAK,QAAQ,IAAI,cAAc,CAAC,CAAC,OAAO,GAAM,GAAM,EAAK,IAAI,CAAO,EAAW,EAAM,OAAO,EAAE,EAAM,OAAO,EAAE,MAAoB,CAAC,IAAI,EACvc,EAAa,EAAM,GAAe,EAAU,GAA+D,OAAQ,SAAS,EAAe,GAAS,EAAe,GAAS,IACjL,EAAc,IAGZ,OAHmB,GAAW,EAAM,OAAO,IAAG,EAAQ,eAAe,CAAC,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