import { A as AuthProvider } from './types-D9-B25-T.js'; export { a as AuthToken, C as ChatConfig, H as HwChatOptions } from './types-D9-B25-T.js'; /** * Web Component. * * Owns the Shadow DOM, subscribes to a ChatController for state, and * re-renders on every state change. Event delegation (data-action attrs) * keeps handler plumbing simple — one click / keydown / drag listener * at the root, dispatching by action string. */ declare const BaseElement: typeof HTMLElement; declare class HwChatElement extends BaseElement { /** Programmatic auth provider. The React wrapper assigns this in a * useEffect, which fires AFTER `connectedCallback` already ran `boot()`, * so the setter has to forward late assignments to the live controller — * otherwise the AuthManager keeps the null snapshot it captured at boot * and every signed request goes out unauthenticated (401 from ingress). */ private _authProvider; get authProvider(): AuthProvider | null; set authProvider(provider: AuthProvider | null); private root; private controller; private unsubscribe; private dragCounter; private initialized; private systemDarkMq; private systemDarkListener; private textareaEl; private rootListenersAttached; static get observedAttributes(): string[]; /** Active voice session, if any. Mutually exclusive with text-mode * streaming — the SDK takes over audio capture while it lives. */ private voiceSession; private voiceMode; private postMessageListener; constructor(); connectedCallback(): void; disconnectedCallback(): void; attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void; private readOptions; private boot; /** Dashboard preview iframe refreshes the short-lived preview token every * 25 minutes over postMessage so long sessions don't expire. Same message * contract the dashboard's WidgetPreview component sends. */ private watchParentMessages; private watchSystemTheme; private applyThemeVars; private render; /** Build the persistent textarea once. Listeners attached here survive * every subsequent render because the node itself is never destroyed. */ private createTextarea; private toggleVoice; private startVoice; private endVoice; private setVoiceMode; private renderBootError; private wireEvents; private wireRootListenersOnce; private autoresizeTextarea; private scrollToBottom; } /** Register once. Calling define twice throws, so guard first. */ declare function registerHwChat(): void; /** * Voice session controller — wraps ElevenLabs's Conversational AI client * SDK behind a small interface so the widget code stays SDK-agnostic. * * Why dynamic-import: the SDK ships ~150kB of audio plumbing (WebRTC, * Opus codec) that most chat-widget consumers never touch. We load it * lazily the first time the user clicks the mic button, so the widget's * baseline cold-load stays the size it is today. * * Vapi + Retell SDKs have their own dynamic-import drivers — see the * future vapi.driver.ts / retell.driver.ts. Only ElevenLabs is wired in * Fase 5; the others stub-throw with a clear message until Fase 6. */ type VoiceProvider = 'elevenlabs' | 'vapi' | 'retell'; type VoiceTurn = { role: 'user' | 'agent'; text: string; /** When true the turn is still streaming and may grow on subsequent * callbacks. False once the speaker stops talking. */ final: boolean; }; type VoiceMode = 'idle' | 'connecting' | 'listening' | 'speaking' | 'ended'; interface VoiceSessionHandle { /** End the session and tear down audio capture/playback. Idempotent. */ end(): Promise; } interface VoiceSessionCallbacks { /** Fires for each transcript turn (user or agent). The widget pipes * these into the chat message list so users see what was said. */ onTurn?: (turn: VoiceTurn) => void; /** Fires when the agent's listening/speaking state changes. The * widget uses this to render a "speaking" indicator. */ onMode?: (mode: VoiceMode) => void; /** Fires when the session ends naturally (agent hung up, user * closed the call, audio device disappeared). */ onEnd?: (reason: string) => void; /** Fires for any unrecoverable error during the session. */ onError?: (err: Error) => void; } interface StartVoiceSessionOptions extends VoiceSessionCallbacks { provider: VoiceProvider; /** Provider-side agent id. Required when no signedUrl is provided * (direct mode, ElevenLabs only). Optional when signedUrl is set — * the backend already bound the session to the right agent. */ agentId?: string; /** Pre-signed WebSocket URL minted by HW backend * (`/api/voice-sessions/start`). When set, ElevenLabs uses it as the * bootstrap and forces WebSocket transport — the only way to skip * the LiveKit/WebRTC negotiation that times out against ElevenLabs's * older LiveKit cluster. */ signedUrl?: string; /** * Optional CDN override for the SDK module. esm.sh is the default — * users self-hosting under strict CSP can ship the SDK from their own * origin and pass the URL here. */ sdkUrl?: string; } export { AuthProvider, HwChatElement, type StartVoiceSessionOptions, type VoiceMode, type VoiceProvider, type VoiceSessionHandle, type VoiceTurn, registerHwChat };