"use client" import type React from "react" import { useState, useRef, useEffect } from "react" import { Button } from "@/components/ui/button" import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card" import { Input } from "@/components/ui/input" import { Badge } from "@/components/ui/badge" import { MessageCircle, Send, X, Sparkles, Heart } from "lucide-react" import { motion, AnimatePresence } from "framer-motion" interface Message { id: string text: string isUser: boolean timestamp: Date } export default function MostarAIAssistant() { const [isOpen, setIsOpen] = useState(false) const [messages, setMessages] = useState([ { id: "welcome", text: "Sawubona! I am Mostar, your Ubuntu AI guide. I embody the spirit of 'I am because we are.' Ask me about FlameBorn, Ubuntu philosophy, African wisdom, or healthcare tokenization. How can we grow together today?", isUser: false, timestamp: new Date(), }, ]) const [inputValue, setInputValue] = useState("") const [isTyping, setIsTyping] = useState(false) const messagesEndRef = useRef(null) const scrollToBottom = () => { messagesEndRef.current?.scrollIntoView({ behavior: "smooth" }) } useEffect(() => { scrollToBottom() }, [messages]) const ubuntuResponses = [ "In Ubuntu philosophy, we understand that individual wellness flows from community health. Your question touches the heart of our interconnectedness.", "As the Zulu saying goes: 'Umuntu ngumuntu ngabantu' - a person is a person through other persons. This wisdom guides everything we do at FlameBorn.", "The flame of healing burns brightest when we tend it together. In our tokenization model, every reward strengthens the whole network.", "Ubuntu teaches us that when one suffers, we all suffer. When one heals, we all heal. This is why FlameBorn exists - to weave digital bonds that strengthen real healing.", "In traditional African communities, the birth of a child was celebrated by the entire village. FlameBorn brings this spirit to the digital age through our birth registration tokens.", "The ancestors whisper: 'What affects one, affects all.' Our blockchain preserves this wisdom, ensuring that every healthcare action ripples through the community.", "Ubuntu is not just philosophy - it's a way of being. When healthcare workers earn FLB tokens, they're not just being rewarded, they're being recognized as vital threads in our community fabric.", ] const handleSendMessage = async () => { if (!inputValue.trim()) return const userMessage: Message = { id: Date.now().toString(), text: inputValue, isUser: true, timestamp: new Date(), } setMessages((prev) => [...prev, userMessage]) setInputValue("") setIsTyping(true) // Simulate AI response delay setTimeout(() => { const aiResponse: Message = { id: (Date.now() + 1).toString(), text: ubuntuResponses[Math.floor(Math.random() * ubuntuResponses.length)], isUser: false, timestamp: new Date(), } setMessages((prev) => [...prev, aiResponse]) setIsTyping(false) }, 1500) } const handleKeyPress = (e: React.KeyboardEvent) => { if (e.key === "Enter" && !e.shiftKey) { e.preventDefault() handleSendMessage() } } return ( <> {/* Floating Chat Button */} {/* Pulsing indicator */}
{/* Chat Modal */} {isOpen && ( setIsOpen(false)} > e.stopPropagation()} className="w-full max-w-md h-[600px] flex flex-col" >
Mostar AI Ubuntu Guide
{/* Messages */}
{messages.map((message) => (

{message.text}

{message.timestamp.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit", })}

))} {isTyping && (
)}
{/* Input */}
setInputValue(e.target.value)} onKeyPress={handleKeyPress} placeholder="Ask about Ubuntu, FlameBorn, or African wisdom..." className="flex-1" disabled={isTyping} />
)} ) }