{"version":3,"file":"TextHighlight.Br3QL9fY.mjs","names":["React.useRef","React.useState","React.useCallback","React.useMemo","Element","_Fragment","__esmMin","ne","init_npm_react_18_3_1","te","pe","le","window","init_jsx_runtime","c","_e","de","init_ssg_sandbox_shims","useIsStaticRenderer","addPropertyControls","ControlType","init_framer_CaDWdxiz","TextHighlight","props","isStatic","textRef","rootRef","rects","setRects","parsePadding","nums","value","m","v","top","right","pad","padding","raf","measure","rootBounds","cs","lineHeightPx","fontSizePx","trim","range","next","r","trimmedH","ro","text","tag","uppercase","font","backgroundColor","textColor","borderRadius","isFixedWidth","style","isFixedHeight","containerStyle","textStyle","staticHighlightStyle","wrapperStyle","l","i","init_TextHighlight"],"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\",\"framerSupportedLayoutHeight\":\"any\",\"framerContractVersion\":\"1\",\"framerIntrinsicWidth\":\"720\",\"framerIntrinsicHeight\":\"260\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./TextHighlight.map"],"mappings":"A,4OAOG,SAAwBsB,EAAc,EAAM,CAAC,GAAK,CAAC,OAAK,MAAI,kBAAgB,YAAU,eAAa,UAAQ,YAAU,OAAK,SAAOC,EAAYC,EAASN,EAAoB,EAAQO,EAAQzB,EAAa,IAAI,EAAQ0B,EAAQ1B,EAAa,IAAI,EAAO,CAAC2B,EAAMC,GAAU3B,EAAe,CAAC,CAAC,EAAQ4B,EAAa3B,EAAkB,GAAO,CAA2J,IAAM4B,EAApJ,OAAOC,GAAO,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,OAAO,OAA4G,CAAA,CAAM,IAA9F,GAAG,CAAC,IAAMC,EAAEC,EAAE,MAAM,yBAAyB,EAAE,OAAOD,EAAE,WAAWA,EAAE,EAAE,EAAE,CAAE,CAA2B,EAAQE,EAAIJ,EAAK,IAAI,EAAQK,EAAML,EAAK,IAAII,EAAwD,MAAM,CAAC,MAAI,QAAM,OAAxDJ,EAAK,IAAII,EAAsD,KAAvCJ,EAAK,IAAIK,CAAkC,CAAE,EAAE,CAAC,CAAC,EAAQC,EAAIjC,MAAkB0B,EAAaQ,CAAO,EAAE,CAACA,EAAQ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