{"version":3,"file":"TextDecoder.DpX5O8MX.mjs","names":["useState","useRef"],"sources":["https:/framerusercontent.com/modules/Hl59dWRH4wP3qmZ5YniG/WJHJfWVyY4IdXQQIjMhq/TextDecoder.js"],"sourcesContent":["// Text animator that decodes letters and numbers, with editable speed and animation style\nimport{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect,useRef,useState,startTransition}from\"react\";import{addPropertyControls,ControlType,RenderTarget}from\"framer\";const CHARACTERS=\"0123456789\";function randomChar(){return CHARACTERS[Math.floor(Math.random()*CHARACTERS.length)];}function decodeText(target,progress,style){let out=\"\";for(let i=0;i<target.length;i++){if(progress>i){out+=target[i];}else{if(style===\"random\"){out+=randomChar();}else if(style===\"underscore\"){out+=\"_\";}else{out+=\" \";}}}return out;}/**\n * Text Decoder Animator\n *\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight auto\n * @framerComponentSlot true\n */export default function TextDecoder(props){const{text,speed,animationStyle,font,color,style}=props;const[progress,setProgress]=useState(0);const[display,setDisplay]=useState(text);const intervalRef=useRef(null);const delayTimeoutRef=useRef(null);const containerRef=useRef(null);const[responsiveFontSize,setResponsiveFontSize]=useState(font.fontSize);useEffect(()=>{const updateFontSize=()=>{if(containerRef.current&&style?.width){const containerWidth=containerRef.current.offsetWidth;// Scale font size based on container width (adjust the divisor to control scaling)\nconst baseFontSize=parseFloat(font.fontSize)||32;const scaleFactor=containerWidth/400// 400px as base width\n;const newSize=baseFontSize*scaleFactor;setResponsiveFontSize(`${newSize}px`);}};updateFontSize();if(typeof window!==\"undefined\"){window.addEventListener(\"resize\",updateFontSize);return()=>window.removeEventListener(\"resize\",updateFontSize);}},[font.fontSize,style?.width]);useEffect(()=>{startTransition(()=>setProgress(0));},[text,speed,animationStyle,props.delay]);useEffect(()=>{if(RenderTarget.current()!==RenderTarget.preview){setDisplay(text);return;}if(progress>=text.length){setDisplay(text);return;}intervalRef.current&&clearInterval(intervalRef.current);delayTimeoutRef.current&&clearTimeout(delayTimeoutRef.current);delayTimeoutRef.current=setTimeout(()=>{intervalRef.current=setInterval(()=>{startTransition(()=>{setProgress(p=>{const next=p+1;setDisplay(decodeText(text,next,animationStyle));if(next>=text.length){clearInterval(intervalRef.current);}return next;});});},speed);},props.delay);return()=>{clearInterval(intervalRef.current);clearTimeout(delayTimeoutRef.current);};},[progress,text,speed,animationStyle,props.delay]);useEffect(()=>{setDisplay(decodeText(text,progress,animationStyle));},[progress,text,animationStyle]);return /*#__PURE__*/_jsx(\"span\",{ref:containerRef,style:{...style,...font,fontSize:responsiveFontSize,color,whiteSpace:\"normal\",width:\"100%\",display:\"block\"},children:display});}addPropertyControls(TextDecoder,{text:{type:ControlType.String,title:\"Text\",defaultValue:\"Decoding 123...\"},speed:{type:ControlType.Number,title:\"Speed (ms)\",defaultValue:40,min:10,max:500,step:1,displayStepper:true},animationStyle:{type:ControlType.Enum,title:\"Style\",options:[\"random\",\"underscore\",\"blank\"],optionTitles:[\"Random\",\"Underscore\",\"Blank\"],defaultValue:\"random\",displaySegmentedControl:true},font:{type:ControlType.Font,title:\"Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:\"32px\",variant:\"Semibold\",letterSpacing:\"-0.01em\",lineHeight:\"1.2em\"}},color:{type:ControlType.Color,title:\"Color\",defaultValue:\"#000000\"},delay:{type:ControlType.Number,title:\"Delay (ms)\",defaultValue:0,min:0,max:5e3,step:10,displayStepper:true}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"TextDecoder\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerComponentSlot\":\"true\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerSupportedLayoutHeight\":\"auto\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./TextDecoder.map"],"mappings":"oNACuM,SAAS,GAAY,CAAC,OAAO,EAAW,KAAK,MAAM,KAAK,OAAO,EAAE,EAAiB,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