{"version":3,"file":"TextTypewriter.CUueQfD2.mjs","names":["React.useState","React.useMemo","React.useCallback","_Fragment"],"sources":["https:/framerusercontent.com/modules/awJ7GONrnIslKgIQucCL/EYCny3HQ4eZfouVA4pWw/TextTypewriter.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from\"react/jsx-runtime\";import*as React from\"react\";import{addPropertyControls,ControlType}from\"framer\";import{motion}from\"framer-motion\";/**\n * @copyright ©framersnippets.com\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight any\n * @framerDisableUnlink\n **/export default function TextTypewriter(props){const migratedProps=migrateSpecificWords(props);const{content,specificWords,font,fontColor,cursor,effect,tag:Tag}=migratedProps;const[state,setState]=React.useState({displayedContent:\"\",wordIndex:0,isDeleting:false,isBlinking:false});const fullContent=React.useMemo(()=>`${content} ${specificWords[state.wordIndex]?.text||\"\"}`,[content,specificWords,state.wordIndex]);const updateState=React.useCallback(()=>{setState(prevState=>{const{displayedContent,isDeleting,wordIndex}=prevState;if(!isDeleting&&displayedContent.length===fullContent.length){return{...prevState,isBlinking:true};}else if(isDeleting&&displayedContent.length===content.length){return{...prevState,wordIndex:(wordIndex+1)%specificWords.length,isDeleting:false,isBlinking:false};}return{...prevState,displayedContent:fullContent.substring(0,displayedContent.length+(isDeleting?-1:1))};});},[fullContent,content.length,specificWords.length]);React.useEffect(()=>{const timeoutId=setTimeout(updateState,effect.typingSpeed);return()=>clearTimeout(timeoutId);},[state.displayedContent,state.isDeleting,updateState,effect.typingSpeed]);React.useEffect(()=>{if(state.isBlinking){const timeoutId=setTimeout(()=>{setState(prevState=>({...prevState,isDeleting:true,isBlinking:false}));},effect.delay);return()=>clearTimeout(timeoutId);}},[state.isBlinking,effect.delay]);const renderContent=React.useCallback(()=>/*#__PURE__*/_jsxs(_Fragment,{children:[/*#__PURE__*/_jsx(\"span\",{children:state.displayedContent.substring(0,content.length)},\"content\"),/*#__PURE__*/_jsx(\"span\",{style:{color:specificWords[state.wordIndex]?.color},children:state.displayedContent.substring(content.length)},\"specific-word\")]}),[state.displayedContent,content.length,specificWords,state.wordIndex]);return /*#__PURE__*/_jsx(motion.div,{style:{...font,color:fontColor,whiteSpace:\"pre-wrap\",position:\"relative\",wordWrap:\"break-word\"},children:/*#__PURE__*/_jsxs(Tag,{style:{all:\"unset\",fontSize:font.fontSize},children:[renderContent(),/*#__PURE__*/_jsx(CursorComponent,{isBlinking:state.isBlinking,cursor:cursor,isMixedMargin:false},\"cursor\")]})});}TextTypewriter.defaultProps={content:\"Typewriter.\",specificWords:[{text:\"Cycle.\",color:\"#0599ff\"},{text:\"Content.\",color:\"#0599ff\"},{text:\"Color.\",color:\"#0599ff\"},{text:\"Cursor.\",color:\"#0599ff\"},{text:\"Blink.\",color:\"#0599ff\"},{text:\"Transition.\",color:\"#0599ff\"}],font:{fontSize:15,lineHeight:1,letterSpacing:0},fontColor:\"#000000\",cursor:{cursorColor:\"#0599ff\",cursorHeight:15,cursorWidth:2,verticalAlign:\"middle\",margin:0,blink:false},effect:{typingSpeed:100,delay:1500},tag:\"p\"};addPropertyControls(TextTypewriter,{font:{type:ControlType.Font,title:\"Font\",controls:\"extended\",displayTextAlignment:true,defaultFontType:\"sans-serif\",defaultValue:{fontSize:15,lineHeight:1,letterSpacing:0}},content:{type:ControlType.String,title:\"Content\",placeholder:\"Type something…\",displayTextArea:true},fontColor:{type:ControlType.Color,title:\"‎\",defaultValue:\"#000000\"},specificWords:{type:ControlType.Array,title:\"Typewriter\",propertyControl:{type:ControlType.Object,controls:{text:{type:ControlType.String,title:\"Text\"},color:{type:ControlType.Color,title:\"Color\"}}}},cursor:{type:ControlType.Object,title:\"Cursor\",controls:{cursorColor:{type:ControlType.Color,title:\"Color\",defaultValue:\"#0599ff\"},cursorHeight:{type:ControlType.Number,title:\"Height\",displayStepper:true,defaultValue:18},cursorWidth:{type:ControlType.Number,title:\"Width\",displayStepper:true,defaultValue:2},verticalAlign:{type:ControlType.Enum,title:\"Align\",defaultValue:\"center\",options:[\"top\",\"middle\",\"bottom\"],optionTitles:[\"Top\",\"Center\",\"Bottom\"],displaySegmentedControl:true},margin:{type:ControlType.FusedNumber,title:\"Margin\",toggleKey:\"isMixedMargin\",toggleTitles:[\"All\",\"Individual\"],valueKeys:[\"topMargin\",\"rightMargin\",\"bottomMargin\",\"leftMargin\"],valueLabels:[\"T\",\"R\",\"B\",\"L\"],min:0},blink:{type:ControlType.Boolean,title:\"Blinking\",defaultValue:false,enabledTitle:\"On\",disabledTitle:\"Off\"}}},effect:{type:ControlType.Object,title:\"Transition\",controls:{typingSpeed:{type:ControlType.Number,title:\"Speed\",min:0,max:200,defaultValue:100,displayStepper:true,step:10},delay:{type:ControlType.Number,title:\"Delay\",min:0,max:5e3,defaultValue:2e3,displayStepper:true,step:100}}},tag:{type:ControlType.Enum,title:\"Tag\",options:[\"h1\",\"h2\",\"h3\",\"h4\",\"h5\",\"h6\",\"p\",\"span\"],optionTitles:[\"h1\",\"h2\",\"h3\",\"h4\",\"h5\",\"h6\",\"p\",\"span\"],defaultValue:\"p\",description:`\nImportant: Update the component in Framer (Assets > Components > Click purple update button) to prevent crashes.\n`}});const CursorComponent=/*#__PURE__*/React.memo(({isBlinking,cursor,isMixedMargin=false})=>{const marginValue=isMixedMargin?`${cursor.margin}px`:`${cursor.topMargin}px ${cursor.rightMargin}px ${cursor.bottomMargin}px ${cursor.leftMargin}px`;const cursorStyle={display:\"inline-block\",width:cursor.cursorWidth,height:cursor.cursorHeight,backgroundColor:cursor.cursorColor,verticalAlign:cursor.verticalAlign,margin:marginValue,overflow:\"visible\"};return /*#__PURE__*/_jsx(motion.span,{style:cursorStyle,animate:{opacity:isBlinking&&cursor.blink?[0,1]:1},transition:{repeat:isBlinking&&cursor.blink?Infinity:0,duration:.6,repeatType:\"reverse\",type:\"spring\",delay:.2}});});function migrateSpecificWords(props){if(Array.isArray(props.specificWords)&&typeof props.specificWords[0]===\"string\"){return{...props,specificWords:props.specificWords.map(word=>({text:word,color:props.specificWordsColor||\"#0599ff\"}))};}return props;}\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"TextTypewriter\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"any\",\"framerSupportedLayoutHeight\":\"any\",\"framerDisableUnlink\":\"\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./TextTypewriter.map"],"mappings":"+XAKI,SAAwB,EAAe,EAAM,CAAiD,GAAK,CAAC,UAAQ,gBAAc,OAAK,YAAU,SAAO,SAAO,IAAI,GAAzF,EAAqB,EAAM,CAAsF,CAAC,EAAM,GAAUA,EAAe,CAAC,iBAAiB,GAAG,UAAU,EAAE,WAAW,GAAM,WAAW,GAAM,CAAC,CAAO,EAAYC,MAAkB,GAAG,EAAQ,GAAG,EAAc,EAAM,YAAY,MAAM,KAAK,CAAC,EAAQ,EAAc,EAAM,UAAU,CAAC,CAAO,EAAYC,MAAsB,CAAC,EAAS,GAAW,CAAC,GAAK,CAAC,mBAAiB,aAAW,aAAW,EAAiR,MAApQ,CAAC,GAAY,EAAiB,SAAS,EAAY,OAAc,CAAC,GAAG,EAAU,WAAW,GAAK,CAAU,GAAY,EAAiB,SAAS,EAAQ,OAAc,CAAC,GAAG,EAAU,WAAW,EAAU,GAAG,EAAc,OAAO,WAAW,GAAM,WAAW,GAAM,CAAQ,CAAC,GAAG,EAAU,iBAAiB,EAAY,UAAU,EAAE,EAAiB,QAAQ,EAAW,GAAG,GAAG,CAAC,EAAG,EAAG,CAAC,EAAY,EAAQ,OAAO,EAAc,OAAO,CAAC,CAAC,MAAoB,CAAC,IAAM,EAAU,WAAW,EAAY,EAAO,YAAY,CAAC,UAAU,aAAa,EAAU,EAAG,CAAC,EAAM,iBAAiB,EAAM,WAAW,EAAY,EAAO,YAAY,CAAC,CAAC,MAAoB,CAAC,GAAG,EAAM,WAAW,CAAC,IAAM,EAAU,eAAe,CAAC,EA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