{"version":3,"file":"SwipeLoopCarousel.BsBIHDMC.mjs","names":["useRef","useState","useMemo","Children","useCallback","__esmMin","pe","init_npm_react_18_3_1","ne","init_ssg_sandbox_shims","window","te","_e","p","c","J","init_jsx_runtime","ce","j","de","init_framer_B6PCHH0A","useIsStaticRenderer","SwipeLoopCarousel","isStatic","slideWidthRatio","viewportRef","wrapTimeoutRef","slideWidth","setSlideWidth","activeIndex","setActiveIndex","stepSize","childrenArray","props","hasExpectedSlides","loopedSlides","first","clearWrapTimer","updateFromScroll","viewport","rawIndex","originalCount","realIndex","recenterIfNeeded","observer","nextWidth","entries","onScroll","Component","index","child","init_SwipeLoopCarousel"],"sources":["https:/framerusercontent.com/modules/rpQAm0RiNaExGqYhOQRn/8zmbvlsCN5Ri8cunDBoO/SwipeLoopCarousel.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useIsStaticRenderer}from\"framer\";import{Children,forwardRef,startTransition,useCallback,useEffect,useMemo,useRef,useState}from\"react\";// User request: Create a code override named SwipeLoopCarousel for an existing canvas FrameNode that keeps its children intact, supports horizontal swipe + snap, loops infinitely in both directions, preserves responsive sizing without clipping child image content, hides scrollbars, avoids fixed widths, and includes safe static-render fallback/accessibility semantics.\n// Update request: Make slides ~92% viewport width with subtle next-slide peek, while preserving swipe/snap/infinite behavior and updating measured slideWidth for correct wrap logic.\n// Update request: Add ~16px horizontal gap between slides and ensure all positioning math uses slide width + gap so infinite wrapping remains correct.\nexport function SwipeLoopCarousel(Component){return /*#__PURE__*/forwardRef(function SwipeLoopCarouselOverride(props,ref){const isStatic=useIsStaticRenderer();const slideWidthRatio=.92;const slideGap=16;const viewportRef=useRef(null);const wrapTimeoutRef=useRef(null);const[slideWidth,setSlideWidth]=useState(0);const[activeIndex,setActiveIndex]=useState(0);const stepSize=useMemo(()=>slideWidth+slideGap,[slideGap,slideWidth]);const childrenArray=useMemo(()=>{return Children.toArray(props.children);},[props.children]);const hasExpectedSlides=childrenArray.length>=2;const loopedSlides=useMemo(()=>{if(!hasExpectedSlides)return childrenArray;const first=childrenArray[0];const last=childrenArray[childrenArray.length-1];return[last,...childrenArray,first];},[childrenArray,hasExpectedSlides]);const clearWrapTimer=useCallback(()=>{if(wrapTimeoutRef.current!==null&&typeof window!==\"undefined\"){window.clearTimeout(wrapTimeoutRef.current);wrapTimeoutRef.current=null;}},[]);const updateFromScroll=useCallback(()=>{const viewport=viewportRef.current;if(!viewport||stepSize<=0||!hasExpectedSlides)return;const rawIndex=Math.round(viewport.scrollLeft/stepSize);const originalCount=childrenArray.length;const realIndex=((rawIndex-1+originalCount)%originalCount+originalCount)%originalCount;startTransition(()=>setActiveIndex(realIndex));},[childrenArray.length,hasExpectedSlides,stepSize]);const recenterIfNeeded=useCallback(()=>{const viewport=viewportRef.current;if(!viewport||stepSize<=0||!hasExpectedSlides)return;const rawIndex=Math.round(viewport.scrollLeft/stepSize);const originalCount=childrenArray.length;if(rawIndex===0){viewport.scrollTo({left:originalCount*stepSize,behavior:\"auto\"});startTransition(()=>setActiveIndex(originalCount-1));}else if(rawIndex===originalCount+1){viewport.scrollTo({left:stepSize,behavior:\"auto\"});startTransition(()=>setActiveIndex(0));}},[childrenArray.length,hasExpectedSlides,stepSize]);useEffect(()=>{if(isStatic||!hasExpectedSlides)return;if(typeof window===\"undefined\")return;if(typeof ResizeObserver===\"undefined\")return;const viewport=viewportRef.current;if(!viewport)return;const observer=new ResizeObserver(entries=>{const viewportWidth=entries[0]?.contentRect?.width??0;const nextWidth=viewportWidth*slideWidthRatio;startTransition(()=>setSlideWidth(nextWidth));});observer.observe(viewport);return()=>observer.disconnect();},[hasExpectedSlides,isStatic,slideWidthRatio]);useEffect(()=>{if(isStatic||!hasExpectedSlides)return;const viewport=viewportRef.current;if(!viewport||stepSize<=0)return;viewport.scrollTo({left:stepSize,behavior:\"auto\"});startTransition(()=>setActiveIndex(0));},[hasExpectedSlides,isStatic,stepSize]);useEffect(()=>{return()=>clearWrapTimer();},[clearWrapTimer]);const onScroll=useCallback(()=>{if(!hasExpectedSlides)return;updateFromScroll();clearWrapTimer();if(typeof window!==\"undefined\"){wrapTimeoutRef.current=window.setTimeout(()=>{recenterIfNeeded();},120);}},[clearWrapTimer,hasExpectedSlides,recenterIfNeeded,updateFromScroll]);if(isStatic||!hasExpectedSlides||childrenArray.length===0){return /*#__PURE__*/_jsx(Component,{ref:ref,...props});}return /*#__PURE__*/_jsx(Component,{ref:ref,...props,style:{...props.style,position:\"relative\",overflow:\"hidden\"},children:/*#__PURE__*/_jsxs(\"div\",{role:\"region\",\"aria-roledescription\":\"carousel\",\"aria-label\":\"Swipe carousel\",style:{position:\"relative\",width:\"100%\",height:\"100%\",overflow:\"hidden\"},children:[/*#__PURE__*/_jsx(\"div\",{ref:viewportRef,onScroll:onScroll,style:{width:\"100%\",height:\"100%\",display:\"flex\",flexDirection:\"row\",columnGap:`${slideGap}px`,overflowX:\"auto\",overflowY:\"hidden\",scrollSnapType:\"x mandatory\",WebkitOverflowScrolling:\"touch\",scrollbarWidth:\"none\",msOverflowStyle:\"none\",touchAction:\"pan-x\",overscrollBehaviorX:\"contain\"},children:loopedSlides.map((child,index)=>/*#__PURE__*/_jsx(\"div\",{\"aria-hidden\":index===0||index===loopedSlides.length-1,style:{position:\"relative\",flex:`0 0 ${slideWidthRatio*100}%`,minWidth:`${slideWidthRatio*100}%`,height:\"100%\",scrollSnapAlign:\"start\",overflow:\"visible\"},children:child},`loop-slide-${index}`))}),/*#__PURE__*/_jsx(\"div\",{\"aria-live\":\"polite\",\"aria-atomic\":\"true\",style:{position:\"absolute\",width:1,height:1,padding:0,margin:-1,overflow:\"hidden\",clip:\"rect(0, 0, 0, 0)\",whiteSpace:\"nowrap\",border:0},children:`Slide ${activeIndex+1} of ${childrenArray.length}`})]})});});}\nexport const __FramerMetadata__ = {\"exports\":{\"SwipeLoopCarousel\":{\"type\":\"reactHoc\",\"name\":\"SwipeLoopCarousel\",\"annotations\":{\"framerContractVersion\":\"1\"}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