'use client' import { useCallback, useState } from 'react' import { Check, Loader2, Mail, Maximize2, MessagesSquare, Minimize2, Send, Square, X } from 'lucide-react' import { EXAMPLE_QUESTIONS } from './advisor/EmptyState' import { EvidenceWorkspace } from './advisor/EvidenceWorkspace' import { useAdvisorStream } from './advisor/useAdvisorStream' import { useAdvisorEmail } from './advisor/useAdvisorEmail' interface ComplianceAdvisorWidgetProps { currentStep?: string } type Country = 'DE' | 'AT' | 'CH' | 'EU' const COUNTRIES: Country[] = ['DE', 'AT', 'CH', 'EU'] /** * Compliance Advisor — Evidence Workspace as a floating widget on every SDK page. * Renders ONLY structured evidence from the SDK (answer + sources + figures + footnotes); * it never parses the answer text. See memory: advisor-evidence-workspace-no-parse. */ export function ComplianceAdvisorWidget({ currentStep = 'default' }: ComplianceAdvisorWidgetProps) { const [isOpen, setIsOpen] = useState(false) const [isExpanded, setIsExpanded] = useState(false) const [inputValue, setInputValue] = useState('') const [country, setCountry] = useState('DE') const { turns, isStreaming, send, stop } = useAdvisorStream({ currentStep, country }) const email = useAdvisorEmail(turns, country, currentStep) const exampleQuestions = EXAMPLE_QUESTIONS[currentStep] || EXAMPLE_QUESTIONS.default const submit = useCallback( (q: string) => { if (!q.trim() || isStreaming) return setInputValue('') void send(q) }, [isStreaming, send], ) const onKeyDown = (e: React.KeyboardEvent) => { if (e.key === 'Enter' && !e.shiftKey) { e.preventDefault() submit(inputValue) } } if (!isOpen) { return ( ) } return (
{/* Header */}
Compliance Advisor
{COUNTRIES.map((c) => ( ))}
{turns.length > 0 && ( )}
{/* Evidence Workspace */} {/* Input */}
setInputValue(e.target.value)} onKeyDown={onKeyDown} placeholder="Frage eingeben..." disabled={isStreaming} className="flex-1 rounded-lg border border-gray-300 px-3 py-2 text-sm focus:border-transparent focus:outline-none focus:ring-2 focus:ring-purple-500 disabled:opacity-50" /> {isStreaming ? ( ) : ( )}
) }