{"version":3,"file":"TextEmbed.BSeW677V.mjs","names":["useMemo"],"sources":["https:/framerusercontent.com/modules/sC8efaEtJFj8b6E5t5aS/KWOLmviSJWI8xXF8RpVK/TextEmbed.js"],"sourcesContent":["// User request: Rebuild TextEmbed slot scaling using a simple layout-aware inline wrapper approach (120px baseline) that scales with the existing Font control, without cloning or replacing slot content, while preserving controls, alignment, and hover behavior.\n// Text embed component that allows integrating elements directly into the text layer, in-line\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useMemo}from\"react\";import{addPropertyControls,ControlType}from\"framer\";import{motion}from\"framer-motion\";/**\n * @framerSupportedLayoutWidth fixed\n * @framerSupportedLayoutHeight auto\n */export default function TextEmbed(props){const{text=\"This is some text with an inline element [] here.\",textColor=\"#000000\",font,slots,elementSettings={align:\"middle\",hoverScale:1.1,hoverRotation:10},style}=props;const{align=\"middle\",hoverScale=1.1,hoverRotation=10}=elementSettings;// Convert slots to array\nconst slotsArray=useMemo(()=>{return slots?Array.isArray(slots)?slots:[slots]:[];},[slots]);// Split text by [] placeholder and create parts array\nconst parts=useMemo(()=>{const result=[];const segments=text.split(\"[]\");segments.forEach((segment,index)=>{const hasSlotAfter=index<segments.length-1;if(hasSlotAfter){// Keep the final word (plus trailing spaces) grouped with the slot so they never wrap apart.\nconst match=segment.match(RegExp(\"^(.*?)(\\\\S+\\\\s*)$\",\"s\"));const prefix=match?match[1]:\"\";const trailingWord=match?match[2]:segment;if(prefix){result.push({type:\"text\",value:prefix});}result.push({type:\"slotGroup\",trailingWord,slotIndex:index});}else if(segment){result.push({type:\"text\",value:segment});}});// If no parts were created, return the original text\nreturn result.length>0?result:[{type:\"text\",value:text}];},[text]);const isFixedWidth=style?.width===\"100%\";const slotBaseSize=120;const resolvedFontSizePx=useMemo(()=>{const rawFontSize=font?.fontSize;if(typeof rawFontSize===\"number\"&&Number.isFinite(rawFontSize)){return rawFontSize;}if(typeof rawFontSize===\"string\"){const parsed=Number.parseFloat(rawFontSize);if(!Number.isFinite(parsed))return 15;const normalized=rawFontSize.trim().toLowerCase();if(normalized.endsWith(\"px\")||/^-?\\d*\\.?\\d+$/.test(normalized)){return parsed;}if(normalized.endsWith(\"rem\")||normalized.endsWith(\"em\")){return parsed*16;}}return 15;},[font]);const slotScale=useMemo(()=>{return Math.max(resolvedFontSizePx/slotBaseSize,.01);},[resolvedFontSizePx]);return /*#__PURE__*/_jsx(\"div\",{style:{...style,position:\"relative\",width:isFixedWidth?\"100%\":undefined,color:textColor,...font},children:parts.map((part,index)=>{if(part.type===\"text\"){return /*#__PURE__*/_jsx(\"span\",{children:part.value},index);}const slotContent=slotsArray[part.slotIndex];const rotation=Math.sin(index*123.45)*hoverRotation;return /*#__PURE__*/_jsxs(\"span\",{style:{display:\"inline-block\",whiteSpace:\"nowrap\"},children:[part.trailingWord,/*#__PURE__*/_jsx(motion.span,{style:{display:\"inline-block\",verticalAlign:align,cursor:\"default\",lineHeight:1,width:slotBaseSize,height:slotBaseSize,zoom:slotScale,whiteSpace:\"nowrap\"},whileHover:{scale:hoverScale,rotate:rotation},children:slotContent||/*#__PURE__*/_jsx(\"span\",{style:{display:\"inline-flex\",alignItems:\"center\",justifyContent:\"center\",border:\"1px dashed #CCCCCC\",borderRadius:4,padding:\"4px 8px\",fontSize:\"12px\",color:\"#CCCCCC\",minWidth:60,minHeight:24},children:\"[]\"})})]},index);})});}addPropertyControls(TextEmbed,{text:{type:ControlType.String,title:\"Text\",defaultValue:\"This is some text with an inline element [] here.\",displayTextArea:true,description:\"Enter text with [] placeholders where you want to insert inline elements.\"},textColor:{type:ControlType.Color,title:\"Text Color\",defaultValue:\"#000000\",description:\"Sets the color of the text.\"},font:{type:ControlType.Font,title:\"Font\",defaultValue:{fontSize:\"15px\",variant:\"Medium\",letterSpacing:\"-0.01em\",lineHeight:\"1.3em\"},controls:\"extended\",defaultFontType:\"sans-serif\",description:\"Configure font family, size, weight, and spacing for the text.\"},slots:{type:ControlType.Slot,title:\"Slots\",maxCount:10,description:\"Add elements to insert inline at [] positions in the text.\"},elementSettings:{type:ControlType.Object,title:\"Elements\",description:\"More components at [8ighty8 Studio](https://8ighty8studio.lemonsqueezy.com)\",controls:{align:{type:ControlType.Enum,title:\"Align\",options:[\"top\",\"middle\",\"bottom\",\"baseline\"],optionTitles:[\"Top\",\"Middle\",\"Bottom\",\"Baseline\"],defaultValue:\"middle\",displaySegmentedControl:true},hoverScale:{type:ControlType.Number,title:\"Hover Scale\",defaultValue:1.1,min:1,max:2,step:.1,displayStepper:true},hoverRotation:{type:ControlType.Number,title:\"Hover Rotate\",defaultValue:10,min:0,max:360,unit:\"deg\"}},defaultValue:{align:\"middle\",hoverScale:1.1,hoverRotation:10}}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"TextEmbed\",\"slots\":[\"slots\"],\"annotations\":{\"framerSupportedLayoutHeight\":\"auto\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"fixed\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./TextEmbed.map"],"mappings":"kOAKG,SAAwB,EAAU,EAAM,CAAC,GAAK,CAAC,OAAK,oDAAoD,YAAU,UAAU,OAAK,QAAM,kBAAgB,CAAC,MAAM,SAAS,WAAW,IAAI,cAAc,EAAE,EAAE,SAAO,EAAW,CAAC,QAAM,SAAS,aAAW,IAAI,gBAAc,IAAI,EACxQ,EAAWA,MAAoB,EAAM,MAAM,QAAQ,CAAK,EAAE,EAAM,CAAC,CAAK,EAAE,CAAC,EAAI,CAAC,CAAK,CAAC,EACpF,EAAMA,MAAY,CAAC,IAAM,EAAO,CAAC,EAAQ,EAAS,EAAK,MAAM,IAAI,EAEvE,OAFyE,EAAS,SAAS,EAAQ,IAAQ,CAA4C,GAAxB,EAAM,EAAS,OAAO,EAAkB,CACvK,IAAM,EAAM,EAAQ,MAAM,OAAO,oBAAoB,GAAG,CAAC,EAAQ,EAAO,EAAM,EAAM,GAAG,GAA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