{"version":3,"file":"TextRotation.f_usV-ta.mjs","names":["React.useState","id"],"sources":["https:/framerusercontent.com/modules/6jS2pOHZjZh4JhZlnfvc/B3Fi4cbKeV7uo0Uu5wtx/TextRotation.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import*as React from\"react\";import{motion,AnimatePresence}from\"framer-motion\";import{addPropertyControls,ControlType}from\"framer\";export default function TextRotation(props){const{staticText,phrases,interval,animationMode,animationStyle,loop,pauseOnHover,font,staticColor,color}=props;const safePhrases=phrases.length>0?phrases:[\"Text\"];const[index,setIndex]=React.useState(0);const[paused,setPaused]=React.useState(false);// Typewriter state\nconst[displayedChars,setDisplayedChars]=React.useState(0);const[isDeleting,setIsDeleting]=React.useState(false);const text=safePhrases[index];const isTypewriter=animationStyle===\"typewriter\";const isDecode=animationStyle===\"typewriterDecode\";const isTypewriterStyle=isTypewriter||isDecode;// Decode scramble state\nconst[scrambleChar,setScrambleChar]=React.useState(\"\");const[scrambleCount,setScrambleCount]=React.useState(0);const scrambleTotal=4;const scrambleSpeed=30;const scrambleChars=\"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789#@$%&\";// Standard rotation timer (non-typewriter styles)\nReact.useEffect(()=>{if(isTypewriterStyle)return;if(paused)return;if(!loop&&index===safePhrases.length-1)return;const id=setTimeout(()=>{setIndex(i=>(i+1)%safePhrases.length);},interval);return()=>clearTimeout(id);},[index,interval,loop,paused,safePhrases.length,isTypewriterStyle]);// Typewriter effect (shared by typewriter and typewriterDecode)\nReact.useEffect(()=>{if(!isTypewriterStyle)return;if(paused)return;const fullText=safePhrases[index];const typeSpeed=80;const deleteSpeed=40;const pauseBeforeDelete=interval;const pauseBeforeNext=200;if(!isDeleting&&displayedChars<fullText.length){if(isDecode&&scrambleCount<scrambleTotal){// Scramble phase: cycle through random characters\nconst id=setTimeout(()=>{const rand=scrambleChars[Math.floor(Math.random()*scrambleChars.length)];setScrambleChar(rand);setScrambleCount(c=>c+1);},scrambleSpeed);return()=>clearTimeout(id);}// Typing forward — land on the correct character\nconst id=setTimeout(()=>{setDisplayedChars(c=>c+1);setScrambleCount(0);setScrambleChar(\"\");},isDecode?scrambleSpeed:typeSpeed);return()=>clearTimeout(id);}if(!isDeleting&&displayedChars===fullText.length){// Finished typing — pause then start deleting\nif(!loop&&index===safePhrases.length-1)return;const id=setTimeout(()=>{setIsDeleting(true);},pauseBeforeDelete);return()=>clearTimeout(id);}if(isDeleting&&displayedChars>0){// Deleting\nconst id=setTimeout(()=>{setDisplayedChars(c=>c-1);},deleteSpeed);return()=>clearTimeout(id);}if(isDeleting&&displayedChars===0){// Finished deleting — move to next phrase\nconst id=setTimeout(()=>{setIsDeleting(false);setIndex(i=>(i+1)%safePhrases.length);},pauseBeforeNext);return()=>clearTimeout(id);}},[isTypewriterStyle,isDecode,paused,index,displayedChars,isDeleting,interval,loop,safePhrases,scrambleCount,scrambleTotal,scrambleSpeed,scrambleChars]);// Reset typewriter chars when index changes\nReact.useEffect(()=>{if(isTypewriterStyle){setDisplayedChars(0);setIsDeleting(false);setScrambleCount(0);setScrambleChar(\"\");}},[index,isTypewriterStyle]);const units=animationMode===\"character\"?Array.from(text):animationMode===\"word\"?text.split(\" \").map((w,i,arr)=>i<arr.length-1?w+\" \":w):[text];const motionVariants={slideUp:{initial:{opacity:0,y:16},animate:{opacity:1,y:0},exit:{opacity:0,y:-16}},slideDown:{initial:{opacity:0,y:-16},animate:{opacity:1,y:0},exit:{opacity:0,y:16}},fade:{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0}},clipReveal:{initial:{clipPath:\"inset(-0.2em 100% -0.1em 0)\"},animate:{clipPath:\"inset(-0.2em -0.1em -0.1em 0)\"},exit:{clipPath:\"inset(-0.2em 0 -0.1em 100%)\"}},typewriter:{initial:{opacity:1},animate:{opacity:1},exit:{opacity:1}}};// Typewriter / Decode rendering\nif(isTypewriterStyle){const visibleText=text.slice(0,displayedChars);const scrambleSuffix=isDecode&&!isDeleting&&displayedChars<text.length&&scrambleCount>0?scrambleChar:\"\";return /*#__PURE__*/_jsxs(\"div\",{\"aria-live\":\"polite\",onMouseEnter:()=>pauseOnHover&&setPaused(true),onMouseLeave:()=>pauseOnHover&&setPaused(false),style:{...font,display:\"inline-flex\",alignItems:\"center\",width:\"100%\",height:\"100%\"},children:[staticText&&/*#__PURE__*/_jsx(\"span\",{style:{marginRight:6,color:staticColor,whiteSpace:\"pre\"},children:staticText}),/*#__PURE__*/_jsx(\"span\",{style:{position:\"relative\",display:\"inline-block\",padding:\"0.2em 0.05em 0 0\",margin:\"-0.2em 0 0 0\"},children:/*#__PURE__*/_jsxs(\"span\",{style:{display:\"inline-block\",whiteSpace:\"nowrap\",color},children:[visibleText,scrambleSuffix]})})]});}// Standard rendering (slideUp, slideDown, fade, clipReveal)\nreturn /*#__PURE__*/_jsxs(\"div\",{\"aria-live\":\"polite\",onMouseEnter:()=>pauseOnHover&&setPaused(true),onMouseLeave:()=>pauseOnHover&&setPaused(false),style:{...font,display:\"inline-flex\",alignItems:\"center\",width:\"100%\",height:\"100%\"},children:[staticText&&/*#__PURE__*/_jsx(\"span\",{style:{marginRight:6,color:staticColor,whiteSpace:\"pre\"},children:staticText}),/*#__PURE__*/_jsx(\"span\",{style:{position:\"relative\",display:\"inline-block\",overflow:animationStyle===\"clipReveal\"?\"visible\":\"hidden\",padding:\"0.2em 0.05em 0 0\",margin:\"-0.2em 0 0 0\"},children:/*#__PURE__*/_jsx(AnimatePresence,{mode:\"wait\",children:/*#__PURE__*/_jsx(motion.span,{...motionVariants[animationStyle],transition:{duration:animationStyle===\"clipReveal\"?.6:.4,ease:animationStyle===\"clipReveal\"?[.65,0,.35,1]:\"easeOut\"},style:{display:\"inline-block\",whiteSpace:\"nowrap\",color},children:units.map((unit,i)=>/*#__PURE__*/_jsx(motion.span,{initial:animationMode===\"phrase\"?false:{opacity:0,y:8},animate:animationMode===\"phrase\"?{}:{opacity:1,y:0},transition:{delay:animationMode===\"phrase\"?0:i*.04},style:{display:\"inline-block\",whiteSpace:\"pre\"},children:unit},i))},text+index)})})]});}TextRotation.defaultProps={staticText:\"I like\",phrases:[\"apples\",\"mangoes\",\"oranges\"],interval:2e3,animationMode:\"phrase\",animationStyle:\"slideUp\",loop:true,pauseOnHover:false,staticColor:\"#666\",color:\"#000\"};addPropertyControls(TextRotation,{staticText:{type:ControlType.String,title:\"Static Text\"},phrases:{type:ControlType.Array,title:\"Rotating Text\",control:{type:ControlType.String}},font:{type:ControlType.Font,title:\"Font\",controls:\"extended\"},interval:{type:ControlType.Number,title:\"Interval\",min:500,max:8e3,unit:\"ms\"},animationMode:{type:ControlType.Enum,title:\"Animate By\",options:[\"phrase\",\"word\",\"character\"]},animationStyle:{type:ControlType.Enum,title:\"Style\",options:[\"slideUp\",\"slideDown\",\"fade\",\"clipReveal\",\"typewriter\",\"typewriterDecode\"],optionTitles:[\"Slide Up\",\"Slide Down\",\"Fade\",\"Clip Reveal\",\"Typewriter\",\"Typewriter Decode\"]},loop:{type:ControlType.Boolean,title:\"Loop\"},pauseOnHover:{type:ControlType.Boolean,title:\"Pause on Hover\"},staticColor:{type:ControlType.Color,title:\"Static Color\"},color:{type:ControlType.Color,title:\"Rotate Color\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"TextRotation\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./TextRotation.map"],"mappings":"gPAA2L,SAAwB,EAAa,EAAM,CAAC,GAAK,CAAC,aAAW,UAAQ,WAAS,gBAAc,iBAAe,OAAK,eAAa,OAAK,cAAY,SAAO,EAAY,EAAY,EAAQ,OAAO,EAAE,EAAQ,CAAC,OAAO,CAAM,CAAC,EAAM,GAAUA,EAAe,EAAE,CAAM,CAAC,EAAO,GAAWA,EAAe,GAAM,CAC1d,CAAC,EAAe,GAAmBA,EAAe,EAAE,CAAM,CAAC,EAAW,GAAeA,E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