{"version":3,"file":"HtmlRenderer.DVU3o93o.mjs","names":["React.useRef","React.useState"],"sources":["https:/framerusercontent.com/modules/kEOVSZw3a6qpKw9oGx3k/tZGr82yGjaK4JzshKMYj/HtmlRenderer.js"],"sourcesContent":["// TextSlotsHtmlRenderer.tsx\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import*as React from\"react\";import{addPropertyControls,ControlType}from\"framer\";const emptySlotClasses={h1:{},h2:{},h3:{},h4:{},h5:{},h6:{},paragraph:{}};/**\n * @framerSupportedLayoutWidth auto\n * @framerSupportedLayoutHeight auto\n */export default function TextSlots(props){const{html=\"\",h1,h2,h3,h4,h5,h6,paragraph,gap=16,style}=props;// Refs for off-screen style sampling containers\nconst h1Ref=React.useRef(null);const h2Ref=React.useRef(null);const h3Ref=React.useRef(null);const h4Ref=React.useRef(null);const h5Ref=React.useRef(null);const h6Ref=React.useRef(null);const pRef=React.useRef(null);const[slotClasses,setSlotClasses]=React.useState(emptySlotClasses);const[renderedNodes,setRenderedNodes]=React.useState([]);// Find the \"leaf\" heading/paragraph inside a slot instance\nconst findLeafTextElement=root=>{if(!root)return null;return root.querySelector(\"h1, h2, h3, h4, h5, h6, p\");};const toCamelCase=prop=>{// font-size -> fontSize, background-color -> backgroundColor, etc.\nreturn prop.replace(/-([a-z])/g,(_,char)=>char.toUpperCase());};const extractInlineStyle=leaf=>{const styleDecl=leaf.style;const inlineStyle={};for(let i=0;i<styleDecl.length;i++){const cssName=styleDecl[i]// e.g. \"font-size\" or \"--framer-font-size\"\n;const value=styleDecl.getPropertyValue(cssName);if(!value)continue;if(cssName.startsWith(\"--\")){// CSS variables – React supports them as-is\ninlineStyle[cssName]=value;}else{const camel=toCamelCase(cssName);inlineStyle[camel]=value;}}return inlineStyle;};const extractSlotInfo=container=>{const leaf=findLeafTextElement(container);if(!leaf)return{};const info={className:leaf.className||undefined,dataStylesPreset:leaf.getAttribute(\"data-styles-preset\")||undefined};const inlineStyle=extractInlineStyle(leaf);if(Object.keys(inlineStyle).length>0){info.inlineStyle=inlineStyle;}return info;};// 1) Read className + data-styles-preset + inline style from off-screen slot instances\nReact.useLayoutEffect(()=>{const newClasses={h1:extractSlotInfo(h1Ref.current),h2:extractSlotInfo(h2Ref.current),h3:extractSlotInfo(h3Ref.current),h4:extractSlotInfo(h4Ref.current),h5:extractSlotInfo(h5Ref.current),h6:extractSlotInfo(h6Ref.current),paragraph:extractSlotInfo(pRef.current)};setSlotClasses(newClasses);},[h1,h2,h3,h4,h5,h6,paragraph]);// 2) Parse HTML + map tags -> appropriate slot classes\nReact.useEffect(()=>{if(!html||typeof window===\"undefined\"){setRenderedNodes([]);return;}const parser=new DOMParser;const doc=parser.parseFromString(html,\"text/html\");const body=doc.body;const result=[];Array.from(body.childNodes).forEach((node,index)=>{const rendered=renderNode(node,`root-${index}`,slotClasses);if(rendered!==null&&rendered!==undefined){result.push(rendered);}});setRenderedNodes(result);},[html,slotClasses]);return /*#__PURE__*/_jsxs(\"div\",{style:{...style,position:\"relative\",width:\"100%\",height:\"100%\"},children:[/*#__PURE__*/_jsxs(\"div\",{style:{position:\"absolute\",left:\"-9999px\",top:\"-9999px\",visibility:\"hidden\",pointerEvents:\"none\"},children:[/*#__PURE__*/_jsx(\"div\",{ref:h1Ref,children:h1}),/*#__PURE__*/_jsx(\"div\",{ref:h2Ref,children:h2}),/*#__PURE__*/_jsx(\"div\",{ref:h3Ref,children:h3}),/*#__PURE__*/_jsx(\"div\",{ref:h4Ref,children:h4}),/*#__PURE__*/_jsx(\"div\",{ref:h5Ref,children:h5}),/*#__PURE__*/_jsx(\"div\",{ref:h6Ref,children:h6}),/*#__PURE__*/_jsx(\"div\",{ref:pRef,children:paragraph})]}),/*#__PURE__*/_jsx(\"div\",{style:{display:\"flex\",flexDirection:\"column\",gap:`${gap}px`,width:\"100%\",height:\"100%\"},children:renderedNodes.length===0?/*#__PURE__*/_jsx(\"div\",{style:{padding:16,color:\"#999\",fontSize:14,fontFamily:\"sans-serif\"},children:\"Add styled text components to the slots and provide HTML to render.\"}):renderedNodes.map((node,idx)=>/*#__PURE__*/_jsx(\"div\",{children:node},idx))})]});}// --- HTML → React mapping using slot classes + inline styles ---\nfunction renderNode(node,key,classes){// Text node\nif(node.nodeType===Node.TEXT_NODE){const text=node.textContent;if(!text||text.trim()===\"\")return null;return text;}if(!(node instanceof HTMLElement))return null;const tag=node.tagName.toLowerCase();// Skip scripts / styles for safety\nif(tag===\"script\"||tag===\"style\")return null;const children=Array.from(node.childNodes).map((child,index)=>renderNode(child,`${key}-${index}`,classes));const applySlotProps=slot=>({className:slot.className,\"data-styles-preset\":slot.dataStylesPreset,style:slot.inlineStyle});switch(tag){case\"h1\":return /*#__PURE__*/_jsx(\"h1\",{...applySlotProps(classes.h1),children:children},key);case\"h2\":return /*#__PURE__*/_jsx(\"h2\",{...applySlotProps(classes.h2),children:children},key);case\"h3\":return /*#__PURE__*/_jsx(\"h3\",{...applySlotProps(classes.h3),children:children},key);case\"h4\":return /*#__PURE__*/_jsx(\"h4\",{...applySlotProps(classes.h4),children:children},key);case\"h5\":return /*#__PURE__*/_jsx(\"h5\",{...applySlotProps(classes.h5),children:children},key);case\"h6\":return /*#__PURE__*/_jsx(\"h6\",{...applySlotProps(classes.h6),children:children},key);case\"p\":return /*#__PURE__*/_jsx(\"p\",{...applySlotProps(classes.paragraph),children:children},key);case\"strong\":case\"b\":return /*#__PURE__*/_jsx(\"strong\",{children:children},key);case\"em\":case\"i\":return /*#__PURE__*/_jsx(\"em\",{children:children},key);case\"a\":return /*#__PURE__*/_jsx(\"a\",{href:node.getAttribute(\"href\")||\"#\",target:\"_blank\",rel:\"noreferrer\",children:children},key);case\"br\":return /*#__PURE__*/_jsx(\"br\",{},key);case\"ul\":return /*#__PURE__*/_jsx(\"ul\",{children:children},key);case\"ol\":return /*#__PURE__*/_jsx(\"ol\",{children:children},key);case\"li\":return /*#__PURE__*/_jsx(\"li\",{children:/*#__PURE__*/_jsx(\"span\",{...applySlotProps(classes.paragraph),children:children})},key);case\"div\":case\"span\":return /*#__PURE__*/_jsx(\"span\",{children:children},key);default:return /*#__PURE__*/_jsx(\"span\",{children:children},key);}}// --- Property controls ---\naddPropertyControls(TextSlots,{html:{type:ControlType.String,title:\"HTML\",displayTextArea:true},h1:{type:ControlType.ComponentInstance,title:\"H1\"},h2:{type:ControlType.ComponentInstance,title:\"H2\"},h3:{type:ControlType.ComponentInstance,title:\"H3\"},h4:{type:ControlType.ComponentInstance,title:\"H4\"},h5:{type:ControlType.ComponentInstance,title:\"H5\"},h6:{type:ControlType.ComponentInstance,title:\"H6\"},paragraph:{type:ControlType.ComponentInstance,title:\"Paragraph\"},gap:{type:ControlType.Number,title:\"Gap\",defaultValue:16,min:0,max:100,step:1,unit:\"px\"}});TextSlots.defaultProps={html:\"\",gap:16};\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"TextSlots\",\"slots\":[\"h1\",\"h2\",\"h3\",\"h4\",\"h5\",\"h6\",\"paragraph\"],\"annotations\":{\"framerSupportedLayoutWidth\":\"auto\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"auto\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./HtmlRenderer.map"],"mappings":"0MAIG,SAAwB,EAAU,EAAM,CAAC,GAAK,CAAC,OAAK,GAAG,KAAG,KAAG,KAAG,KAAG,KAAG,KAAG,YAAU,MAAI,GAAG,SAAO,EAC9F,EAAMA,EAAa,IAAI,EAAQ,EAAMA,EAAa,IAAI,EAAQ,EAAMA,EAAa,IAAI,EAAQ,EAAMA,EAAa,IAAI,EAAQ,EAAMA,EAAa,IAAI,EAAQ,EAAMA,EAAa,IAAI,EAAQ,EAAKA,EAAa,IAAI,EAAO,CAAC,EAAY,GAAgBC,EAAe,CAAgB,EAAO,CAAC,EAAc,GAAkBA,EAAe,CAAC,CAAC,EAC5U,EAAoB,GAAW,EAAwB,EAAK,cAAc,2BAA2B,EAA1D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