{"version":3,"file":"SlideshowWithTimeline.CsuMSyMA.mjs","names":["useMemo","useState","useRef"],"sources":["https:/framerusercontent.com/modules/aFBp3IjMwtxUJ7AEgrHc/kTelSQGRhiQ35HgRmKhJ/SlideshowWithTimeline.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useEffect,useState,useRef,startTransition,useMemo}from\"react\";import{addPropertyControls,ControlType}from\"framer\";import{useInView}from\"framer-motion\";/*\nUser goal: generate an image slide show which loops selected images automatically with horizontal timeline bars showing slideshow progress.\n\n@framerIntrinsicWidth 800\n@framerIntrinsicHeight 450\n\n@framerSupportedLayoutWidth any-prefer-fixed\n@framerSupportedLayoutHeight any-prefer-fixed\n*/export default function SlideshowWithTimeline(props){const{images,duration,backgroundColor,barBackgroundColor,barFillColor,borderRadius,pauseOnHover,style,timeOverlayTextColor,timeOverlayBackgroundColor}=props;const validImages=useMemo(()=>Array.isArray(images)&&images.length>0?images:[],[images]);const[currentIndex,setCurrentIndex]=useState(0);const[progress,setProgress]=useState(0);const[paused,setPaused]=useState(false);const containerRef=useRef(null);const inView=useInView(containerRef,{amount:.2});useEffect(()=>{if(!inView||paused||validImages.length===0)return;if(duration<=0)return;let frameId;const startTime=typeof performance!==\"undefined\"?performance.now():Date.now();const loop=now=>{const currentTime=typeof performance!==\"undefined\"?now:Date.now();const elapsed=currentTime-startTime;const totalDurationMs=duration*1e3;const newProgress=Math.min(elapsed/totalDurationMs,1);startTransition(()=>{setProgress(newProgress);});if(newProgress<1){frameId=requestAnimationFrame(loop);}else{startTransition(()=>{setCurrentIndex(prev=>{const nextIndex=(prev+1)%validImages.length;return nextIndex;});setProgress(0);});}};frameId=requestAnimationFrame(loop);return()=>{if(typeof cancelAnimationFrame!==\"undefined\"){cancelAnimationFrame(frameId);}};},[currentIndex,inView,paused,duration,validImages.length]);const handleMouseEnter=()=>{if(!pauseOnHover)return;startTransition(()=>setPaused(true));};const handleMouseLeave=()=>{if(!pauseOnHover)return;startTransition(()=>setPaused(false));};const isFixedWidth=style&&style.width===\"100%\";const isFixedHeight=style&&style.height===\"100%\";const wrapperStyle={position:\"relative\",overflow:\"hidden\",borderRadius,backgroundColor,width:\"100%\",height:\"100%\",...style,...isFixedWidth?{}:{minWidth:\"max-content\"},...isFixedHeight?{}:{}};const currentImage=validImages.length>0?validImages[currentIndex]:undefined;const remainingSeconds=useMemo(()=>duration>0?Math.max(0,duration*(1-progress)):0,[duration,progress]);const formattedRemaining=useMemo(()=>`${remainingSeconds.toFixed(1)}s`,[remainingSeconds]);return /*#__PURE__*/_jsx(\"div\",{ref:containerRef,style:wrapperStyle,onMouseEnter:handleMouseEnter,onMouseLeave:handleMouseLeave,children:/*#__PURE__*/_jsxs(\"div\",{style:{position:\"relative\",width:\"100%\",height:\"100%\",overflow:\"hidden\"},children:[currentImage?/*#__PURE__*/_jsx(\"img\",{src:currentImage.src,srcSet:currentImage.srcSet,alt:currentImage.alt||\"\",style:{width:\"100%\",height:\"100%\",objectFit:\"cover\",display:\"block\"}}):/*#__PURE__*/_jsx(\"div\",{style:{width:\"100%\",height:\"100%\",display:\"flex\",alignItems:\"center\",justifyContent:\"center\",color:\"#CCCCCC\",fontSize:14},children:\"Add images to start slideshow\"}),currentImage&&duration>0&&/*#__PURE__*/_jsx(\"div\",{style:{position:\"absolute\",bottom:12,right:12,padding:\"4px 8px\",borderRadius:999,backgroundColor:timeOverlayBackgroundColor,color:timeOverlayTextColor,fontSize:12,fontWeight:500,pointerEvents:\"none\"},\"aria-hidden\":\"true\",children:formattedRemaining}),validImages.length>0&&/*#__PURE__*/_jsx(\"div\",{style:{position:\"absolute\",left:0,right:0,bottom:0,padding:\"8px 12px 10px 12px\",boxSizing:\"border-box\",display:\"flex\",gap:6,pointerEvents:\"none\"},\"aria-hidden\":\"true\",children:validImages.map((_,index)=>{let fillPercent=0;if(index<currentIndex)fillPercent=100;else if(index===currentIndex)fillPercent=Math.max(0,Math.min(progress*100,100));else fillPercent=0;return /*#__PURE__*/_jsx(\"div\",{style:{flex:1,height:4,borderRadius:999,backgroundColor:barBackgroundColor,overflow:\"hidden\"},children:/*#__PURE__*/_jsx(\"div\",{style:{width:`${fillPercent}%`,height:\"100%\",borderRadius:999,backgroundColor:barFillColor,transition:index===currentIndex?\"width 0.1s linear\":\"width 0.25s ease-out\"}})},index);})})]})});}addPropertyControls(SlideshowWithTimeline,{images:{type:ControlType.Array,title:\"Images\",maxCount:10,control:{type:ControlType.ResponsiveImage},defaultValue:[{src:\"https://framerusercontent.com/images/f9RiWoNpmlCMqVRIHz8l8wYfeI.jpg\",alt:\"Slide 1\"},{src:\"https://framerusercontent.com/images/2uTNEj5aTl2K3NJaEFWMbnrA.jpg\",alt:\"Slide 2\"},{src:\"https://framerusercontent.com/images/BYnxEV1zjYb9bhWh1IwBZ1ZoS60.jpg\",alt:\"Slide 3\"}]},duration:{type:ControlType.Number,title:\"Duration\",defaultValue:5,min:1,max:20,step:.5,unit:\"s\"},backgroundColor:{type:ControlType.Color,title:\"Background\",defaultValue:\"#000000\"},barBackgroundColor:{type:ControlType.Color,title:\"Bar BG\",defaultValue:\"rgba(0,0,0,0)\"},barFillColor:{type:ControlType.Color,title:\"Bar Fill\",defaultValue:\"#000000\"},borderRadius:{type:ControlType.Number,title:\"Radius\",defaultValue:12,min:0,max:40,step:1},pauseOnHover:{type:ControlType.Boolean,title:\"Pause Hover\",defaultValue:true,enabledTitle:\"On\",disabledTitle:\"Off\"},timeOverlayTextColor:{type:ControlType.Color,title:\"Time Text\",defaultValue:\"#FFFFFF\"},timeOverlayBackgroundColor:{type:ControlType.Color,title:\"Time BG\",defaultValue:\"rgba(0,0,0,0.6)\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"SlideshowWithTimeline\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerSupportedLayoutHeight\":\"any-prefer-fixed\",\"framerIntrinsicWidth\":\"800\",\"framerI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