{"version":3,"file":"CustomUnderlineText.Cs6LuRAJ.mjs","names":["useState","useCallback","useMemo","__esmMin","ne","init_npm_react_18_3_1","te","pe","_e","init_jsx_runtime","addPropertyControls","init_framer_BWFVvmND","ControlType","escapeRegex","input","isWholeWordBoundary","prev","start","text","next","end","prevIsWord","nextIsWord","parsePhrases","item","collectMatches","phrases","pattern","b","a","regex","caseSensitive","ranges","match","value","wholeWord","range","matchScope","CustomUnderlineText","props","isHovered","setIsHovered","onMouseEnter","onMouseLeave","markedPhrases","matches","segments","result","cursor","effectiveUnderlineColor","hoverBehavior","hoverUnderlineColor","underlineColor","effectiveThickness","hoverThickness","underlineThickness","TextTag","semanticTag","style","textColor","textFont","segment","underlineStyle","markerRadius","markerHeight","markerOffset","underlineOpacity","index","underlineOffset","init_CustomUnderlineText"],"sources":["https:/framerusercontent.com/modules/cq83pVSAOmQeVGv1XNVy/4jvLh829JWKvTt6s05S9/CustomUnderlineText.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{startTransition,useCallback,useMemo,useState}from\"react\";import{addPropertyControls,ControlType}from\"framer\";function escapeRegex(input){return input.replace(/[.*+?^${}()|[\\]\\\\]/g,\"\\\\$&\");}function isWholeWordBoundary(text,start,end){const prev=start>0?text[start-1]:\"\";const next=end<text.length?text[end]:\"\";const prevIsWord=/\\w/.test(prev);const nextIsWord=/\\w/.test(next);return!prevIsWord&&!nextIsWord;}function parsePhrases(input){return input.split(/[\\n,]/).map(item=>item.trim()).filter(Boolean);}function collectMatches(text,phrases,caseSensitive,wholeWord,matchScope){if(!text||phrases.length===0)return[];const sorted=[...phrases].sort((a,b)=>b.length-a.length);const pattern=sorted.map(escapeRegex).join(\"|\");const flags=caseSensitive?\"g\":\"gi\";const regex=new RegExp(pattern,flags);const ranges=[];let match=regex.exec(text);while(match){const value=match[0];const start=match.index;const end=start+value.length;const passWholeWord=!wholeWord||isWholeWordBoundary(text,start,end);if(passWholeWord){const overlaps=ranges.some(range=>start<range.end&&end>range.start);if(!overlaps){ranges.push({start,end});if(matchScope===\"first\")break;}}match=regex.exec(text);}return ranges.sort((a,b)=>a.start-b.start);}/**\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight auto\n */export default function CustomUnderlineText(props){const{text,semanticTag,markedPhrases,matchScope,caseSensitive,wholeWord,textFont,textAlign,textColor,underlineColor,underlineThickness,underlineOffset,underlineStyle,underlineOpacity,markerRadius,markerHeight,markerOffset,hoverBehavior,hoverUnderlineColor,hoverThickness,style}=props;const[isHovered,setIsHovered]=useState(false);const onMouseEnter=useCallback(()=>{startTransition(()=>setIsHovered(true));},[]);const onMouseLeave=useCallback(()=>{startTransition(()=>setIsHovered(false));},[]);const phrases=useMemo(()=>parsePhrases(markedPhrases),[markedPhrases]);const matches=useMemo(()=>collectMatches(text,phrases,caseSensitive,wholeWord,matchScope),[text,phrases,caseSensitive,wholeWord,matchScope]);const segments=useMemo(()=>{if(matches.length===0)return[{value:text,marked:false}];const result=[];let cursor=0;for(const match of matches){if(match.start>cursor){result.push({value:text.slice(cursor,match.start),marked:false});}result.push({value:text.slice(match.start,match.end),marked:true});cursor=match.end;}if(cursor<text.length){result.push({value:text.slice(cursor),marked:false});}return result;},[text,matches]);const effectiveUnderlineColor=isHovered&&hoverBehavior===\"colorShift\"?hoverUnderlineColor:underlineColor;const effectiveThickness=isHovered&&hoverBehavior===\"thicken\"?hoverThickness:underlineThickness;const TextTag=semanticTag;return /*#__PURE__*/_jsx(\"div\",{style:{position:\"relative\",display:\"block\",width:\"100%\",height:\"auto\",...style},onMouseEnter:hoverBehavior===\"none\"?undefined:onMouseEnter,onMouseLeave:hoverBehavior===\"none\"?undefined:onMouseLeave,children:/*#__PURE__*/_jsx(TextTag,{style:{margin:0,whiteSpace:\"pre-wrap\",overflowWrap:\"break-word\",color:textColor,textAlign,fontFamily:textFont.fontFamily||\"Soleil, Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif\",fontSize:textFont.fontSize,lineHeight:textFont.lineHeight,letterSpacing:textFont.letterSpacing,fontWeight:textFont.fontWeight,fontStyle:textFont.fontStyle},children:segments.map((segment,index)=>{if(!segment.marked)return /*#__PURE__*/_jsx(\"span\",{children:segment.value},index);if(underlineStyle===\"marker\"){return /*#__PURE__*/_jsx(\"span\",{style:{borderRadius:markerRadius,backgroundImage:`linear-gradient(to top, rgba(0,0,0,0) ${Math.max(0,100-markerHeight)}%, ${effectiveUnderlineColor} ${Math.max(0,100-markerHeight)}%)`,backgroundRepeat:\"no-repeat\",backgroundSize:\"100% 100%\",backgroundPosition:`0 ${markerOffset}px`,opacity:underlineOpacity},children:segment.value},index);}return /*#__PURE__*/_jsx(\"span\",{style:{textDecorationLine:\"underline\",textDecorationStyle:underlineStyle,textDecorationColor:effectiveUnderlineColor,textDecorationThickness:`${effectiveThickness}px`,textUnderlineOffset:`${underlineOffset}px`,textDecorationSkipInk:\"none\",opacity:underlineOpacity},children:segment.value},index);})})});}addPropertyControls(CustomUnderlineText,{text:{type:ControlType.String,title:\"Text Content\",defaultValue:\"Design text naturally and mark phrases for a custom underline treatment.\",displayTextArea:true},semanticTag:{type:ControlType.Enum,title:\"Semantic Tag\",options:[\"p\",\"h1\",\"h2\",\"h3\",\"h4\",\"h5\",\"h6\",\"span\",\"div\"],optionTitles:[\"p\",\"h1\",\"h2\",\"h3\",\"h4\",\"h5\",\"h6\",\"span\",\"div\"],defaultValue:\"p\"},markedPhrases:{type:ControlType.String,title:\"Marked\",defaultValue:\"custom underline\\nphrases\",displayTextArea:true},matchScope:{type:ControlType.Enum,title:\"Matches\",options:[\"first\",\"all\"],optionTitles:[\"First Only\",\"All\"],defaultValue:\"all\",displaySegmentedControl:true},caseSensitive:{type:ControlType.Boolean,title:\"Case\",defaultValue:false,enabledTitle:\"Sensitive\",disabledTitle:\"Ignore\"},wholeWord:{type:ControlType.Boolean,title:\"Whole Word\",defaultValue:false,enabledTitle:\"On\",disabledTitle:\"Off\"},textFont:{type:ControlType.Font,title:\"Text Style\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:\"18px\",lineHeight:\"1.45em\",letterSpacing:\"-0.01em\",variant:\"Regular\"}},textAlign:{type:ControlType.Enum,title:\"Align\",options:[\"left\",\"center\",\"right\"],optionTitles:[\"Left\",\"Center\",\"Right\"],defaultValue:\"left\",displaySegmentedControl:true},textColor:{type:ControlType.Color,title:\"Text\",defaultValue:\"#000000\"},underlineColor:{type:ControlType.Color,title:\"Underline\",defaultValue:\"#F28C28\"},underlineThickness:{type:ControlType.Number,title:\"Thickness\",defaultValue:2,min:1,max:12,step:1,unit:\"px\"},underlineOffset:{type:ControlType.Number,title:\"Offset\",defaultValue:2,min:-6,max:20,step:1,unit:\"px\"},underlineStyle:{type:ControlType.Enum,title:\"Style\",options:[\"solid\",\"dashed\",\"dotted\",\"double\",\"wavy\",\"marker\"],optionTitles:[\"Solid\",\"Dashed\",\"Dotted\",\"Double\",\"Wavy\",\"Marker\"],defaultValue:\"solid\"},underlineOpacity:{type:ControlType.Number,title:\"Opacity\",defaultValue:1,min:.1,max:1,step:.05},markerRadius:{type:ControlType.Number,title:\"Marker Radius\",defaultValue:3,min:0,max:24,step:1,unit:\"px\",hidden:props=>props.underlineStyle!==\"marker\"},markerHeight:{type:ControlType.Number,title:\"Marker Height\",defaultValue:45,min:10,max:100,step:1,unit:\"%\",hidden:props=>props.underlineStyle!==\"marker\"},markerOffset:{type:ControlType.Number,title:\"Marker Offset\",defaultValue:0,min:-10,max:12,step:1,unit:\"px\",hidden:props=>props.underlineStyle!==\"marker\"},hoverBehavior:{type:ControlType.Enum,title:\"Hover\",options:[\"none\",\"colorShift\",\"thicken\"],optionTitles:[\"None\",\"Color Shift\",\"Thicken\"],defaultValue:\"none\"},hoverUnderlineColor:{type:ControlType.Color,title:\"Hover Color\",defaultValue:\"#D96A00\",hidden:props=>props.hoverBehavior!==\"colorShift\"},hoverThickness:{type:ControlType.Number,title:\"Hover Thick\",defaultValue:4,min:1,max:14,step:1,unit:\"px\",hidden:props=>props.hoverBehavior!==\"thicken\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"CustomUnderlineText\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerSupportedLayoutHeight\":\"auto\",\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./CustomUnderlineText.map"],"mappings":"A,2LAA+J,SAASa,EAAY,EAAM,CAAC,OAAOC,EAAM,QAAQ,sBAAsB,MAAM,CAAE,CAAC,SAASC,EAAoB,EAAK,EAAM,EAAI,CAAC,IAAMC,EAAKC,EAAM,EAAEC,EAAKD,EAAM,GAAG,GAASE,EAAKC,EAAIF,EAAK,OAAOA,EAAKE,GAAK,GAASC,EAAW,KAAK,KAAKL,CAAI,EAAQM,EAAW,KAAK,KAAKH,CAAI,EAAE,MAAM,CAACE,GAAY,CAACC,CAAW,CAAC,SAASC,EAAa,EAAM,CAAC,OAAOT,EAAM,MAAM,OAAO,CAAC,CAAC,IAAI,GAAMU,EAAK,KAAK,CAAC,CAAC,CAAC,OAAO,OAAO,CAAE,CAAC,SAASC,EAAe,EAAK,EAAQ,EAAc,EAAU,EAAW,CAAC,GAAG,CAACP,GAAMQ,EAAQ,SAAS,EAAE,MAAM,CAAC,EAA2D,IAAMC,EAAlD,CAAC,GAAGD,CAAO,CAAC,CAAC,MAAM,EAAE,IAAIE,EAAE,OAAOC,EAAE,MAA2B,CAAC,CAAC,IAAIhB,CAAW,CAAC,CAAC,KAAK,GAAG,EAA2CiB,EAAM,IAAI,OAAOH,EAA9CI,EAAc,IAAI,IAAyC,EAAQC,EAAO,CAAC,EAAMC,EAAMH,EAAM,KAAKZ,CAAI,EAAE,KAAMe,GAAM,CAAC,IAAMC,EAAMD,EAAM,GAAShB,EAAMgB,EAAM,MAAYb,EAAIH,EAAMiB,EAAM,OAA2E,IAAhD,CAACC,GAAWpB,EAA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