import React from 'react'; export interface SlateTextNode { text: string; bold?: boolean; italic?: boolean; underline?: boolean; code?: boolean; } export interface SlateElementNode { type?: string; speaker?: string; role?: 'buyer' | 'seller' | 'host' | 'guest' | 'ai' | 'customer'; time?: string; children: (SlateElementNode | SlateTextNode)[]; } interface SlateScriptRendererProps { nodes?: (SlateElementNode | SlateTextNode)[]; primaryColor?: string; className?: string; } export const SlateScriptRenderer: React.FC = ({ nodes, primaryColor = '#18181b', className = '', }) => { if (!nodes || nodes.length === 0) { return null; } const renderTextNode = (node: SlateTextNode, idx: number) => { let content: React.ReactNode = node.text; if (node.bold) content = {content}; if (node.italic) content = {content}; if (node.underline) content = {content}; if (node.code) { content = ( {content} ); } return {content}; }; const renderElement = (node: SlateElementNode, idx: number) => { switch (node.type) { case 'chat-dialog': case 'dialog': case 'negotiation': { const isHost = node.role === 'seller' || node.role === 'host' || node.role === 'ai'; return (
{/* Avatar */}
{node.speaker ? node.speaker.slice(0, 1) : isHost ? '호' : '손'}
{/* Bubble */}
{node.speaker || (isHost ? '호스트' : '게스트')} {node.time && · {node.time}}
{node.children.map((child, cIdx) => 'text' in child ? renderTextNode(child, cIdx) : renderElement(child, cIdx) )}
); } case 'heading-two': case 'h2': return (

{node.children.map((child, cIdx) => 'text' in child ? renderTextNode(child, cIdx) : renderElement(child, cIdx) )}

); case 'quote': case 'blockquote': return (
{node.children.map((child, cIdx) => 'text' in child ? renderTextNode(child, cIdx) : renderElement(child, cIdx) )}
); case 'callout': case 'info-box': return (
{node.children.map((child, cIdx) => 'text' in child ? renderTextNode(child, cIdx) : renderElement(child, cIdx) )}
); default: return (

{node.children.map((child, cIdx) => 'text' in child ? renderTextNode(child, cIdx) : renderElement(child, cIdx) )}

); } }; return (
{nodes.map((node, idx) => 'text' in node ? renderTextNode(node, idx) : renderElement(node, idx) )}
); };