{"version":3,"file":"TextDecoder.ChMupnhV.mjs","names":["useState","useRef","__esmMin","init_ssg_sandbox_shims","te","window","_e","de","init_jsx_runtime","init_npm_react_18_3_1","ce","init_framer_DKWANagr","addPropertyControls","ControlType","RenderTarget","randomChar","CHARACTERS","decodeText","out","target","progress","style","TextDecoder","props","setProgress","display","setDisplay","text","intervalRef","delayTimeoutRef","containerRef","responsiveFontSize","setResponsiveFontSize","font","updateFontSize","containerWidth","newSize","speed","animationStyle","next","p","init_TextDecoder"],"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":"A,gNACuM,SAASe,GAAY,CAAC,OAAOC,EAAW,KAAK,MAAM,KAAK,OAAO,EAAE,EAAiB,EAAG,CAAC,SAASC,EAAW,EAAO,EAAS,EAAM,CAAC,IAAIC,EAAI,GAAG,IAAI,IAAI,EAAE,EAAE,EAAEC,EAAO,OAAO,IAAK,AAAyHD,GAAtHE,EAAS,EAAQD,EAAO,GAAYE,IAAQ,SAAeN,EAAW,EAAWM,IAAQ,aAAmB,IAAe,IAAO,OAAOH,CAAI,CAMjgB,SAAwBI,EAAY,EAAM,CAAC,GAAK,CAAC,OAAK,QAAM,iBAAe,OAAK,QAAM,SAAOC,EAAW,CAACH,EAASI,GAAaxB,EAAS,CAAC,EAAO,CAACyB,EAAQC,GAAY1B,EAAS2B,CAAI,EAAQC,EAAY3B,EAAO,IAAI,EAAQ4B,EAAgB5B,EAAO,IAAI,EAAQ6B,EAAa7B,EAAO,IAAI,EAAO,CAAC8B,EAAmBC,GAAuBhC,EAASiC,EAAK,QAAQ,EAE2xB,OAFzxBvB,MAAc,CAAC,IAAMwB,MAAmB,CAAC,GAAGJ,EAAa,SAAST,GAAO,MAAM,CAAC,IAAMc,EAAeL,EAAa,QAAQ,YAEpdM,GADY,WAAWH,EAAK,QAAQ,GAAG,KAAqBE,EAAe,KAC1CH,EAAsB,GAAGI,EAAQ,GAAG,CAAE,CAAC,EAAmB,GAAjBF,EAAe,EAAY7B,IAAS,OAA8D,OAAjDA,EAAO,iBAAiB,SAAS6B,CAAc,MAAY7B,EAAO,oBAAoB,SAAS6B,CAAc,CAAG,EAAE,CAACD,EAAK,SAASZ,GAAO,KAAK,CAAC,EAAEX,MAAc,CAACN,MAAoBoB,EAAY,CAAC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