{"version":3,"file":"TextHighlight.DkvrLkPT.mjs","names":["React.useRef","React.useState","React.useCallback","React.useMemo","Element","_Fragment"],"sources":["https:/framerusercontent.com/modules/bTNkyTQRjbULh9lGHsPZ/4mZIjGggqgeCGs7ZIDml/TextHighlight.js"],"sourcesContent":["// User instructions: Create a Framer component that takes a multiline text and places a rounded rectangle matching exactly the limits of the text (also multiline). Use Framer typography properties and render SEO-friendly text directly in the code.\nimport{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from\"react/jsx-runtime\";import*as React from\"react\";import{addPropertyControls,ControlType,useIsStaticRenderer}from\"framer\";/**\n * @framerIntrinsicWidth 720\n * @framerIntrinsicHeight 260\n *\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight any\n */export default function TextHighlight(props){const{text,tag,backgroundColor,textColor,borderRadius,padding,uppercase,font,style}=props;const isStatic=useIsStaticRenderer();const textRef=React.useRef(null);const rootRef=React.useRef(null);const[rects,setRects]=React.useState([]);const parsePadding=React.useCallback(value=>{const parts=String(value||\"\").trim().split(/\\s+/).filter(Boolean);const toPx=v=>{const m=v.match(/^(-?[0-9]*\\.?[0-9]+)px$/);return m?parseFloat(m[1]):0;};const nums=parts.map(toPx);const top=nums[0]??0;const right=nums[1]??top;const bottom=nums[2]??top;const left=nums[3]??right;return{top,right,bottom,left};},[]);const pad=React.useMemo(()=>parsePadding(padding),[padding,parsePadding]);React.useLayoutEffect(()=>{if(isStatic)return;if(typeof window===\"undefined\")return;if(!textRef.current||!rootRef.current)return;let raf=0;const measure=()=>{if(!textRef.current||!rootRef.current)return;const rootBounds=rootRef.current.getBoundingClientRect();// Trim the extra leading added by line-height so the background hugs the glyphs\nconst cs=window.getComputedStyle(textRef.current);const lineHeightPx=parseFloat(cs.lineHeight||\"\");const fontSizePx=parseFloat(cs.fontSize||\"\");const trim=Number.isFinite(lineHeightPx)&&Number.isFinite(fontSizePx)?Math.max(0,(lineHeightPx-fontSizePx)/2):0;const range=document.createRange();range.selectNodeContents(textRef.current);const clientRects=Array.from(range.getClientRects());const next=clientRects.filter(r=>r.width>0&&r.height>0).map(r=>{const trimmedH=Math.max(0,r.height-trim*2);return{x:r.left-rootBounds.left-pad.left,y:r.top-rootBounds.top-pad.top+trim,w:r.width+pad.left+pad.right,h:trimmedH+pad.top+pad.bottom};});React.startTransition(()=>setRects(next));};raf=window.requestAnimationFrame(measure);const ro=new ResizeObserver(()=>{window.cancelAnimationFrame(raf);raf=window.requestAnimationFrame(measure);});ro.observe(rootRef.current);ro.observe(textRef.current);return()=>{ro.disconnect();window.cancelAnimationFrame(raf);};},[isStatic,text,tag,uppercase,font,backgroundColor,textColor,borderRadius,pad.left,pad.right,pad.top,pad.bottom]);const isFixedWidth=!!style&&style.width===\"100%\";const isFixedHeight=!!style&&style.height===\"100%\";const containerStyle=React.useMemo(()=>({...style,position:\"relative\",// Only fill the frame on axes that are explicitly set to 100%.\n    display:isFixedWidth||isFixedHeight?\"block\":\"inline-block\",width:isFixedWidth?\"100%\":\"max-content\",height:isFixedHeight?\"100%\":\"max-content\",overflow:\"visible\"}),[style,isFixedWidth,isFixedHeight]);const textStyle=React.useMemo(()=>({...font,color:textColor,textTransform:uppercase?\"uppercase\":\"none\",whiteSpace:\"pre-wrap\",wordBreak:\"break-word\",overflowWrap:\"anywhere\",display:\"inline\",maxWidth:\"100%\",// If the component is auto-sized on an axis, ensure it sizes to content.\n    ...isFixedWidth?null:{width:\"max-content\"},...isFixedHeight?null:{height:\"max-content\"}}),[font,textColor,uppercase,isFixedWidth,isFixedHeight]);const staticHighlightStyle=React.useMemo(()=>({...textStyle,backgroundColor,padding,borderRadius,WebkitBoxDecorationBreak:\"clone\",boxDecorationBreak:\"clone\"}),[textStyle,backgroundColor,padding,borderRadius]);const wrapperStyle=React.useMemo(()=>({position:\"relative\",display:\"inline-block\",maxWidth:\"100%\",verticalAlign:\"top\",// If the component is auto-sized on an axis, ensure it sizes to content.\n    ...isFixedWidth?{width:\"100%\"}:{width:\"max-content\"}}),[isFixedWidth]);const Element=tag;return /*#__PURE__*/_jsx(\"div\",{style:containerStyle,ref:rootRef,children:/*#__PURE__*/_jsx(Element,{style:{margin:0,position:\"relative\"},children:/*#__PURE__*/_jsx(\"span\",{style:wrapperStyle,children:isStatic?/*#__PURE__*/_jsx(\"span\",{ref:textRef,style:staticHighlightStyle,children:text}):/*#__PURE__*/_jsxs(_Fragment,{children:[rects.map((r,i)=>/*#__PURE__*/_jsx(\"div\",{\"aria-hidden\":\"true\",style:{position:\"absolute\",left:r.x,top:r.y,width:r.w,height:r.h,backgroundColor,borderRadius,zIndex:0}},i)),/*#__PURE__*/_jsx(\"span\",{ref:textRef,style:{...textStyle,position:\"relative\",zIndex:1},children:text})]})})})});}addPropertyControls(TextHighlight,{text:{type:ControlType.String,title:\"Text\",defaultValue:\"ANTICIPATING AI\\nCONSEQUENCES IN\\nPRODUCTS\",displayTextArea:true},uppercase:{type:ControlType.Boolean,title:\"Uppercase\",defaultValue:false,enabledTitle:\"On\",disabledTitle:\"Off\"},tag:{type:ControlType.Enum,title:\"Tag\",options:[\"h1\",\"h2\",\"h3\",\"p\",\"span\"],optionTitles:[\"H1\",\"H2\",\"H3\",\"P\",\"Span\"],defaultValue:\"h1\"},backgroundColor:{type:ControlType.Color,title:\"Background\",defaultValue:\"#FFFFFF\"},textColor:{type:ControlType.Color,title:\"Text\",defaultValue:\"#000000\"},borderRadius:{type:ControlType.Number,title:\"Radius\",defaultValue:12,min:0,max:64,step:1},padding:{type:ControlType.Padding,title:\"Background Padding\",defaultValue:\"8px 14px 10px\"},font:{type:ControlType.Font,title:\"Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:\"120px\",variant:\"Regular\",letterSpacing:\"-0.04em\",lineHeight:\"0.9em\",textAlign:\"left\"}}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"TextHighlight\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"any\",\"framerSupported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