{"version":3,"file":"RichCustomTextComponent.CromsSMt.mjs","names":["useMemo","__esmMin","pe","init_npm_react_18_3_1","init_jsx_runtime","H","c","init_framer_DKtAEkcX","addPropertyControls","ControlType","escapeRegExp","string","normalizeColors","colors","input","getHighlightStyle","angle","parseWeightMarkers","text","cursor","ranges","open","close","start","RichText","props","marked","value","markedText","at","wrapBefore","markerMode","map","phrases","highlightWords","hw","phrase","b","a","pattern","parts","regex","Tag","tagOptions","tag","elementStyle","style","font","textColor","result","range","index","spanStyle","part","highlightMap","i","init_RichCustomTextComponent","t"],"sources":["https:/framerusercontent.com/modules/TEEYhvpn10V5n0g5HCqg/QO8fqFMm7hClAmGbmtvu/RichCustomTextComponent.js"],"sourcesContent":["// RichText.tsx\nimport{jsx as _jsx}from\"react/jsx-runtime\";import{useMemo,createElement}from\"react\";import{addPropertyControls,ControlType}from\"framer\";const tagOptions=[\"h1\",\"h2\",\"h3\",\"h4\",\"h5\",\"h6\",\"p\"];/**\n * Escapes special characters for Regex (e.g. \"?\", \"*\", \".\")\n */function escapeRegExp(string){return string.replace(/[.*+?^${}()|[\\]\\\\]/g,\"\\\\$&\");}function normalizeColors(input){const colors=Array.isArray(input)?input.filter(c=>typeof c===\"string\"&&c.trim().length>0):[];// If user provided at least 1 color, use it/them (max 3)\nif(colors.length>=1)return colors.slice(0,3);// Fallback if empty: default gradient\nreturn[\"#0099FF\",\"#FF5588\"];}function getHighlightStyle(colors,angle){// Solid Color Mode (1 color)\nif(colors.length===1){return{color:colors[0],display:\"inline\",backgroundImage:\"none\",WebkitBackgroundClip:\"initial\",backgroundClip:\"initial\",WebkitTextFillColor:\"initial\"};}// Gradient Mode (2+ colors)\nreturn{backgroundImage:`linear-gradient(${angle}deg, ${colors.join(\", \")})`,WebkitBackgroundClip:\"text\",backgroundClip:\"text\",WebkitTextFillColor:\"transparent\",color:\"transparent\",display:\"inline\"};}// A matched pair of asterisks changes weight only; unmatched markers stay literal.\nfunction parseWeightMarkers(input){let text=\"\";let cursor=0;const ranges=[];while(cursor<input.length){const open=input.indexOf(\"*\",cursor);const close=open<0?-1:input.indexOf(\"*\",open+1);if(open<0||close<0){text+=input.slice(cursor);break;}text+=input.slice(cursor,open);const start=text.length;text+=input.slice(open+1,close);if(text.length>start)ranges.push({start,end:text.length});cursor=close+1;}return{text,ranges};}/**\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight auto\n */export default function RichText(props){const{text,markedText,wrapBefore=\"\",markerMode=false,tag,highlightWords=[],font,style,textColor}=props;const marked=useMemo(()=>{let value=String(markedText??text??\"\");const at=wrapBefore?value.indexOf(wrapBefore):-1;if(at>0&&value[at-1]!==\"\\n\")value=value.slice(0,at)+\"\\n\"+value.slice(at);return markerMode?parseWeightMarkers(value):{text:String(text??\"\"),ranges:[]};},[text,markedText,wrapBefore,markerMode]);// 1. Prepare Regex and Lookup Map\nconst{regex,highlightMap}=useMemo(()=>{const map=new Map;const phrases=[];if(Array.isArray(highlightWords)){for(const hw of highlightWords){if(hw?.word&&hw.word.trim().length>0){const phrase=hw.word.trim();map.set(phrase.toLowerCase(),hw);phrases.push(phrase);}}}// Sort by length descending to prioritize longer matches\nphrases.sort((a,b)=>b.length-a.length);if(phrases.length===0){return{regex:null,highlightMap:map};}const pattern=`(${phrases.map(escapeRegExp).join(\"|\")})`;return{regex:new RegExp(pattern,\"gi\"),highlightMap:map};},[highlightWords]);// 2. Split text\nconst parts=useMemo(()=>{if(!marked.text)return[];if(!regex)return[marked.text];return marked.text.split(regex);},[marked.text,regex]);const Tag=tagOptions.includes(tag)?tag:\"h1\";const elementStyle={...style,...font,margin:0,display:style?.width===\"100%\"?\"block\":\"inline-block\",color:textColor,whiteSpace:\"pre-wrap\"};// In marker mode, each marked phrase owns its style by position, never by wording.\nconst renderParts=()=>{if(markerMode){const result=[];let cursor=0;marked.ranges.forEach((range,index)=>{if(range.start>cursor)result.push(/*#__PURE__*/_jsx(\"span\",{children:marked.text.slice(cursor,range.start)},\"plain-\"+index));const hw=highlightWords[index]??highlightWords[highlightWords.length-1];const spanStyle={...hw?.highlightFont||{},fontWeight:hw?.highlightFont?.fontWeight??600,...hw?getHighlightStyle(normalizeColors(hw.gradientColors),typeof hw.gradientAngle===\"number\"?hw.gradientAngle:90):{}};result.push(/*#__PURE__*/_jsx(\"span\",{style:spanStyle,children:marked.text.slice(range.start,range.end)},\"marked-\"+index));cursor=range.end;});if(cursor<marked.text.length)result.push(/*#__PURE__*/_jsx(\"span\",{children:marked.text.slice(cursor)},\"plain-end\"));return result;}return parts.map((part,i)=>{if(!part)return null;const hw=highlightMap.get(part.toLowerCase());const spanStyle=hw?{...hw.highlightFont||{},...getHighlightStyle(normalizeColors(hw.gradientColors),typeof hw.gradientAngle===\"number\"?hw.gradientAngle:90)}:undefined;return /*#__PURE__*/_jsx(\"span\",{style:spanStyle,children:part},i);});};return /*#__PURE__*/createElement(Tag,{style:elementStyle},renderParts());}addPropertyControls(RichText,{text:{type:ControlType.String,title:\"Legacy Text\",hidden:props=>!!props.markerMode,defaultValue:\"This is a gradient headline example\",displayTextArea:true,description:\"Wrap words in *asterisks* for semibold. Unmarked words use the base weight. Existing colours and gradients stay unchanged.\"},markedText:{type:ControlType.String,title:\"Title\",displayTextArea:true,hidden:props=>!props.markerMode,description:\"Wrap semibold words in *asterisks*. The highlight style stays with the marked phrase when you change its wording.\"},wrapBefore:{type:ControlType.String,title:\"Break Before\",defaultValue:\"\",description:\"Optional phrase to start on a new line at this breakpoint.\"},markerMode:{type:ControlType.Boolean,title:\"Weight Markers\",defaultValue:false,description:\"Choose semibold words directly in Text using *asterisks*.\"},tag:{type:ControlType.Enum,title:\"Tag\",options:tagOptions,optionTitles:tagOptions.map(t=>t.toUpperCase()),defaultValue:\"h1\"},highlightWords:{type:ControlType.Array,title:\"Highlights\",control:{type:ControlType.Object,controls:{word:{type:ControlType.String,title:\"Phrase\",defaultValue:\"gradient headline\",description:\"Text to highlight.\"},highlightFont:{type:ControlType.Font,title:\"Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:\"40px\",variant:\"Bold\",letterSpacing:\"-0.04em\",lineHeight:\"1em\"}},gradientColors:{type:ControlType.Array,title:\"Colors\",description:\"1 color = Solid. 2+ colors = Gradient.\",control:{type:ControlType.Color},maxCount:3,defaultValue:[\"#0099FF\",\"#FF5588\"]},gradientAngle:{type:ControlType.Number,title:\"Angle\",defaultValue:90,min:0,max:360,unit:\"deg\",displayStepper:true}}},maxCount:10,defaultValue:[{word:\"gradient headline\",highlightFont:{fontSize:\"40px\",variant:\"Bold\",letterSpacing:\"-0.04em\",lineHeight:\"1em\"},gradientColors:[\"#0099FF\",\"#FF5588\"],gradientAngle:90}]},font:{type:ControlType.Font,title:\"Base Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:\"40px\",variant:\"Bold\",letterSpacing:\"-0.04em\",lineHeight:\"1em\"}},textColor:{type:ControlType.Color,title:\"Text Color\",defaultValue:\"#000000\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"RichText\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutHeight\":\"auto\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"any\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./RichCustomTextComponent.map"],"mappings":"A,iLAGG,SAASU,EAAa,EAAO,CAAC,OAAOC,EAAO,QAAQ,sBAAsB,MAAM,CAAE,CAAC,SAASC,EAAgB,EAAM,CAAC,IAAMC,EAAO,MAAM,QAAQC,CAAK,EAAEA,EAAM,OAAO,GAAG,OAAOR,GAAI,UAAUA,EAAE,KAAK,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,EAEjN,OADGO,EAAO,QAAQ,EAASA,EAAO,MAAM,EAAE,CAAC,EACrC,CAAC,UAAU,SAAS,CAAE,CAAC,SAASE,EAAkB,EAAO,EAAM,CAErE,OADGF,EAAO,SAAS,EAAS,CAAC,MAAMA,EAA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