/** @jsx h */ import { h } from 'preact'; import Template from '../Template/Template'; import type { VoiceSearchCSSClasses, VoiceSearchTemplates, } from '../../widgets/voice-search/voice-search'; import type { VoiceListeningState } from '../../lib/voiceSearchHelper/types'; import type { ComponentCSSClasses } from '../../types'; export type VoiceSearchComponentCSSClasses = ComponentCSSClasses; export type VoiceSearchComponentTemplates = Required; export type VoiceSearchProps = { cssClasses: VoiceSearchComponentCSSClasses; isBrowserSupported: boolean; isListening: boolean; toggleListening: () => void; voiceListeningState: VoiceListeningState; templates: VoiceSearchComponentTemplates; }; const VoiceSearch = ({ cssClasses, isBrowserSupported, isListening, toggleListening, voiceListeningState, templates, }: VoiceSearchProps) => { const handleClick = (event: MouseEvent): void => { if (event.currentTarget instanceof HTMLElement) { event.currentTarget.blur(); } toggleListening(); }; const { status, transcript, isSpeechFinal, errorCode } = voiceListeningState; return (