{"version":3,"file":"CustomSlideshow.BiTvqDBe.mjs","names":["useRef","useState","useMemo"],"sources":["https:/framerusercontent.com/modules/FP2Y5O5PDCNJessevqM1/6zvc5uzx6MX61aKYhHbB/CustomSlideshow.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useState,useRef,useEffect,useMemo}from\"react\";import{addPropertyControls,ControlType,motion,useMotionValue,useAnimation,Frame,useIsStaticRenderer}from\"framer\";export default function InfiniteTicker(props){const{gap=40,speed=20,direction=\"left\",width=\"100%\",height=60,contentFrames=[],...rest}=props;const containerRef=useRef(null);const itemsContainerRef=useRef(null);const observerRef=useRef(null);const[contentWidth,setContentWidth]=useState(0);const[containerWidth,setContainerWidth]=useState(0);const[isDragging,setIsDragging]=useState(false);const[isHovering,setIsHovering]=useState(false);const[duplicates,setDuplicates]=useState(1);const[isInView,setIsInView]=useState(false);const pausedX=useRef(null);const isMobile=useRef(false);const isStatic=useIsStaticRenderer();const x=useMotionValue(0);const controls=useAnimation();// Disable image dragging\nconst disableImageDrag=img=>{img.draggable=false;img.style.userSelect=\"none\";img.style.webkitUserDrag=\"none\";};const handleImages=container=>{const images=container.getElementsByTagName(\"img\");Array.from(images).forEach(disableImageDrag);};// Intersection Observer for performance optimization\nuseEffect(()=>{if(isStatic||!containerRef.current)return;const observer=new IntersectionObserver(entries=>{entries.forEach(entry=>{setIsInView(entry.isIntersecting);});},{threshold:.1,rootMargin:\"50px\"});observer.observe(containerRef.current);return()=>observer.disconnect();},[isStatic]);// Handle images and mutations\nuseEffect(()=>{if(isStatic||!itemsContainerRef.current)return;handleImages(itemsContainerRef.current);observerRef.current=new MutationObserver(mutations=>{mutations.forEach(mutation=>{if(mutation.type===\"childList\"){handleImages(itemsContainerRef.current);}});});observerRef.current.observe(itemsContainerRef.current,{childList:true,subtree:true});return()=>{if(observerRef.current){observerRef.current.disconnect();}};},[contentFrames,isStatic]);// Update container width on resize\nuseEffect(()=>{if(isStatic||!containerRef.current)return;const updateWidths=()=>{setContentWidth(0)// Reset to trigger recalculation\n;setContainerWidth(containerRef.current.offsetWidth);if(typeof window!==\"undefined\"){isMobile.current=window.innerWidth<=768;}};updateWidths();if(typeof window!==\"undefined\"){window.addEventListener(\"resize\",updateWidths);return()=>window.removeEventListener(\"resize\",updateWidths);}},[isStatic]);// Calculate content width and duplicates\nuseEffect(()=>{if(isStatic||!itemsContainerRef.current||!containerWidth)return;const singleSetWidth=itemsContainerRef.current.scrollWidth/duplicates;setContentWidth(singleSetWidth);const neededDuplicates=Math.max(3,Math.ceil(containerWidth*2/singleSetWidth));setDuplicates(neededDuplicates);},[containerWidth,contentFrames,gap,duplicates,isStatic]);// Handle infinite scroll effect\nconst handleDrag=()=>{if(!contentWidth)return;const currentX=x.get();const totalWidth=contentWidth;if(currentX>0){x.set(currentX-totalWidth);}else if(currentX<-totalWidth){x.set(currentX+totalWidth);}// Store current position during drag\npausedX.current=x.get();};// Animation control\nuseEffect(()=>{if(isStatic||!contentWidth||!containerWidth||contentFrames.length===0)return;const startAnimation=async()=>{if(!isInView||isHovering||isDragging){if(isDragging){pausedX.current=x.get();}controls.stop();return;}const directionMultiplier=direction===\"left\"?-1:1;const duration=contentWidth/speed;const startX=pausedX.current!==null?pausedX.current:direction===\"left\"?0:-contentWidth;x.set(startX);await controls.start({x:startX+directionMultiplier*contentWidth,transition:{duration,ease:\"linear\",repeat:Infinity,repeatType:\"loop\"}});};startAnimation();return()=>controls.stop();},[contentWidth,containerWidth,speed,direction,isHovering,isDragging,controls,contentFrames.length,isInView,isStatic,x]);// Duplicate frames for infinite scroll\nconst getDuplicatedFrames=useMemo(()=>{const duplicatedFrames=[];for(let i=0;i<duplicates;i++){duplicatedFrames.push(...contentFrames);}return duplicatedFrames;},[contentFrames,duplicates]);// Render frames\nconst renderFrames=()=>{if(contentFrames.length===0){return /*#__PURE__*/_jsx(\"div\",{style:{padding:\"10px\",color:\"#999\"},children:\"Connect frames in the properties panel\"});}return getDuplicatedFrames.map((frame,index)=>/*#__PURE__*/_jsx(\"div\",{style:{marginRight:`${gap}px`,display:\"inline-block\",userSelect:\"none\",WebkitUserSelect:\"none\",MozUserSelect:\"none\",msUserSelect:\"none\",transform:isMobile.current?\"scale(1)\":\"none\",transformOrigin:\"center center\",pointerEvents:isDragging?\"none\":\"auto\",willChange:\"transform\"},children:frame},`frame-${index}`));};return /*#__PURE__*/_jsx(Frame,{...rest,width:width,height:height,background:\"transparent\",overflow:\"hidden\",ref:containerRef,onMouseEnter:()=>!isStatic&&setIsHovering(true),onMouseLeave:()=>!isStatic&&setIsHovering(false),children:/*#__PURE__*/_jsx(motion.div,{ref:itemsContainerRef,style:{display:\"flex\",height:\"100%\",alignItems:\"center\",x:x,cursor:isHovering?\"grab\":\"auto\",position:\"absolute\",left:0,top:0,userSelect:\"none\",WebkitUserDrag:\"none\",WebkitTouchCallout:\"none\",WebkitUserSelect:\"none\",MozUserSelect:\"none\",msUserSelect:\"none\",touchAction:\"none\",willChange:\"transform\",transform:\"translateZ(0)\"},animate:controls,drag:isStatic?false:\"x\",dragConstraints:{left:-contentWidth*duplicates,right:contentWidth*duplicates},onPointerDown:()=>{if(!isStatic)setIsDragging(true);pausedX.current=x.get();},onPointerUp:()=>{if(!isStatic)setIsDragging(false);},onDragStart:()=>{if(!isStatic)setIsDragging(true);pausedX.current=x.get();},onDragEnd:()=>{if(!isStatic)setIsDragging(false);},onDrag:handleDrag,dragElastic:.1,dragTransition:{power:.15,timeConstant:150,modifyTarget:target=>{if(!contentWidth)return target;if(target>0)return target-contentWidth;if(target<-contentWidth)return target+contentWidth;return target;}},whileTap:{cursor:\"grabbing\"},children:renderFrames()})});}addPropertyControls(InfiniteTicker,{contentFrames:{type:ControlType.Array,title:\"Content Frames\",control:{type:ControlType.ComponentInstance},defaultValue:[]},gap:{type:ControlType.Number,title:\"Gap\",defaultValue:40,min:0,max:200,step:1},speed:{type:ControlType.Number,title:\"Speed\",defaultValue:20,min:1,max:100,step:1},direction:{type:ControlType.Enum,title:\"Direction\",options:[\"left\",\"right\"],defaultValue:\"left\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"InfiniteTicker\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./CustomSlideshow.map"],"mappings":"2bAAiN,SAAwB,EAAe,EAAM,CAAC,GAAK,CAAC,MAAI,GAAG,QAAM,GAAG,YAAU,OAAO,QAAM,OAAO,SAAO,GAAG,gBAAc,EAAE,CAAC,GAAG,GAAM,EAAY,EAAaA,EAAO,KAAK,CAAO,EAAkBA,EAAO,KAAK,CAAO,EAAYA,EAAO,KAAK,CAAM,CAAC,EAAa,GAAiBC,EAAS,EAAE,CAAM,CAAC,EAAe,GAAmBA,EAAS,EAAE,CAAM,CAAC,EAAW,GAAeA,EAAS,GAAM,CAAM,CAAC,EAAW,GAAeA,EAAS,GAAM,CAAM,CAAC,EAAW,GAAeA,EAAS,EAAE,CAAM,CAAC,EAAS,GAAaA,EAAS,GAAM,CAAO,EAAQD,EAAO,KAAK,CAAO,EAASA,EAAO,GAAM,CAAO,EAAS,GAAqB,CAAO,EAAE,EAAe,EAAE,CAAO,EAAS,GAAc,CAC32B,EAAiB,GAAK,CAAC,EAAI,UAAU,GAAM,EAAI,MAAM,WAAW,OAAO,EAAI,MAAM,eAAe,QAAe,EAAa,GAAW,CAAC,IAAM,EAAO,EAAU,qBAAqB,MAAM,CAAC,MAAM,KAAK,EAAO,CAAC,QAAQ,EAAiB,EAC7O,MAAc,CAAC,GAAG,GAAU,CAAC,EAAa,QAAQ,OAAO,IAAM,EAAS,IAAI,qBAAqB,GAAS,CAAC,EAAQ,QAAQ,GAAO,CAAC,EAAY,EAAM,eAAe,EAAG,EAAG,CAAC,UAAU,GAAG,WAAW,OAAO,CAAC,CAAwC,OAAvC,EAAS,QAAQ,EAAa,QAAQ,KAAW,EAAS,YAAY,EAAG,CAAC,EAAS,CAAC,CA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