import React, { useState, useMemo } from 'react'; import { useAppConfig } from '../contexts/AppConfigContext'; import SecurityChatBotIcon from './icons/SecurityChatBotIcon'; import '../styles/IntakePanel.css'; /** * First-session intake: Jerry's greeting + chips + optional free-text. * Chips come from /api/config → chat_page.intake, filtered by guest persona when set. */ const IntakePanel = ({ onSubmit, guestPersona = null }) => { const { config } = useAppConfig(); const intake = config?.chat_page?.intake || {}; const greeting = intake.greeting || "You've contacted me today — what is it that I can help you with in cybersecurity?"; const chips = useMemo(() => { const byPersona = intake.by_persona || {}; const personaKey = (guestPersona || '').toLowerCase(); const personaChips = personaKey && Array.isArray(byPersona[personaKey]) ? byPersona[personaKey] : null; if (personaChips && personaChips.length > 0) return personaChips; return Array.isArray(intake.chips) ? intake.chips : []; }, [intake, guestPersona]); const [freeText, setFreeText] = useState(''); const [showFreeText, setShowFreeText] = useState(false); const handleChip = (chip) => { if (chip.free_text) { setShowFreeText(true); return; } if (chip.prompt) onSubmit(chip.prompt); }; const handleFreeSubmit = (e) => { e.preventDefault(); const text = freeText.trim(); if (!text) return; onSubmit(text); setFreeText(''); }; return (

{greeting}

Pick a starting point, or tell me in your own words.

{chips.map((chip) => ( ))}
{(showFreeText || chips.length === 0) && (