{"version":3,"file":"TextCycle.BYSyav5H.mjs","names":["useRef","useState","useCallback","p"],"sources":["https:/framerusercontent.com/modules/O0wf3YQ7nlrkjGzlmODh/Jtw7GDqei7rrlwatJTmP/TextCycle.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{addPropertyControls,ControlType,RenderTarget}from\"framer\";import{motion,useMotionValue,useTransform,animate}from\"framer-motion\";import{useState,useEffect,useCallback,useLayoutEffect,useRef,startTransition}from\"react\";/* -------------------------------------------------- *//* Helpers *//* -------------------------------------------------- */function getTranslatePercent(index,total){return index/(total+1)*1e4;}function useElementWidth(){const elRef=useRef(null);const[width,setWidth]=useState(0);const setRef=useCallback(node=>{elRef.current=node;},[]);useLayoutEffect(()=>{if(typeof window===\"undefined\")return;const el=elRef.current;if(!el)return;const update=()=>{const next=el.getBoundingClientRect().width;startTransition(()=>setWidth(next));};update();if(typeof ResizeObserver===\"undefined\"){// Fallback: update on window resize\nwindow.addEventListener(\"resize\",update);return()=>window.removeEventListener(\"resize\",update);}const ro=new ResizeObserver(()=>update());ro.observe(el);return()=>ro.disconnect();},[]);return[setRef,width];}/**\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight auto\n */export default function TextCycle(props){const{text,direction,overflow,playing,gradients,fontColor}=props;const textStyle={margin:0,transformOrigin:`${props.out.anchor} center`};const fadeHeight=overflow.mode===\"fade\"?overflow.fadeHeight:0;const[measureRef,width]=useElementWidth();const isCanvas=RenderTarget.current()===RenderTarget.canvas;const[textIndex,setTextIndex]=useState(props.randomStart&&!isCanvas?Math.floor(Math.random()*text.length):0);const translatePercent=useMotionValue(getTranslatePercent(textIndex,text.length));/* -------------------------------------------------- *//* Animation Loop *//* -------------------------------------------------- */useEffect(()=>{if(!isCanvas&&playing){const timer=window.setTimeout(()=>{if(textIndex===text.length-1){startTransition(()=>setTextIndex(0));animate(translatePercent,getTranslatePercent(textIndex+1,text.length),props.transition).then(()=>translatePercent.set(0));}else{if(textIndex===0)translatePercent.set(0);animate(translatePercent,getTranslatePercent(textIndex+1,text.length),props.transition);startTransition(()=>setTextIndex(textIndex+1));}},props.interval*1e3);return()=>window.clearTimeout(timer);}},[playing,isCanvas,textIndex,text.length,props.interval,props.transition,translatePercent]);/* -------------------------------------------------- *//* Gradient Style *//* -------------------------------------------------- */function getGradientStyle(index){const g=gradients?.[index];if(!g||!g.colors?.length){return{color:fontColor};}return{backgroundImage:`linear-gradient(${g.angle??90}deg, ${g.colors.join(\", \")})`,backgroundClip:\"text\",WebkitBackgroundClip:\"text\",WebkitTextFillColor:\"transparent\",color:\"transparent\"};}/* -------------------------------------------------- *//* Render *//* -------------------------------------------------- */return /*#__PURE__*/_jsx(motion.div,{style:{...props.font,fontWeight:700,userSelect:props.textSelect?\"auto\":\"none\",height:props.font?.lineHeight??\"1.2em\",overflow:\"hidden\",boxSizing:\"content-box\",position:\"relative\",WebkitMaskImage:fadeHeight>0?`linear-gradient(to top, transparent 0px, black ${fadeHeight}px, black calc(100% - ${fadeHeight}px), transparent 100%)`:\"none\",padding:props.paddingIsMixed?`${props.paddingTop+fadeHeight}px ${props.paddingRight}px ${props.paddingBottom+fadeHeight}px ${props.paddingLeft}px`:`${props.padding+fadeHeight}px ${props.padding}px`,display:\"flex\",justifyContent:props.font.textAlign},transition:props.transition,animate:props.style?.width!==\"100%\"?{width}:undefined,children:/*#__PURE__*/_jsxs(\"div\",{ref:measureRef,style:{width:\"max-content\"},children:[/*#__PURE__*/_jsxs(motion.div,{style:{position:props.resize?\"absolute\":\"static\",display:\"flex\",flexDirection:direction===\"up\"?\"column\":\"column-reverse\",gap:props.gap,paddingBlockEnd:props.gap,translateY:useTransform(translatePercent,value=>direction===\"up\"?`${-(value/100)}%`:`${-100+1/(text.length+1)*100+value/100}%`)},children:[text.map((item,index)=>/*#__PURE__*/_jsx(motion.p,{animate:{scale:textIndex===index?1:props.out.scale,opacity:textIndex===index?1:props.out.opacity},transition:props.transition,initial:false,style:{...textStyle,...getGradientStyle(index)},children:item},index)),text.length>0&&/*#__PURE__*/_jsx(motion.p,{animate:{scale:textIndex===0?1:props.out.scale,opacity:textIndex===0?1:props.out.opacity},transition:props.transition,initial:false,style:{...textStyle,...getGradientStyle(0)},children:text[0]})]}),/*#__PURE__*/_jsx(\"p\",{style:{margin:0,opacity:0},children:text[textIndex]})]})});}/* -------------------------------------------------- *//* Framer Controls *//* -------------------------------------------------- */addPropertyControls(TextCycle,{text:{type:ControlType.Array,defaultValue:[\"Design\",\"Build\",\"Scale\"],control:{type:ControlType.String,defaultValue:\"Text\"}},gradients:{type:ControlType.Array,title:\"Text Gradients\",control:{type:ControlType.Object,controls:{angle:{type:ControlType.Number,min:0,max:360,defaultValue:90},colors:{type:ControlType.Array,control:{type:ControlType.Color,defaultValue:\"#6A5CFF\"},defaultValue:[\"#6A5CFF\",\"#00E0FF\"]}}},defaultValue:[{angle:90,colors:[\"#6A5CFF\",\"#00E0FF\"]}]},direction:{type:ControlType.Enum,defaultValue:\"up\",options:[\"up\",\"down\"],displaySegmentedControl:true},interval:{type:ControlType.Number,defaultValue:1,min:.1,step:.01,unit:\"s\"},playing:{type:ControlType.Boolean,defaultValue:true},randomStart:{type:ControlType.Boolean,defaultValue:false},fontColor:{type:ControlType.Color,defaultValue:\"#000000\"},font:{type:ControlType.Font,controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:24,lineHeight:1.4,variant:\"Bold\",letterSpacing:\"-0.01em\"}},out:{type:ControlType.Object,title:\"Inactive\",controls:{opacity:{type:ControlType.Number,defaultValue:.5,min:0,max:1},scale:{type:ControlType.Number,defaultValue:1,min:0},anchor:{type:ControlType.Enum,defaultValue:\"center\",options:[\"left\",\"center\",\"right\"],displaySegmentedControl:true}}},overflow:{type:ControlType.Object,controls:{mode:{type:ControlType.Enum,defaultValue:\"hidden\",options:[\"visible\",\"hidden\",\"fade\"],displaySegmentedControl:true},fadeHeight:{type:ControlType.Number,defaultValue:12,hidden:p=>p.mode!==\"fade\"}}},gap:{type:ControlType.Number,defaultValue:10,min:0},paddingIsMixed:{type:ControlType.Boolean,title:\"Mixed Padding\",defaultValue:false,enabledTitle:\"Mixed\",disabledTitle:\"Uniform\"},padding:{type:ControlType.Number,defaultValue:0,min:0,step:1,unit:\"px\",hidden:p=>p.paddingIsMixed},paddingTop:{type:ControlType.Number,defaultValue:0,min:0,step:1,unit:\"px\",hidden:p=>!p.paddingIsMixed},paddingRight:{type:ControlType.Number,defaultValue:0,min:0,step:1,unit:\"px\",hidden:p=>!p.paddingIsMixed},paddingBottom:{type:ControlType.Number,defaultValue:0,min:0,step:1,unit:\"px\",hidden:p=>!p.paddingIsMixed},paddingLeft:{type:ControlType.Number,defaultValue:0,min:0,step:1,unit:\"px\",hidden:p=>!p.paddingIsMixed},resize:{type:ControlType.Boolean,defaultValue:false},textSelect:{type:ControlType.Boolean,defaultValue:true},transition:{type:ControlType.Transition}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"TextCycle\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutHeight\":\"auto\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"any\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./TextCycle.map"],"mappings":"+SAAsZ,SAAS,EAAoB,EAAM,EAAM,CAAC,OAAO,GAAO,EAAM,GAAG,IAAK,SAAS,GAAiB,CAAC,IAAM,EAAMA,EAAO,KAAK,CAAM,CAAC,EAAM,GAAUC,EAAS,EAAE,CAAO,EAAOC,EAAY,GAAM,CAAC,EAAM,QAAQ,GAAO,EAAE,CAAC,CACjb,OADkb,MAAoB,CAAC,GAAU,IAAS,OAAY,OAAO,IAAM,EAAG,EAAM,QAAQ,GAAG,CAAC,EAAG,OAAO,IAAM,MAAW,CAAC,IAAM,EAAK,EAAG,uBAAuB,CAAC,MAAM,MAAoB,EAAS,EAAK,CAAC,EAAY,GAAT,GAAQ,CAAI,OAAO,eAAiB,IA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