import { jsx as _jsx } from "react/jsx-runtime";
import { useMemo } from 'react';
import { block } from "../../../utils/cn.js";
import { getMessageRenderer, mergeMessageRendererRegistries, } from "../../../utils/messageTypeRegistry.js";
import { normalizeContent } from "../../../utils/messageUtils.js";
import { BaseMessage } from "../../molecules/BaseMessage/index.js";
import { createDefaultMessageRegistry } from "./defaultMessageTypeRegistry.js";
import "./AssistantMessage.css";
const b = block('assistant-message');
export function AssistantMessage({ content, actions, extraInfo, timestamp, id, messageRendererRegistry, transformOptions, shouldParseIncompleteMarkdown, showActionsOnHover, showTimestamp, userRating, className, qa, onActionPopup, }) {
    const registry = useMemo(() => {
        const defaultRegistry = createDefaultMessageRegistry(transformOptions, shouldParseIncompleteMarkdown);
        if (messageRendererRegistry) {
            return mergeMessageRendererRegistries(defaultRegistry, messageRendererRegistry);
        }
        return defaultRegistry;
    }, [messageRendererRegistry, transformOptions, shouldParseIncompleteMarkdown]);
    const parts = normalizeContent(content);
    if (parts.length === 0) {
        return null;
    }
    const renderPart = (part, partIndex) => {
        const PartComponent = getMessageRenderer(registry, part.type);
        if (!PartComponent) {
            return null;
        }
        const key = part.id || `${id || 'message'}-part-${partIndex}`;
        return _jsx(PartComponent, { part: part }, key);
    };
    return (_jsx(BaseMessage, { role: "assistant", actions: actions, extraInfo: extraInfo, showActionsOnHover: showActionsOnHover, showTimestamp: showTimestamp, timestamp: timestamp, userRating: userRating, className: b(null, className), qa: qa, onActionPopup: onActionPopup, children: _jsx("div", { className: b('content'), children: parts.map((part, index) => renderPart(part, index)) }) }));
}
//# sourceMappingURL=AssistantMessage.js.map
