{"version":3,"file":"LaTeXText.Cq8Ve7tk.mjs","names":["useRef","useState","useMemo"],"sources":["https:/framerusercontent.com/modules/GKFywvo9CQO2RgvgpK7s/czOu1jNYA5Kear6VHC9H/LaTeXText.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect,useRef,useState,useMemo}from\"react\";import{addPropertyControls,ControlType}from\"framer\";/**\n * LaTeX Text Component\n * \n * Renders text with LaTeX mathematical expressions.\n * Use $...$ for inline math and $$...$$ for display math.\n * \n * @framerIntrinsicWidth 300\n * @framerIntrinsicHeight 100\n * \n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight auto\n */export default function LaTeXText(props){const{text=\"This is inline math: $E = mc^2$ and display math: $$\\\\int_{-\\\\infty}^{\\\\infty} e^{-x^2} dx = \\\\sqrt{\\\\pi}$$\",font,textColor=\"#000000\",backgroundColor=\"transparent\",padding=\"16px\",borderRadius=\"8px\",katexColor=\"#000000\",displayMode=\"inline\"}=props;const containerRef=useRef(null);const[katexLoaded,setKatexLoaded]=useState(false);const[renderedHtml,setRenderedHtml]=useState(\"\");// Load KaTeX CSS and JS\nuseEffect(()=>{if(typeof window===\"undefined\")return;// Check if KaTeX is already loaded\nif(window.katex){setKatexLoaded(true);return;}// Load KaTeX CSS\nif(!document.getElementById(\"katex-css\")){const link=document.createElement(\"link\");link.id=\"katex-css\";link.rel=\"stylesheet\";link.href=\"https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/katex.min.css\";document.head.appendChild(link);}// Load KaTeX JS\nconst script=document.createElement(\"script\");script.src=\"https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/katex.min.js\";script.async=true;script.onload=()=>setKatexLoaded(true);document.head.appendChild(script);return()=>{// Cleanup script if needed\n};},[]);// Process text and render LaTeX\nuseEffect(()=>{if(!katexLoaded||!window.katex)return;const processText=()=>{// Split text by LaTeX delimiters\n// Match $$...$$ for display math and $...$ for inline math\nconst parts=text.split(/(\\$\\$[\\s\\S]*?\\$\\$|\\$[^\\$\\n]*?\\$)/g);let html=\"\";parts.forEach((part,index)=>{if(part.startsWith(\"$$\")&&part.endsWith(\"$$\")){// Display math\nconst latex=part.slice(2,-2).trim();try{const rendered=window.katex.renderToString(latex,{displayMode:true,throwOnError:false,color:katexColor});html+=`<div style=\"margin: 1em 0;\">${rendered}</div>`;}catch(e){html+=`<span style=\"color: red;\">${part}</span>`;}}else if(part.startsWith(\"$\")&&part.endsWith(\"$\")){// Inline math\nconst latex=part.slice(1,-1).trim();try{const rendered=window.katex.renderToString(latex,{displayMode:false,throwOnError:false,color:katexColor});html+=rendered;}catch(e){html+=`<span style=\"color: red;\">${part}</span>`;}}else{// Regular text - escape HTML\nhtml+=part.replace(/&/g,\"&amp;\").replace(/</g,\"&lt;\").replace(/>/g,\"&gt;\").replace(/\\n/g,\"<br/>\");}});setRenderedHtml(html);};processText();},[text,katexLoaded,katexColor]);const containerStyle=useMemo(()=>({width:\"100%\",minHeight:\"100%\",padding,backgroundColor,borderRadius,color:textColor,fontSize:font?.fontSize||\"16px\",fontFamily:font?.fontFamily||\"system-ui, -apple-system, sans-serif\",fontWeight:font?.fontWeight||400,fontStyle:font?.fontStyle||\"normal\",letterSpacing:font?.letterSpacing||\"normal\",lineHeight:font?.lineHeight||\"1.6\",textAlign:font?.textAlign||\"left\",wordWrap:\"break-word\",overflowWrap:\"break-word\"}),[padding,backgroundColor,borderRadius,textColor,font]);return /*#__PURE__*/_jsx(\"div\",{ref:containerRef,style:containerStyle,dangerouslySetInnerHTML:{__html:renderedHtml}});}addPropertyControls(LaTeXText,{text:{type:ControlType.String,title:\"Text with LaTeX\",defaultValue:\"This is inline math: $E = mc^2$ and display math: $$\\\\int_{-\\\\infty}^{\\\\infty} e^{-x^2} dx = \\\\sqrt{\\\\pi}$$\",displayTextArea:true},font:{type:ControlType.Font,title:\"Text Font\",defaultValue:{fontSize:\"16px\",variant:\"Regular\",letterSpacing:\"0em\",lineHeight:\"1.6em\",textAlign:\"left\"},controls:\"extended\",defaultFontType:\"sans-serif\"},textColor:{type:ControlType.Color,title:\"Text Color\",defaultValue:\"#000000\"},katexColor:{type:ControlType.Color,title:\"Math Color\",defaultValue:\"#000000\"},backgroundColor:{type:ControlType.Color,title:\"Background\",defaultValue:\"transparent\"},padding:{type:ControlType.Padding,title:\"Padding\",defaultValue:\"16px\"},borderRadius:{type:ControlType.BorderRadius,title:\"Border Radius\",defaultValue:\"8px\"}});LaTeXText.displayName=\"LaTeX Text\";\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"LaTeXText\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutHeight\":\"auto\",\"framerIntrinsicHeight\":\"100\",\"framerIntrinsicWidth\":\"300\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./LaTeXText.map"],"mappings":"6MAWG,SAAwB,EAAU,EAAM,CAAC,GAAK,CAAC,OAAK,8GAA8G,OAAK,YAAU,UAAU,kBAAgB,cAAc,UAAQ,OAAO,eAAa,MAAM,aAAW,UAAU,cAAY,UAAU,EAAY,EAAaA,EAAO,KAAK,CAAM,CAAC,EAAY,GAAgBC,EAAS,GAAM,CAAM,CAAC,EAAa,GAAiBA,EAAS,GAAG,CAWqP,OAVtqB,MAAc,CAAC,GAAU,IAAS,OAAY,OAC9C,GAAG,EAAO,MAAM,CAAC,EAAe,GAAK,CAAC,OACtC,GAAG,CAAC,SAAS,eAAe,YAAY,CAAC,CAAC,IAAM,EAAK,SAAS,cAAc,OAAO,CAAC,EAAK,GAAG,YAAY,EAAK,IAAI,aAAa,EAAK,KAAK,+DAA+D,SAAS,KAAK,YAAY,EAAK,CACtO,IAAM,EAAO,SAAS,cAAc,SAAS,CAAqK,MAApK,GAAO,IAAI,8DAA8D,EAAO,MAAM,GAAK,EAAO,WAAW,EAAe,GAAK,CAAC,SAAS,KAAK,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