import { motion } from "motion/react"; import React from "react"; import { TypingText } from "./TypingText"; import { EmojiText } from "../chatbot/EmojiText"; import chatbotAvatarIcon from "../../../assets/chatbot-bot-avatar.png"; import { toPersianDigits } from "../../../utils/persianNumberUtils"; export interface ChatMessage { id: string; type: "user" | "other" | "loading"; content: string; author?: string; timestamp: string; isTyping?: boolean; } interface ChatMessagesProps { messages: ChatMessage[]; containerRef: React.RefObject; endRef: React.RefObject; onTyping?: () => void; } const messageStyles = { user: { background: "linear-gradient(145deg, rgba(218, 94, 142, 0.96) 0%, rgba(162, 56, 110, 0.95) 100%)", boxShadow: "0 0 24px rgba(240,110,168,0.28), 0 12px 28px rgba(84, 22, 60, 0.38), inset 0 1px 0 rgba(255,255,255,0.16)", border: "1px solid rgba(255, 178, 214, 0.58)", backdropFilter: "blur(14px)", WebkitBackdropFilter: "blur(14px)", }, other: { background: "linear-gradient(145deg, rgba(52, 34, 76, 0.94) 0%, rgba(35, 24, 62, 0.94) 100%)", backgroundImage: "linear-gradient(145deg, rgba(52, 34, 76, 0.94) 0%, rgba(35, 24, 62, 0.94) 100%), linear-gradient(120deg, #7c3aed 0%, #f97316 58%, #facc15 100%)", backgroundOrigin: "border-box", backgroundClip: "padding-box, border-box", boxShadow: "0 0 24px rgba(152,104,235,0.24), 0 12px 28px rgba(12, 8, 30, 0.4), inset 0 1px 0 rgba(255,255,255,0.12)", border: "0.5px solid transparent", backdropFilter: "blur(14px)", WebkitBackdropFilter: "blur(14px)", }, }; export function ChatMessages({ messages, containerRef, endRef, onTyping, }: ChatMessagesProps) { return (
{messages.map((message) => { const isUser = message.type === "user"; const isLoading = message.type === "loading"; return (
{message.author && (

{message.author}

)} {isLoading ? (
) : message.type === "other" && message.isTyping ? ( ) : (

)}

{toPersianDigits(message.timestamp)}

{!isUser && (
چت‌بات
)}
); })}
); }