{"version":3,"file":"TextScrambler.BotYcTSA.mjs","names":["useState","useRef"],"sources":["https:/framerusercontent.com/modules/4MPovkMUiiN0xWz9BHXe/l2cONoRKnoONevK1LiwY/TextScrambler.js"],"sourcesContent":["// Text scrambler effect with customizable word and animation settings\nimport{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect,useState,useRef,startTransition}from\"react\";import{addPropertyControls,ControlType,useIsStaticRenderer}from\"framer\";import{useInView}from\"framer-motion\";/**\n * Text Scrambler Effect\n * \n * @framerIntrinsicWidth 300\n * @framerIntrinsicHeight 60\n * \n * @framerSupportedLayoutWidth auto\n * @framerSupportedLayoutHeight auto\n */export default function TextScrambler(props){const{text=\"SCRAMBLE\",font,textColor=\"#000000\",duration=2e3,scrambleSpeed=50,autoPlay=true,loop=false,characters=\"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*\",triggerOnScroll=false,scrollMargin=\"0px\"}=props;const[displayText,setDisplayText]=useState(text);const[isAnimating,setIsAnimating]=useState(false);const[hasAnimated,setHasAnimated]=useState(false);const animationRef=useRef(null);const containerRef=useRef(null);const isStatic=useIsStaticRenderer();const isInView=useInView(containerRef,{once:!loop});const scramble=()=>{if(isStatic)return;startTransition(()=>setIsAnimating(true));const startTime=Date.now();const textLength=text.length;const animate=()=>{const elapsed=Date.now()-startTime;const progress=Math.min(elapsed/duration,1);// Calculate how many characters should be revealed\nconst revealedCount=Math.floor(progress*textLength);let newText=\"\";for(let i=0;i<textLength;i++){if(i<revealedCount){// Character is revealed\nnewText+=text[i];}else if(text[i]===\" \"){// Keep spaces as spaces\nnewText+=\" \";}else{// Scramble this character\nconst randomChar=characters[Math.floor(Math.random()*characters.length)];newText+=randomChar;}}startTransition(()=>setDisplayText(newText));if(progress<1){animationRef.current=requestAnimationFrame(animate);}else{startTransition(()=>{setDisplayText(text);setIsAnimating(false);});// Loop if enabled\nif(loop){setTimeout(()=>{scramble();},1e3);}}};animationRef.current=requestAnimationFrame(animate);};useEffect(()=>{// Cancel any ongoing animation\nif(animationRef.current){cancelAnimationFrame(animationRef.current);}// Reset display text to new text\nstartTransition(()=>{setDisplayText(text);setIsAnimating(false);setHasAnimated(false);});// Start animation if autoPlay is enabled and not using scroll trigger\nif(autoPlay&&!triggerOnScroll&&!isStatic){// Small delay to show the new text before scrambling\nconst timeoutId=setTimeout(()=>{scramble();},100);return()=>{clearTimeout(timeoutId);if(animationRef.current){cancelAnimationFrame(animationRef.current);}};}return()=>{if(animationRef.current){cancelAnimationFrame(animationRef.current);}};},[text,duration,autoPlay,loop,isStatic,triggerOnScroll]);// Handle scroll-triggered animation\nuseEffect(()=>{if(triggerOnScroll&&isInView&&!isStatic&&!isAnimating){if(loop||!hasAnimated){scramble();startTransition(()=>setHasAnimated(true));}}},[isInView,triggerOnScroll,isStatic,isAnimating,hasAnimated,loop]);useEffect(()=>{if(!isAnimating&&!isStatic){startTransition(()=>setDisplayText(text));}},[text,isAnimating,isStatic]);const handleClick=()=>{if(!isStatic&&!isAnimating){scramble();}};return /*#__PURE__*/_jsx(\"div\",{ref:containerRef,onClick:handleClick,style:{display:\"inline-block\",cursor:isStatic?\"default\":\"pointer\",userSelect:\"none\",width:\"max-content\",minWidth:\"max-content\"},children:/*#__PURE__*/_jsx(\"span\",{style:{...font,color:textColor,whiteSpace:\"pre\",fontVariantNumeric:\"tabular-nums\",fontFeatureSettings:\"'tnum'\"},children:displayText})});}addPropertyControls(TextScrambler,{text:{type:ControlType.String,title:\"Text\",defaultValue:\"SCRAMBLE\"},font:{type:ControlType.Font,title:\"Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:\"40px\",variant:\"Bold\",letterSpacing:\"-0.02em\",lineHeight:\"1em\"}},textColor:{type:ControlType.Color,title:\"Text Color\",defaultValue:\"#000000\"},duration:{type:ControlType.Number,title:\"Duration\",defaultValue:2e3,min:500,max:5e3,step:100,unit:\"ms\"},scrambleSpeed:{type:ControlType.Number,title:\"Speed\",defaultValue:50,min:10,max:200,step:10,unit:\"ms\"},triggerOnScroll:{type:ControlType.Boolean,title:\"Trigger\",defaultValue:false,enabledTitle:\"Scroll\",disabledTitle:\"Auto\"},autoPlay:{type:ControlType.Boolean,title:\"Auto Play\",defaultValue:true,enabledTitle:\"On\",disabledTitle:\"Off\",hidden:({triggerOnScroll})=>triggerOnScroll},loop:{type:ControlType.Boolean,title:\"Loop\",defaultValue:false,enabledTitle:\"On\",disabledTitle:\"Off\"},scrollMargin:{type:ControlType.String,title:\"Scroll Margin\",defaultValue:\"0px\",placeholder:\"e.g., -100px\",hidden:({triggerOnScroll})=>!triggerOnScroll},characters:{type:ControlType.String,title:\"Characters\",defaultValue:\"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*\",displayTextArea:true}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"TextScrambler\",\"slots\":[],\"annotations\":{\"framerIntrinsicHeight\":\"60\",\"framerSupportedLayoutWidth\":\"auto\",\"framerContractVersion\":\"1\",\"framerIntrinsicWidth\":\"300\",\"framerSupportedLayoutHeight\":\"auto\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./TextScrambler.map"],"mappings":"mPASG,SAAwB,EAAc,EAAM,CAAC,GAAK,CAAC,OAAK,WAAW,OAAK,YAAU,UAAU,WAAS,IAAI,gBAAc,GAAG,WAAS,GAAK,OAAK,GAAM,aAAW,+CAA+C,kBAAgB,GAAM,eAAa,OAAO,EAAW,CAAC,EAAY,GAAgBA,EAAS,EAAK,CAAM,CAAC,EAAY,GAAgBA,EAAS,GAAM,CAAM,CAAC,EAAY,GAAgBA,EAAS,GAAM,CAAO,EAAaC,EAAO,KAAK,CAAO,EAAaA,EAAO,KAAK,CAAO,EAAS,GAAqB,CAAO,EAAS,EAAU,EAAa,CAAC,KAAK,CAAC,EAAK,CAAC,CAAO,MAAa,CAAC,GAAG,EAAS,OAAO,MAAoB,EAAe,GAAK,CAAC,CAAC,IA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