'use client'; import type * as React from 'react'; import { AlertTriangle } from 'lucide-react'; import { cn } from '@djangocfg/ui-core/lib'; import type { RecognitionError } from '../types'; const FRIENDLY: Record = { unsupported: 'Speech recognition isn\'t available in this browser.', 'permission-denied': 'Microphone access was denied. Allow it in your browser settings to dictate.', 'no-microphone': 'No microphone found.', network: 'Network error talking to the speech service.', aborted: 'Recognition was interrupted.', 'no-speech': 'No speech was detected. Try again.', language: 'The requested language isn\'t supported by the engine.', engine: 'The speech engine reported an error.', unknown: 'Something went wrong with the microphone.', }; export interface ErrorBannerProps { error: RecognitionError | null; className?: string; onDismiss?: () => void; } export function ErrorBanner({ error, className, onDismiss }: ErrorBannerProps): React.ReactElement | null { if (!error) return null; return (
{FRIENDLY[error.code] ?? error.message}
{onDismiss && ( )}
); }