{"version":3,"file":"TextWrap.lc2_ZPbs.mjs","names":["useMemo","__esmMin","pe","c","init_jsx_runtime","init_npm_react_18_3_1","addPropertyControls","init_framer_CKT6jEEQ","ControlType","escapeRegex","value","getSlotRegex","mid","wrapper","start","end","normalizeChildren","children","parseText","parts","regex","slotWrapper","lastIndex","match","slotIndex","text","content","slots","gap","TextWrap","props","Tag","tag","isInline","elements","style","textColor","font","init_TextWrap"],"sources":["https:/framerusercontent.com/modules/rgalUyX153B0hAjmBghD/OZvZEc5slQX2QU8VfWkA/TextWrap.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{addPropertyControls,ControlType}from\"framer\";import{useMemo}from\"react\";/**\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight any\n */function escapeRegex(value){return value.replace(/[.*+?^${}()|[\\]\\\\]/g,\"\\\\$&\");}function getSlotRegex(wrapper){const mid=Math.floor(wrapper.length/2);const start=wrapper.slice(0,mid);const end=wrapper.slice(mid);return new RegExp(`${escapeRegex(start)}${escapeRegex(end)}`,\"g\");}function normalizeChildren(children){if(!children)return[];return Array.isArray(children)?children:[children];}function parseText({text,slotWrapper,slots,gap}){const parts=[];const regex=getSlotRegex(slotWrapper);let lastIndex=0;let match;let slotIndex=0;const mid=Math.floor(slotWrapper.length/2);const start=slotWrapper.slice(0,mid);const end=slotWrapper.slice(mid);while((match=regex.exec(text))!==null){if(match.index>lastIndex){parts.push(/*#__PURE__*/_jsx(\"span\",{style:{whiteSpace:\"pre-wrap\"},children:text.slice(lastIndex,match.index)},`text-${lastIndex}`));}const content=slots[slotIndex];parts.push(/*#__PURE__*/_jsx(\"span\",{style:{display:content?\"inline-block\":\"inline\",verticalAlign:\"baseline\",paddingInline:gap/2,color:content?undefined:\"currentColor\",opacity:content?undefined:.35},children:content??`${start}${end}`},`slot-${slotIndex}`));slotIndex+=1;lastIndex=match.index+match[0].length;}if(lastIndex<text.length){parts.push(/*#__PURE__*/_jsx(\"span\",{style:{whiteSpace:\"pre-wrap\"},children:text.slice(lastIndex)},`text-${lastIndex}`));}return parts;}export default function TextWrap(props){const{text,slotWrapper=\"[]\",tag=\"div\",textColor,font,gap,textAlign,children,style}=props;const Tag=tag;const isInline=tag===\"span\";const elements=useMemo(()=>{return parseText({text,slotWrapper,slots:normalizeChildren(children),gap});},[text,slotWrapper,children,gap]);return /*#__PURE__*/_jsx(Tag,{style:{...style,margin:0,padding:0,display:isInline?\"inline\":\"block\",position:\"relative\",width:style?.width===\"100%\"?\"100%\":\"auto\",color:textColor,textAlign,overflowWrap:\"break-word\",wordWrap:\"break-word\",...font},children:elements});}addPropertyControls(TextWrap,{text:{type:ControlType.String,title:\"Text\",defaultValue:\"This is some text with [] and [] placeholders.\",displayTextArea:true},slotWrapper:{type:ControlType.String,title:\"Slot Marker\",defaultValue:\"[]\"},children:{type:ControlType.Array,title:\"Slots\",control:{type:ControlType.ComponentInstance},maxCount:10},tag:{type:ControlType.Enum,title:\"HTML Tag\",options:[\"div\",\"p\",\"span\",\"h1\",\"h2\",\"h3\",\"h4\"],optionTitles:[\"Div\",\"Paragraph\",\"Span\",\"H1\",\"H2\",\"H3\",\"H4\"],defaultValue:\"div\"},textColor:{type:ControlType.Color,title:\"Text Color\",defaultValue:\"#000000\"},font:{type:ControlType.Font,title:\"Font\",controls:\"extended\",defaultFontType:\"sans-serif\"},textAlign:{type:ControlType.Enum,title:\"Text Align\",options:[\"left\",\"center\",\"right\"],displaySegmentedControl:true},gap:{type:ControlType.Number,title:\"Slot Gap\",defaultValue:4,min:0,max:100,step:1,unit:\"px\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"TextWrap\",\"slots\":[\"children\"],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./TextWrap.map"],"mappings":"A,0KAGG,SAASS,EAAY,EAAM,CAAC,OAAOC,EAAM,QAAQ,sBAAsB,MAAM,CAAE,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