'use client'; import { useState, useEffect } from 'react'; import { useTranslations } from 'next-intl'; import { Keyboard, Mic } from 'lucide-react'; import { cn } from '@/lib/utils'; // ─── Types ─────────────────────────────────────────────────────────────────── interface ModeToggleProps { mode: 'type' | 'talk'; onChange: (mode: 'type' | 'talk') => void; } // ─── Component ─────────────────────────────────────────────────────────────── export default function ModeToggle({ mode, onChange }: ModeToggleProps) { const t = useTranslations('configurator'); const [voiceSupported, setVoiceSupported] = useState(false); useEffect(() => { async function check() { if (typeof WebSocket === 'undefined') return; if (!navigator.mediaDevices?.getUserMedia) return; try { const res = await fetch('/api/gemini-token'); const data = (await res.json()) as { success: boolean }; if (data.success) setVoiceSupported(true); } catch { // silent — toggle stays hidden } } void check(); }, []); if (!voiceSupported) return null; return (
); }