{"version":3,"file":"DecryptedText.UE82M20r.mjs","names":["useState","useRef","p","startTransition"],"sources":["https:/framerusercontent.com/modules/tyyo2dG3PGA1oAAUGWu3/gNDE3hZkIXlobFmtT1LL/DecryptedText.js"],"sourcesContent":["// Decrypted text animation component with scrambling effect on hover or view\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useEffect,useState,useRef,startTransition}from\"react\";import{motion}from\"framer-motion\";import{addPropertyControls,ControlType}from\"framer\";/**\n * @framerSupportedLayoutWidth auto\n * @framerSupportedLayoutHeight auto\n */export default function DecryptedText(props){const{text=\"Hello World\",speed=50,maxIterations=10,sequential=false,revealDirection=\"start\",useOriginalCharsOnly=false,characters=\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!@#$%^&*()_+\",animateOn=\"hover\",font={fontSize:\"40px\",fontWeight:700,letterSpacing:\"-0.04em\",lineHeight:\"1em\"},textColor=\"#000000\",encryptedColor=\"#CCCCCC\",style}=props;const[displayText,setDisplayText]=useState(text);const[isHovering,setIsHovering]=useState(false);const[isScrambling,setIsScrambling]=useState(false);const[revealedIndices,setRevealedIndices]=useState(new Set);const[hasAnimated,setHasAnimated]=useState(false);const containerRef=useRef(null);useEffect(()=>{let interval;let currentIteration=0;const getNextIndex=revealedSet=>{const textLength=text.length;switch(revealDirection){case\"start\":return revealedSet.size;case\"end\":return textLength-1-revealedSet.size;case\"center\":{const middle=Math.floor(textLength/2);const offset=Math.floor(revealedSet.size/2);const nextIndex=revealedSet.size%2===0?middle+offset:middle-offset-1;if(nextIndex>=0&&nextIndex<textLength&&!revealedSet.has(nextIndex)){return nextIndex;}for(let i=0;i<textLength;i++){if(!revealedSet.has(i))return i;}return 0;}default:return revealedSet.size;}};const availableChars=useOriginalCharsOnly?Array.from(new Set(text.split(\"\"))).filter(char=>char!==\" \"):characters.split(\"\");const shuffleText=(originalText,currentRevealed)=>{if(useOriginalCharsOnly){const positions=originalText.split(\"\").map((char,i)=>({char,isSpace:char===\" \",index:i,isRevealed:currentRevealed.has(i)}));const nonSpaceChars=positions.filter(p=>!p.isSpace&&!p.isRevealed).map(p=>p.char);for(let i=nonSpaceChars.length-1;i>0;i--){const j=Math.floor(Math.random()*(i+1));[nonSpaceChars[i],nonSpaceChars[j]]=[nonSpaceChars[j],nonSpaceChars[i]];}let charIndex=0;return positions.map(p=>{if(p.isSpace)return\" \";if(p.isRevealed)return originalText[p.index];return nonSpaceChars[charIndex++];}).join(\"\");}else{return originalText.split(\"\").map((char,i)=>{if(char===\" \")return\" \";if(currentRevealed.has(i))return originalText[i];return availableChars[Math.floor(Math.random()*availableChars.length)];}).join(\"\");}};if(isHovering){startTransition(()=>setIsScrambling(true));interval=window.setInterval(()=>{setRevealedIndices(prevRevealed=>{if(sequential){if(prevRevealed.size<text.length){const nextIndex=getNextIndex(prevRevealed);const newRevealed=new Set(prevRevealed);newRevealed.add(nextIndex);startTransition(()=>setDisplayText(shuffleText(text,newRevealed)));return newRevealed;}else{clearInterval(interval);startTransition(()=>setIsScrambling(false));return prevRevealed;}}else{startTransition(()=>setDisplayText(shuffleText(text,prevRevealed)));currentIteration++;if(currentIteration>=maxIterations){clearInterval(interval);startTransition(()=>{setIsScrambling(false);setDisplayText(text);});}return prevRevealed;}});},speed);}else{startTransition(()=>{setDisplayText(text);setRevealedIndices(new Set);setIsScrambling(false);});}return()=>{if(interval)clearInterval(interval);};},[isHovering,text,speed,maxIterations,sequential,revealDirection,characters,useOriginalCharsOnly]);useEffect(()=>{if(typeof window===\"undefined\")return;if(animateOn!==\"view\"&&animateOn!==\"both\")return;const observerCallback=entries=>{entries.forEach(entry=>{if(entry.isIntersecting&&!hasAnimated){startTransition(()=>{setIsHovering(true);setHasAnimated(true);});}});};const observerOptions={root:null,rootMargin:\"0px\",threshold:.1};const observer=new IntersectionObserver(observerCallback,observerOptions);const currentRef=containerRef.current;if(currentRef){observer.observe(currentRef);}return()=>{if(currentRef){observer.unobserve(currentRef);}};},[animateOn,hasAnimated]);const hoverProps=animateOn===\"hover\"||animateOn===\"both\"?{onMouseEnter:()=>startTransition(()=>setIsHovering(true)),onMouseLeave:()=>startTransition(()=>setIsHovering(false))}:{};return /*#__PURE__*/_jsxs(motion.span,{ref:containerRef,style:{...style,display:\"inline-block\",whiteSpace:\"pre-wrap\",width:\"max-content\",...font},...hoverProps,children:[/*#__PURE__*/_jsx(\"span\",{style:{position:\"absolute\",width:\"1px\",height:\"1px\",padding:0,margin:\"-1px\",overflow:\"hidden\",clip:\"rect(0,0,0,0)\",border:0},children:displayText}),/*#__PURE__*/_jsx(\"span\",{\"aria-hidden\":\"true\",children:displayText.split(\"\").map((char,index)=>{const isRevealedOrDone=revealedIndices.has(index)||!isScrambling||!isHovering;return /*#__PURE__*/_jsx(\"span\",{style:{color:isRevealedOrDone?textColor:encryptedColor},children:char},index);})})]});}addPropertyControls(DecryptedText,{text:{type:ControlType.String,title:\"Text\",defaultValue:\"Hello World\",displayTextArea:true},font:{type:ControlType.Font,title:\"Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:\"40px\",variant:\"Bold\",letterSpacing:\"-0.04em\",lineHeight:\"1em\"}},textColor:{type:ControlType.Color,title:\"Text Color\",defaultValue:\"#000000\"},encryptedColor:{type:ControlType.Color,title:\"Encrypted Color\",defaultValue:\"#CCCCCC\"},animateOn:{type:ControlType.Enum,title:\"Animate On\",options:[\"hover\",\"view\",\"both\"],optionTitles:[\"Hover\",\"View\",\"Both\"],defaultValue:\"hover\",displaySegmentedControl:true},sequential:{type:ControlType.Boolean,title:\"Sequential\",defaultValue:false,enabledTitle:\"On\",disabledTitle:\"Off\"},revealDirection:{type:ControlType.Enum,title:\"Reveal Direction\",options:[\"start\",\"end\",\"center\"],optionTitles:[\"Start\",\"End\",\"Center\"],defaultValue:\"start\",displaySegmentedControl:true,hidden:({sequential})=>!sequential},speed:{type:ControlType.Number,title:\"Speed\",defaultValue:50,min:10,max:200,step:10,unit:\"ms\"},maxIterations:{type:ControlType.Number,title:\"Max Iterations\",defaultValue:10,min:1,max:50,step:1,hidden:({sequential})=>sequential},useOriginalCharsOnly:{type:ControlType.Boolean,title:\"Use Original Chars\",defaultValue:false,enabledTitle:\"On\",disabledTitle:\"Off\"},characters:{type:ControlType.String,title:\"Characters\",defaultValue:\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!@#$%^&*()_+\",displayTextArea:true,hidden:({useOriginalCharsOnly})=>useOriginalCharsOnly}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"DecryptedText\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"auto\",\"framerSupportedLayoutHeight\":\"auto\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./DecryptedText.map"],"mappings":"qQAIG,SAAwB,EAAc,EAAM,CAAC,GAAK,CAAC,OAAK,cAAc,QAAM,GAAG,gBAAc,GAAG,aAAW,GAAM,kBAAgB,QAAQ,uBAAqB,GAAM,aAAW,mEAAmE,YAAU,QAAQ,OAAK,CAAC,SAAS,OAAO,WAAW,IAAI,cAAc,UAAU,WAAW,MAAM,CAAC,YAAU,UAAU,iBAAe,UAAU,SAAO,EAAW,CAAC,EAAY,GAAgBA,EAAS,EAAK,CAAM,CAAC,EAAW,GAAeA,EAAS,GAAM,CAAM,CAAC,EAAa,GAAiBA,EAAS,GAAM,CAAM,CAAC,EAAgB,GAAoBA,EAAS,IAAI,IAAI,CAAM,CAAC,EAAY,GAAgBA,EAAS,GAAM,CAAO,EAAaC,EAAO,KAAK,CAAC,MAAc,CAAC,IAAI,EAAa,EAAiB,EAAQ,EAAa,GAAa,CAAC,IAAM,EAAW,EAAK,OAAO,OAAO,EAAP,CAAwB,IAAI,QAAQ,OAAO,EAAY,KAAK,IAAI,MAAM,OAAO,EAAW,EAAE,EAAY,KAAK,IAAI,SAAS,CAAC,IAAM,EAAO,KA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