"use client"; import { useState, useEffect, useRef } from "react"; const ChatWidget = () => { const [messages, setMessages] = useState([ { id: 1, sender: "System", text: "Welcome to the encrypted channel. All messages are end‑to‑end encrypted.", time: "12:00" }, { id: 2, sender: "Ghost", text: "Has anyone tested the new stimulant batch?", time: "12:05" }, { id: 3, sender: "Vendor_X", text: "Batch #8 passes all purity tests. Available for bulk.", time: "12:07" }, { id: 4, sender: "Anonymous", text: "Need a EU passport within 48 hours. DM if you can deliver.", time: "12:10" }, ]); const [input, setInput] = useState(""); /** Set after mount so SSR HTML matches first client paint (no Math.random in initial state). */ const [encryptionKey, setEncryptionKey] = useState(""); const chatContainerRef = useRef(null); useEffect(() => { setEncryptionKey("session_" + Math.random().toString(36).substring(2, 9)); }, []); useEffect(() => { if (chatContainerRef.current) { chatContainerRef.current.scrollTop = chatContainerRef.current.scrollHeight; } }, [messages]); const handleSend = () => { if (!input.trim()) return; const newMessage = { id: messages.length + 1, sender: "You", text: input, time: new Date().toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" }), }; setMessages([...messages, newMessage]); setInput(""); // Simulate a reply after a delay setTimeout(() => { const replies = [ "Received. Encryption verified.", "I can help with that. Check your vault.", "New drop incoming in 24 hours.", "Your request has been logged.", ]; const randomReply = replies[Math.floor(Math.random() * replies.length)]; const replyMessage = { id: messages.length + 2, sender: "System", text: randomReply, time: new Date().toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" }), }; setMessages(prev => [...prev, replyMessage]); }, 1000); }; const handleEncrypt = () => { alert(`Session key: ${encryptionKey}\nAll messages are encrypted with this key.`); }; return (

ENCRYPTED CHAT

End‑to‑end encrypted messaging. No logs, no traces.

{/* Chat messages */}
{messages.map((msg) => (
{msg.sender} {msg.time}
{msg.text}
))}
{/* Input area */}
setInput(e.target.value)} onKeyDown={(e) => e.key === "Enter" && handleSend()} />
{/* Chat features */}
🔒
AES‑256‑GCM
Encryption
Zero‑Knowledge
No server storage
🌐
WebRTC
P2P possible
🕶️
Self‑Destruct
Messages expire

Ephemeral client-side queue — nothing leaves this browser profile until a real transport is configured.

); }; export default ChatWidget;