import React, { useState, useRef, useEffect } from 'react'; import { Users, Plus, ChevronDown, Wand2, Check } from 'lucide-react'; /** * Header dropdown that lists every available participant the user can * pull into the conversation. Three sections: * - Neon (HANA personas, vanilla/RAG already filtered server-side) * - Extra (bundled catalog personas, provider + Neon LLMs) * - Expert (user-created, stored in localStorage) * * A top-of-list "Select N Automatically" toggle defers the choice to * the orchestrator LLM: when enabled, manual checkboxes are visually * disabled and the actual picks happen at /chat/start time via the * /api/chat/auto-select-participants endpoint. * * Selecting a participant adds them to the active conversation list. The * "Create Expert Persona..." entry opens the modal. */ export default function ParticipantDropdown({ catalog, expertPersonas, selectedIds, maxParticipants, onToggleParticipant, onOpenExpertModal, autoSelectMode, onToggleAutoSelectMode, }) { const [open, setOpen] = useState(false); const ref = useRef(null); useEffect(() => { function handleClickOutside(e) { if (open && ref.current && !ref.current.contains(e.target)) { setOpen(false); } } document.addEventListener('mousedown', handleClickOutside); return () => document.removeEventListener('mousedown', handleClickOutside); }, [open]); const isSelected = (id) => selectedIds.includes(id); const atCap = selectedIds.length >= maxParticipants; // When auto-select is on, checkboxes are deferred entirely - the // orchestrator picks at start time, so user picks are ignored. const checkboxDisabledForAuto = !!autoSelectMode; const openCreateExpertModal = () => { setOpen(false); onOpenExpertModal(null); }; return (