{"version":3,"file":"ScrollReset.BoLdmwWu.mjs","names":["useState","useRef","useId","useMemo","_Fragment"],"sources":["https:/framerusercontent.com/modules/ygU5sfdzLwMvnsyFzLWX/vmHuNxnzayAsrI9o939r/FlipTextCycle_prod.js","https:/framerusercontent.com/modules/wDyEAtD4I8fVRqRbnBZy/mCWdAWgR2CX3OklYUwYD/ScrollReset.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from\"react/jsx-runtime\";import{useEffect,useRef,useState,useId,useMemo}from\"react\";import{ControlType,addPropertyControls,RenderTarget}from\"framer\";import{ComponentMessage}from\"https://framer.com/m/Utils-FINc.js\";// ------------------------------------------------------------ //\n// PROPERTY CONTROLS\n// ------------------------------------------------------------ //\naddPropertyControls(FlipTextCycle,{preview:{type:ControlType.Boolean,title:\"Preview\",enabledTitle:\"On\",disabledTitle:\"Off\",defaultValue:false},texts:{title:\"Texts\",type:ControlType.Array,control:{type:ControlType.Object,controls:{text:{type:ControlType.String},color:{type:ControlType.Color,title:\"Text Color\"}}}},font:{type:ControlType.Font,defaultFontType:\"sans-serif\",controls:\"extended\",title:\"Font\",//@ts-check\nfontWeight:\"500\",defaultValue:{fontFamily:\"Geist\",fontWeight:\"500\",letterSpacing:\"-0.02em\",lineHeight:\"1.5em\",textAlign:\"left\",fontSize:40}},cycleDelay:{title:\"Delay\",type:ControlType.Number,min:.5,max:10,step:.1,defaultValue:1.5,unit:\"s\"},staggerDelay:{title:\"Stagger\",type:ControlType.Number,min:0,max:1,step:.01,defaultValue:.015,unit:\"s\"},flipDuration:{title:\"Duration\",type:ControlType.Number,min:.1,max:2,step:.1,defaultValue:.2,unit:\"s\",description:\"More components at [Framer University](https://frameruni.link/cc).\"}});// ------------------------------------------------------------ //\n// DEFAULT PROPS\n// ------------------------------------------------------------ //\nFlipTextCycle.defaultProps={cycleDelay:2,flipDuration:.6,staggerDelay:.05,preview:true,font:{fontFamily:\"Geist\",fontWeight:\"medium\",letterSpacing:\"-0.02em\",lineHeight:\"1.5em\",textAlign:\"left\",fontSize:\"40px\"},texts:[{text:\"Framer University\",color:\"#45ED8E\"},{text:\"Learn Framer\",color:\"#8754EB\"}]};// ------------------------------------------------------------ //\n// MAIN COMPONENT\n// ------------------------------------------------------------ //\n/**\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight any\n * @framerDisableUnlink\n */export default function FlipTextCycle(props){const areTextsEmpty=props.texts.length===0||!props.texts;const[currentTextIndex,setCurrentTextIndex]=useState(0);const[isAnimating,setIsAnimating]=useState(false);const[cycleId,setCycleId]=useState(0);const[isInViewport,setIsInViewport]=useState(true);const isCanvas=RenderTarget.current()===RenderTarget.canvas;const pauseInCanvas=isCanvas&&!props.preview;const containerRef=useRef(null);// Unique id to avoid clashes between multiple component instances\nconst reactId=useId();const safeId=useMemo(()=>reactId.replace(/[^a-zA-Z0-9_-]/g,\"-\"),[reactId]);const currentText=props.texts[currentTextIndex];// Stable refs to avoid re-scheduling loops\nconst indexRef=useRef(0);const textsRef=useRef(props.texts);const cycleDelayRef=useRef(props.cycleDelay);const flipDurationRef=useRef(props.flipDuration);const staggerDelayRef=useRef(props.staggerDelay);const animationTimeoutRef=useRef(null);const gapTimeoutRef=useRef(null);// Keep refs in sync with latest props\nuseEffect(()=>{textsRef.current=props.texts;if(indexRef.current>=props.texts.length){indexRef.current=0;setCurrentTextIndex(0);}},[props.texts]);useEffect(()=>{cycleDelayRef.current=props.cycleDelay;},[props.cycleDelay]);useEffect(()=>{flipDurationRef.current=props.flipDuration;},[props.flipDuration]);useEffect(()=>{staggerDelayRef.current=props.staggerDelay;},[props.staggerDelay]);// Viewport detection for performance optimization\nuseEffect(()=>{if(!containerRef.current)return;const observer=new IntersectionObserver(([entry])=>{setIsInViewport(entry.isIntersecting);},{threshold:.1});observer.observe(containerRef.current);return()=>{observer.disconnect();};},[]);// Single scheduler loop: animate -> wait -> next\nuseEffect(()=>{if(areTextsEmpty)return;const clearTimers=()=>{if(animationTimeoutRef.current){clearTimeout(animationTimeoutRef.current);animationTimeoutRef.current=null;}if(gapTimeoutRef.current){clearTimeout(gapTimeoutRef.current);gapTimeoutRef.current=null;}};if(pauseInCanvas||!isInViewport){clearTimers();return()=>clearTimers();}const scheduleNext=()=>{// Start animating current word\nsetIsAnimating(true);const current=textsRef.current[indexRef.current];const letterCount=current?.text?.length??0;const staggerDelay=staggerDelayRef.current// seconds\n;const totalDurationSec=Math.max(0,(letterCount-1)*staggerDelay+flipDurationRef.current);// When the last letter finishes, keep the word visible during the gap\nanimationTimeoutRef.current=window.setTimeout(()=>{// Wait for the configured gap while keeping letters visible\ngapTimeoutRef.current=window.setTimeout(()=>{// Prepare next cycle: briefly hide, swap text, then animate in\nsetIsAnimating(false);// Allow DOM to apply the hidden state before swapping text\nwindow.setTimeout(()=>{const next=(indexRef.current+1)%textsRef.current.length;indexRef.current=next;setCurrentTextIndex(next);// Force new letter elements so transitions retrigger even for repeated words\nsetCycleId(id=>id+1);// Ensure the DOM commits the new letters at rest before animating\nwindow.requestAnimationFrame(()=>{window.requestAnimationFrame(()=>{scheduleNext();});});},0);},cycleDelayRef.current*1e3);},totalDurationSec*1e3);};// Kick off first cycle on mount with two RAFs to ensure initial state paints\nwindow.requestAnimationFrame(()=>{window.requestAnimationFrame(()=>{scheduleNext();});});return()=>{clearTimers();};},[areTextsEmpty,pauseInCanvas,isInViewport]);const baseStyle=`\n    @layer demo {\n      .flip-text-container-${safeId} {\n        perspective: 1000px;\n        width: 100%;\n        height: 100%;\n        display: flex;\n        align-items: center;\n        justify-content: center;\n        transform-style: preserve-3d;\n      }\n      .flip-text-${safeId} {\n        font-family: ${props.font.fontFamily};\n        font-weight: ${props.font.fontWeight};\n        font-size: ${props.font.fontSize};\n        letter-spacing: ${props.font.letterSpacing};\n        line-height: ${props.font.lineHeight};\n        text-align: ${props.font.textAlign};\n        margin: 0;\n        display: inline-block;\n        white-space: break-spaces;\n        transform-style: preserve-3d;\n      }\n      .flip-letter-${safeId} {\n        display: inline-block;\n        color: ${currentText?.color||\"#000\"};\n        transform-style: preserve-3d;\n        transition: transform ${props.flipDuration}s ease-in, opacity ${props.flipDuration}s ease-in;\n        transform: rotateY(90deg);\n        opacity: 0;\n      }\n      .flip-letter-${safeId}.animate {\n        transform: rotateY(0deg);\n        opacity: 1;\n      }\n      .flip-letter-${safeId}.no-anim {\n        transition: none;\n        transform: rotateY(0deg);\n        opacity: 1;\n      }\n    }\n`;const style=useMemo(()=>{return baseStyle;},[safeId,props.font.fontFamily,props.font.fontWeight,props.font.fontSize,props.font.letterSpacing,props.font.lineHeight,props.font.textAlign,currentText?.color,isAnimating,props.flipDuration]);// Split text into tokens (words and spaces) so wrapping happens between words only\nconst tokens=useMemo(()=>{return currentText?.text?currentText.text.split(/(\\s+)/):[];},[currentText?.text,currentTextIndex,cycleId]);// Memoize the rendered content to avoid unnecessary re-renders\nconst renderedContent=useMemo(()=>{let letterCounter=0;return tokens.map((token,tIndex)=>{const isSpace=token.trim()===\"\";if(isSpace){// render a single normal space so the next line never starts with an extra gap\nreturn /*#__PURE__*/_jsx(\"span\",{children:\" \"},`${currentTextIndex}-${cycleId}-space-${tIndex}`);}return /*#__PURE__*/_jsx(\"span\",{style:{display:\"inline-block\",whiteSpace:\"nowrap\"},children:token.split(\"\").map((letter,lIndex)=>{const globalIndex=letterCounter++;return /*#__PURE__*/_jsx(\"span\",{className:`flip-letter-${safeId} ${pauseInCanvas?\"no-anim\":isAnimating?\"animate\":\"\"}`,style:{transitionDelay:pauseInCanvas?\"0s\":`${globalIndex*props.staggerDelay}s`},children:letter},`${currentTextIndex}-${cycleId}-${tIndex}-${lIndex}`);})},`${currentTextIndex}-${cycleId}-word-${tIndex}`);});},[tokens,currentTextIndex,cycleId,pauseInCanvas,isAnimating,safeId,props.staggerDelay]);if(areTextsEmpty){return /*#__PURE__*/_jsx(\"div\",{style:{width:\"100%\",height:\"100%\"},children:/*#__PURE__*/_jsx(ComponentMessage,{title:\"Flip Text Cycle\",subtitle:\"Set up the component by adding texts to the component properties.\"})});}return /*#__PURE__*/_jsxs(_Fragment,{children:[/*#__PURE__*/_jsx(\"style\",{children:style}),/*#__PURE__*/_jsx(\"div\",{ref:containerRef,className:`flip-text-container-${safeId}`,style:{width:\"100%\",height:\"100%\"},children:/*#__PURE__*/_jsx(\"span\",{className:`flip-text-${safeId}`,children:renderedContent})})]});}FlipTextCycle.displayName=\"Flip Text Cycle\";\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"FlipTextCycle\",\"slots\":[],\"annotations\":{\"framerDisableUnlink\":\"\",\"framerSupportedLayoutWidth\":\"any\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"any\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./FlipTextCycle_prod.map","import{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect}from\"react\";export function resetScroll(Component){return props=>{useEffect(()=>{window.scrollTo(0,0);},[]);return /*#__PURE__*/_jsx(Component,{...props});};}\nexport const __FramerMetadata__ = {\"exports\":{\"resetScroll\":{\"type\":\"reactHoc\",\"name\":\"resetScroll\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./ScrollReset.map"],"mappings":"0RAcG,SAAwB,EAAc,EAAM,CAAC,IAAM,EAAc,EAAM,MAAM,SAAS,GAAG,CAAC,EAAM,MAAW,CAAC,EAAiB,GAAqBA,EAAS,EAAE,CAAM,CAAC,EAAY,GAAgBA,EAAS,GAAM,CAAM,CAAC,EAAQ,GAAYA,EAAS,EAAE,CAAM,CAAC,EAAa,GAAiBA,EAAS,GAAK,CAAmE,EAAnD,EAAa,SAAS,GAAG,EAAa,QAAqC,CAAC,EAAM,QAAc,EAAaC,EAAO,KAAK,CAC9a,EAAQC,GAAO,CAAO,EAAOC,MAAY,EAAQ,QAAQ,kBAAkB,IAAI,CAAC,CAAC,EAAQ,CAAC,CAAO,EA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