import React, { useContext, useMemo } from 'react';
import { useChatAnywhere, useCustomCardsContext } from '@agentscope-ai/chat';
interface ICardProps {
code: string,
component?: React.FC,
data?: string | any,
index?: number,
id?: string,
isLast?: boolean,
}
const Card = React.memo(function (props: ICardProps) {
const cardConfig = useCustomCardsContext();
const onInput = useChatAnywhere(v => v.onInput);
const Component = useMemo(() => {
if (props.component) return props.component;
const cardConfigMap = cardConfig;
return cardConfigMap?.[props.code] || (() => `${props.code} not found`);
}, [])
if (typeof Component === 'function') {
const { component, ...rest } = props;
return