{"version":3,"file":"TypewriterEffect.CiGsVG61.mjs","names":["useState"],"sources":["https:/framerusercontent.com/modules/IN9gvnAdlYMBaIcVCl1Q/XubxS0PUpolfylArbgoL/TypewriterEffect.js"],"sourcesContent":["// Typewriter effect with configurable static text, words, speeds, cursor, and font\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useState,useEffect,startTransition}from\"react\";import{addPropertyControls,ControlType}from\"framer\";/**\n * Typewriter Effect\n *\n * @framerIntrinsicWidth 300\n * @framerIntrinsicHeight 50\n *\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight auto\n */export default function TypewriterEffect(props){const{staticText=\"Search for\",words=[\"internet\",\"YouTube\",\"WIX\"],typeMode=\"letter\",speed=100,eraseSpeed=50,delay=1500,cursor=true,cursorCharacter=\"|\",cursorColor=\"#000\",font={fontSize:18,variant:\"Regular\",letterSpacing:0,lineHeight:1.5,textAlign:\"left\"},style,colors=[{color:\"#000\",label:\"Static text\"},{color:\"#000\",label:\"Animated words\"}]}=props;const[displayedText,setDisplayedText]=useState(\"\");const[index,setIndex]=useState(0);const[wordIndex,setWordIndex]=useState(0);const[isDeleting,setIsDeleting]=useState(false);const[blink,setBlink]=useState(true);useEffect(()=>{const blinkInterval=setInterval(()=>{startTransition(()=>setBlink(prev=>!prev));},500);return()=>clearInterval(blinkInterval);},[]);useEffect(()=>{if(!words||words.length===0)return;if(wordIndex>=words.length)return;const currentWord=words[wordIndex];if(typeMode===\"word\"){// Word-by-word typing\nif(!isDeleting){if(displayedText!==currentWord){const timeout=setTimeout(()=>{startTransition(()=>{setDisplayedText(currentWord);setIndex(currentWord.length);});},speed);return()=>clearTimeout(timeout);}else{// Word is fully displayed, wait before erasing\nconst timeout=setTimeout(()=>{startTransition(()=>setIsDeleting(true));},delay);return()=>clearTimeout(timeout);}}else{// Erasing the word\nconst timeout=setTimeout(()=>{startTransition(()=>{setDisplayedText(\"\");setIndex(0);setIsDeleting(false);setWordIndex(prev=>(prev+1)%words.length);});},eraseSpeed);return()=>clearTimeout(timeout);}}else{// Letter-by-letter typing (original behavior)\nif(!isDeleting&&index<currentWord.length){const timeout=setTimeout(()=>{startTransition(()=>{setDisplayedText(prev=>prev+currentWord[index]);setIndex(index+1);});},speed);return()=>clearTimeout(timeout);}else if(isDeleting&&index>0){const timeout=setTimeout(()=>{startTransition(()=>{setDisplayedText(prev=>prev.slice(0,-1));setIndex(index-1);});},eraseSpeed);return()=>clearTimeout(timeout);}else if(!isDeleting&&index===currentWord.length){// Letter typing complete, wait before erasing\nconst timeout=setTimeout(()=>{startTransition(()=>setIsDeleting(true));},delay);return()=>clearTimeout(timeout);}else if(isDeleting&&index===0){// Letter erasing complete, move to next word\nstartTransition(()=>{setIsDeleting(false);setWordIndex(prev=>(prev+1)%words.length);});}}},[index,isDeleting,wordIndex,words,typeMode,speed,eraseSpeed,delay,displayedText]);return /*#__PURE__*/_jsxs(\"div\",{style:{...style,fontSize:font.fontSize,fontWeight:font.fontWeight,fontStyle:font.fontStyle,letterSpacing:font.letterSpacing,lineHeight:font.lineHeight,textAlign:font.textAlign,color:colors[0]?.color||font.color||\"#000\",fontFamily:font.fontFamily,width:\"100%\",minWidth:0,display:\"inline-block\",whiteSpace:\"pre-line\"},children:[/*#__PURE__*/_jsx(\"span\",{style:{color:colors[0]?.color},children:staticText}),\" \",/*#__PURE__*/_jsx(\"span\",{style:{color:colors[1]?.color},children:displayedText}),cursor&&/*#__PURE__*/_jsx(\"span\",{style:{opacity:blink?1:0,color:cursorColor},\"aria-hidden\":\"true\",children:cursorCharacter||\"|\"})]});}addPropertyControls(TypewriterEffect,{staticText:{type:ControlType.String,title:\"Static Text\",defaultValue:\"Search for\"},words:{type:ControlType.Array,title:\"Words\",control:{type:ControlType.String},defaultValue:[\"internet\",\"YouTube\",\"WIX\"]},typeMode:{type:ControlType.Enum,title:\"Type Mode\",options:[\"letter\",\"word\"],optionTitles:[\"Letter by Letter\",\"Word by Word\"],defaultValue:\"letter\",displaySegmentedControl:true},speed:{type:ControlType.Number,title:\"Typing Speed (ms)\",defaultValue:100,min:20,max:500},eraseSpeed:{type:ControlType.Number,title:\"Erasing Speed (ms)\",defaultValue:50,min:20,max:500},delay:{type:ControlType.Number,title:\"Delay Before Erasing (ms)\",defaultValue:1500,min:500,max:5e3},cursor:{type:ControlType.Boolean,title:\"Show Cursor\",defaultValue:true},cursorCharacter:{type:ControlType.String,title:\"Cursor Character\",defaultValue:\"|\"},cursorColor:{type:ControlType.Color,title:\"Cursor Color\",defaultValue:\"#000\"},colors:{type:ControlType.Array,title:\"Colors\",description:undefined,control:{type:ControlType.Object,controls:{color:{type:ControlType.Color,title:\"Color\"},label:{type:ControlType.String,title:\"Label\",defaultValue:\"\",placeholder:\"e.g. Static text or Animated words\"}}},defaultValue:[{color:\"#000\",label:\"Static text\"},{color:\"#000\",label:\"Animated words\"}],maxCount:2},font:{type:ControlType.Font,title:\"Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:18,variant:\"Regular\",letterSpacing:0,lineHeight:1.5,textAlign:\"left\"}}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"TypewriterEffect\",\"slots\":[],\"annotations\":{\"framerIntrinsicHeight\":\"50\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"auto\",\"framerIntrinsicWidth\":\"300\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./TypewriterEffect.map"],"mappings":"+LASG,SAAwB,EAAiB,EAAM,CAAC,GAAK,CAAC,aAAW,aAAa,QAAM,CAAC,WAAW,UAAU,KAAK,EAAE,WAAS,SAAS,QAAM,IAAI,aAAW,GAAG,QAAM,KAAK,SAAO,GAAK,kBAAgB,IAAI,cAAY,OAAO,OAAK,CAAC,SAAS,GAAG,QAAQ,UAAU,cAAc,EAAE,WAAW,IAAI,UAAU,MAAM,EA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