{"version":3,"file":"TextHighlight.CRC0L1es.mjs","names":["React.useRef","React.useState","React.useCallback","React.useMemo","_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\",\"framerSupportedLayout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