{"version":3,"file":"ColorTaggedText.C1eAcjKH.mjs","names":["useRef","useMemo"],"sources":["https:/framerusercontent.com/modules/D6FStjM3IiBZEOKuTzO9/mxbvXbQW8TI9fqbBdmkw/ColorTaggedText.js"],"sourcesContent":["// Text component with inline color tags using #colorcode syntax\n// Example: \"Hello #dc1034world\" will make \"world\" red\n// Text between < and > will animate from primary to secondary color\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useMemo,useRef}from\"react\";import{addPropertyControls,ControlType}from\"framer\";import{motion,useInView}from\"framer-motion\";/**\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight any\n */export default function ColorTaggedText(props){const{text=\"Hello #dc1034world* #0099FFthis #22CC66works <secondary>\",primaryColor=\"#000000\",secondaryColor=\"#dc1034\",beforeAnimationColor=\"rgba(255, 255, 255, 0.2)\",repeatAnimation=false,font,style}=props;const ref=useRef(null);const isInView=useInView(ref,{once:!repeatAnimation});const parsedText=useMemo(()=>{// First, handle <text> for secondary color\n// Then handle #colorcode syntax\nconst parts=[];let currentIndex=0;// Process the text character by character\nlet i=0;while(i<text.length){// Check for <br> pattern (line break)\nif(text.substring(i,i+4)===\"<br>\"){// Add any text before the <br>\nif(i>currentIndex){processSegment(text.substring(currentIndex,i),parts,primaryColor);}// Add line break\nparts.push({type:\"br\"});i+=4;currentIndex=i;continue;}// Check for <text> pattern (secondary color)\nif(text[i]===\"<\"){// Find the closing >\nconst closeIndex=text.indexOf(\">\",i+1);if(closeIndex!==-1){// Add any text before the <\nif(i>currentIndex){processSegment(text.substring(currentIndex,i),parts,primaryColor);}// Add the secondary colored text (without the < >) with animation flag\nparts.push({text:text.substring(i+1,closeIndex),color:secondaryColor,animated:true});i=closeIndex+1;currentIndex=i;continue;}}i++;}// Process remaining text\nif(currentIndex<text.length){processSegment(text.substring(currentIndex),parts,primaryColor);}return parts;},[text,primaryColor,secondaryColor]);// Helper function to process segments that may contain #colorcode\nfunction processSegment(segment,parts,defaultColor){const regex=/#([0-9a-fA-F]{6}|[0-9a-fA-F]{3})([^#<>]*)/g;let lastIndex=0;let match;while((match=regex.exec(segment))!==null){if(match.index>lastIndex){parts.push({text:segment.substring(lastIndex,match.index),color:defaultColor});}parts.push({text:match[2],color:`#${match[1]}`});lastIndex=match.index+match[0].length;}if(lastIndex<segment.length){parts.push({text:segment.substring(lastIndex),color:defaultColor});}}const isFixedWidth=style?.width===\"100%\";return /*#__PURE__*/_jsx(\"div\",{ref:ref,style:{...style,position:\"relative\",display:isFixedWidth?\"block\":\"inline-block\",...isFixedWidth?{}:{width:\"max-content\"},...font},children:parsedText.map((part,index)=>\"type\"in part&&part.type===\"br\"?/*#__PURE__*/_jsx(\"br\",{},index):part.animated?/*#__PURE__*/_jsxs(motion.span,{style:{position:\"relative\",display:\"inline-block\"},children:[/*#__PURE__*/_jsx(\"span\",{style:{color:beforeAnimationColor},children:part.text}),/*#__PURE__*/_jsx(motion.span,{style:{position:\"absolute\",top:0,left:0,color:secondaryColor,clipPath:\"inset(0 100% 0 0)\"},initial:{clipPath:\"inset(0 100% 0 0)\"},animate:isInView?{clipPath:\"inset(0 0% 0 0)\"}:{},transition:{duration:1.2,ease:\"easeInOut\"},children:part.text})]},index):/*#__PURE__*/_jsx(\"span\",{style:{color:part.color},children:part.text},index))});}addPropertyControls(ColorTaggedText,{text:{type:ControlType.String,title:\"Text\",defaultValue:\"Hello #dc1034world #0099FFthis <secondary color>\",displayTextArea:true},primaryColor:{type:ControlType.Color,title:\"Primary Color\",defaultValue:\"#000000\"},secondaryColor:{type:ControlType.Color,title:\"Secondary Color\",defaultValue:\"#dc1034\"},beforeAnimationColor:{type:ControlType.Color,title:\"Before Animation Color\",defaultValue:\"rgba(255, 255, 255, 0.2)\"},repeatAnimation:{type:ControlType.Boolean,title:\"Repeat Animation\",defaultValue:false,enabledTitle:\"On\",disabledTitle:\"Off\"},font:{type:ControlType.Font,title:\"Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:\"32px\",variant:\"Semibold\",letterSpacing:\"-0.03em\",lineHeight:\"1.2em\"}}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"ColorTaggedText\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"any\",\"framerSupportedLayoutWidth\":\"any\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./ColorTaggedText.map"],"mappings":"2OAMG,SAAwB,EAAgB,EAAM,CAAC,GAAK,CAAC,OAAK,2DAA2D,eAAa,UAAU,iBAAe,UAAU,uBAAqB,2BAA2B,kBAAgB,GAAM,OAAK,SAAO,EAAY,EAAIA,EAAO,KAAK,CAAO,EAAS,EAAU,EAAI,CAAC,KAAK,CAAC,EAAgB,CAAC,CAAO,EAAWC,MAAY,CAE1W,IAAM,EAAM,EAAE,CAAK,EAAa,EAC5B,EAAE,EAAE,KAAM,EAAE,EAAK,QAAO,CAC5B,GAAG,EAAK,UAAU,EAAE,EAAE,EAAE,GAAG,OAAO,CAC/B,EAAE,GAAc,EAAe,EAAK,UAAU,EAAa,EAAE,CAAC,EAAM,EAAa,CACpF,EAAM,KAAK,CAAC,KAAK,KAAK,CAAC,CAAC,GAAG,EAAE,EAAa,EAAE,SAC5C,GAAG,EAAK,KAAK,IAAI,CACjB,IAAM,EAAW,EAAK,QAAQ,IAAI,EAAE,EAAE,CAAC,GAAG,IAAa,GAAG,CACvD,EAAE,GAAc,EAAe,EAAK,UAAU,EAAa,EAAE,CAAC,EAAM,EAAa,CACpF,EAAM,KAAK,CAAC,KAAK,EAAK,UAAU,EAAE,EAAE,EAAW,CAAC,MAAM,EAAe,SAAS,GAAK,CAAC,CAAC,EAAE,EAAW,EAAE,EAAa,EAAE,UAAW,IAChC,OAA3F,EAAa,EAAK,QAAQ,EAAe,EAAK,UAAU,EAAa,CAAC,EAAM,EAAa,CAAS,GAAQ,CAAC,EAAK,EAAa,EAAe,CAAC,CAChJ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