{"version":3,"file":"TagHighlighter.CdVQGC18.mjs","names":["useRef","useState","useMemo"],"sources":["https:/framerusercontent.com/modules/kiBk1cobKh1YFxcFtdfu/4ovzSTriweSrq7xTFTHO/TagHighlighter.js"],"sourcesContent":["// Tag highlighter component: highlights specified words in a text with a color\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{addPropertyControls,ControlType}from\"framer\";import{useMemo}from\"react\";import{useInView}from\"framer-motion\";import{useRef,useState,useEffect,startTransition}from\"react\";/**\n * TagHighlighter\n *\n * Highlights specified words in a text with a color\n *\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight auto\n *\n * CHECKPOINT: User is satisfied with the current result and wants to explore more after this.\n */export default function TagHighlighter(props){const{text,tags,font,style,animationDuration=.6,animationEasing=\"cubic-bezier(.6,.2,.2,1)\"}=props;const ref=useRef(null);const isInView=useInView(ref,{once:true,margin:\"-10% 0px\"});const[animate,setAnimate]=useState(false);useEffect(()=>{if(isInView){startTransition(()=>setAnimate(true));}},[isInView]);// Split text into words and highlight tags\nconst content=useMemo(()=>{if(!text)return null;if(!tags||tags.length===0)return text;// Split text into word tokens while preserving spaces and punctuation\nconst tokens=text.split(/(\\b[\\w']+\\b)/);const parts=[];tokens.forEach((token,i)=>{if(!token)return;const trimmedToken=token.trim();if(!trimmedToken){parts.push(token);return;}// Find matching tag for whole-word token or standalone symbols (e.g. \".\", \"!\", \"?\", etc.)\nconst tagIndex=tags.findIndex(t=>t.word===token||t.word===trimmedToken);if(tagIndex===-1){parts.push(token);return;}const{color}=tags[tagIndex];const delay=tagIndex*.1;parts.push(/*#__PURE__*/_jsxs(\"span\",{style:{background:\"transparent\",borderRadius:4,padding:\"0 1px\",margin:\"0 1px\",position:\"relative\",display:\"inline-flex\",alignItems:\"center\",verticalAlign:\"baseline\",overflow:\"hidden\"},children:[/*#__PURE__*/_jsx(\"span\",{style:{position:\"absolute\",inset:0,background:color,zIndex:0,width:animate?\"100%\":\"0%\",transition:`width ${animationDuration}s ${animationEasing}`,transitionDelay:`${delay}s`}}),/*#__PURE__*/_jsx(\"span\",{style:{position:\"relative\",zIndex:1},children:token})]},\"word-\"+i));});return parts;},[text,tags,animate,animationDuration,animationEasing]);return /*#__PURE__*/_jsx(\"div\",{ref:ref,style:{...style,...font,width:style?.width||\"100%\",minHeight:\"1em\",display:\"inline-block\",wordBreak:\"break-word\",background:\"transparent\"},children:content});}addPropertyControls(TagHighlighter,{text:{type:ControlType.String,title:\"Text\",defaultValue:\"Type your text and tag words to highlight.\",displayTextArea:true},tags:{type:ControlType.Array,title:\"Tags\",control:{type:ControlType.Object,controls:{word:{type:ControlType.String,title:\"Word\",defaultValue:\"highlight\"},color:{type:ControlType.Color,title:\"Color\",defaultValue:\"#FFFB8F\"}}},defaultValue:[{word:\"highlight\",color:\"#FFFB8F\"},{word:\"tag\",color:\"#A0E7E5\"}],maxCount:10},font:{type:ControlType.Font,title:\"Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:\"18px\",variant:\"Medium\",letterSpacing:\"-0.01em\",lineHeight:\"1.3em\"}},// Add animation controls\nanimationDuration:{type:ControlType.Number,title:\"Anim Duration\",defaultValue:.6,min:.1,max:2,step:.05,unit:\"s\"},animationEasing:{type:ControlType.Enum,title:\"Anim Easing\",options:[\"ease\",\"linear\",\"ease-in\",\"ease-out\",\"ease-in-out\",\"cubic-bezier(.6,.2,.2,1)\"],optionTitles:[\"Ease\",\"Linear\",\"Ease In\",\"Ease Out\",\"Ease In Out\",\"Custom (Marker)\"],defaultValue:\"cubic-bezier(.6,.2,.2,1)\",displaySegmentedControl:true}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"TagHighlighter\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerSupportedLayoutHeight\":\"auto\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//#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