'use client'; import { Box, Link as MuiLink, Typography, Paper, useTheme } from '@mui/material'; import ReactMarkdown from 'react-markdown'; import remarkGfm from 'remark-gfm'; interface MarkdownMessageProps { content: string; inverse?: boolean; } export default function MarkdownMessage({ content, inverse }: MarkdownMessageProps) { const theme = useTheme(); const codeBg = inverse ? 'rgba(255,255,255,0.18)' : theme.palette.mode === 'light' ? '#F3F4F6' : 'rgba(255,255,255,0.06)'; const codeColor = inverse ? 'white' : theme.palette.text.primary; const borderColor = inverse ? 'rgba(255,255,255,0.25)' : theme.palette.divider; const linkColor = inverse ? 'rgba(255,255,255,0.95)' : theme.palette.primary.main; return ( *:first-of-type': { mt: 0 }, '& > *:last-of-type': { mb: 0 }, }} > ( {children} ), h2: ({ children }) => ( {children} ), h3: ({ children }) => ( {children} ), h4: ({ children }) => ( {children} ), p: ({ children }) => ( {children} ), strong: ({ children }) => ( {children} ), em: ({ children }) => ( {children} ), ul: ({ children }) => ( {children} ), ol: ({ children }) => ( {children} ), li: ({ children }) => {children}, blockquote: ({ children }) => ( {children} ), a: ({ href, children }) => ( {children} ), code: ({ inline, children }: any) => { if (inline) { return ( {children} ); } return ( {children} ); }, hr: () => ( ), table: ({ children }) => ( {children} ), thead: ({ children }) => ( {children} ), th: ({ children }) => ( {children} ), td: ({ children }) => ( {children} ), }} > {content} ); }