{"version":3,"file":"Typewriter_Code.BOZ4hT7D.mjs","names":["useState","useRef"],"sources":["https:/framerusercontent.com/modules/yNbtCc6LcwWeoSBSFgLp/HoNGNcgGK3x2gvd7qgwk/Typewriter_Code.js"],"sourcesContent":["// Typewriter effect component with customizable settings for font, colors, speed, delays, multiple lines, and loop option\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useState,useEffect,useRef,startTransition}from\"react\";import{addPropertyControls,ControlType,useIsStaticRenderer}from\"framer\";/**\n * Typewriter Effect Component\n * \n * Creates a realistic typing animation with customizable speed, delays, and styling options.\n * Supports multiple lines, looping, and cursor customization.\n *\n * @framerSupportedLayoutWidth auto\n * @framerSupportedLayoutHeight auto\n */export default function Typewriter(props){const{text=\"Hello World!\",headingLevel=\"h1\",font,textColor,cursorColor,showCursor,cursorThickness,typingSpeed,delayStart,enableLoop,hideCursorWhenDone}=props;const[currentText,setCurrentText]=useState(\"\");const[isTyping,setIsTyping]=useState(false);const[showCursorBlink,setShowCursorBlink]=useState(true);const[isComplete,setIsComplete]=useState(false);const[hasStarted,setHasStarted]=useState(false);const timeoutRef=useRef(null);const isStatic=useIsStaticRenderer();// Cleanup function to clear timeout\nconst clearCurrentTimeout=()=>{if(timeoutRef.current){clearTimeout(timeoutRef.current);timeoutRef.current=null;}};useEffect(()=>{if(isStatic){setCurrentText(text||\"\");return;}// Initial delay before starting\nif(!hasStarted){clearCurrentTimeout();timeoutRef.current=window.setTimeout(()=>{startTransition(()=>setHasStarted(true));},delayStart*1e3);return;}if(currentText.length<text.length){startTransition(()=>setIsTyping(true));startTransition(()=>setIsComplete(false));clearCurrentTimeout();timeoutRef.current=window.setTimeout(()=>{startTransition(()=>{setCurrentText(prev=>text.slice(0,prev.length+1));});},typingSpeed*1e3);}else{startTransition(()=>setIsTyping(false));startTransition(()=>setIsComplete(true));if(enableLoop){clearCurrentTimeout();timeoutRef.current=window.setTimeout(()=>{startTransition(()=>{setCurrentText(\"\");setHasStarted(false);});},2e3);}}return()=>clearCurrentTimeout();},[currentText,isTyping,text,typingSpeed,delayStart,hasStarted,enableLoop,isStatic]);// Cursor blinking effect\nuseEffect(()=>{if(isStatic||!showCursor)return;const blinkInterval=setInterval(()=>{startTransition(()=>setShowCursorBlink(prev=>!prev));},530);return()=>clearInterval(blinkInterval);},[showCursor,isStatic]);// Cleanup on unmount\nuseEffect(()=>{return()=>clearCurrentTimeout();},[]);const isFixedWidth=props?.style&&props.style.width===\"100%\";const shouldShowCursor=showCursor&&(!hideCursorWhenDone||!isComplete||enableLoop);const HeadingTag=headingLevel;return /*#__PURE__*/_jsx(\"div\",{style:{...props.style,position:\"relative\",...isFixedWidth?{...props?.style}:{width:\"max-content\"},display:\"inline-block\"},children:/*#__PURE__*/_jsxs(HeadingTag,{style:{fontSize:font.fontSize,fontStyle:font.fontStyle,fontWeight:font.fontWeight,fontFamily:font.fontFamily,letterSpacing:font.letterSpacing,lineHeight:font.lineHeight,color:textColor,whiteSpace:\"pre-wrap\",margin:0},children:[currentText,shouldShowCursor&&/*#__PURE__*/_jsx(\"span\",{style:{color:cursorColor,opacity:showCursorBlink?1:0,transition:\"opacity 0.1s ease-in-out\",display:\"inline-block\",width:`${cursorThickness}px`,backgroundColor:cursorColor,height:\"0.9em\",marginLeft:\"2px\",verticalAlign:\"middle\"}})]})});}addPropertyControls(Typewriter,{text:{type:ControlType.String,title:\"Text\",defaultValue:\"Hello World!\",placeholder:\"Enter text...\"},headingLevel:{type:ControlType.Enum,title:\"Heading Level\",options:[\"h1\",\"h2\",\"h3\",\"h4\",\"h5\",\"h6\"],optionTitles:[\"H1\",\"H2\",\"H3\",\"H4\",\"H5\",\"H6\"],defaultValue:\"h1\",displaySegmentedControl:false},font:{type:ControlType.Font,title:\"Font\",defaultValue:{fontSize:\"24px\",variant:\"Regular\",letterSpacing:\"-0.01em\",lineHeight:\"1.2em\"},controls:\"extended\",defaultFontType:\"sans-serif\"},textColor:{type:ControlType.Color,title:\"Text Color\",defaultValue:\"#000000\"},showCursor:{type:ControlType.Boolean,title:\"Show Cursor\",defaultValue:true,enabledTitle:\"Show\",disabledTitle:\"Hide\"},cursorColor:{type:ControlType.Color,title:\"Cursor Color\",defaultValue:\"#000000\",hidden:({showCursor})=>!showCursor},cursorThickness:{type:ControlType.Number,title:\"Cursor Thickness\",defaultValue:2,min:1,max:10,step:1,unit:\"px\",hidden:({showCursor})=>!showCursor},typingSpeed:{type:ControlType.Number,title:\"Typing Speed\",defaultValue:.1,min:.01,max:5,step:.01,unit:\"s\"},delayStart:{type:ControlType.Number,title:\"Delay Start\",defaultValue:0,min:0,max:50,step:.1,unit:\"s\"},enableLoop:{type:ControlType.Boolean,title:\"Enable Loop\",defaultValue:true,enabledTitle:\"Loop\",disabledTitle:\"Once\"},hideCursorWhenDone:{type:ControlType.Boolean,title:\"Hide Cursor When Done\",defaultValue:false,enabledTitle:\"Hide\",disabledTitle:\"Keep\",hidden:({showCursor})=>!showCursor}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"Typewriter\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"auto\",\"framerSupportedLayoutHeight\":\"auto\",\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Typewriter_Code.map"],"mappings":"uNASG,SAAwB,EAAW,EAAM,CAAC,GAAK,CAAC,OAAK,eAAe,eAAa,KAAK,OAAK,YAAU,cAAY,aAAW,kBAAgB,cAAY,aAAW,aAAW,sBAAoB,EAAW,CAAC,EAAY,GAAgBA,EAAS,EAAE,EAAO,CAAC,EAAS,GAAaA,EAAS,EAAK,EAAO,CAAC,EAAgB,GAAoBA,EAAS,EAAI,EAAO,CAAC,EAAW,GAAeA,EAAS,EAAK,EAAO,CAAC,EAAW,GAAeA,EAAS,EAAK,EAAQ,EAAWC,EAAO,IAAI,EAAQ,EAAS,EAAoB,EAC1f,MAAwB,CAAC,AAAwD,EAAW,WAA5C,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