import { VerbaChatConfig, WidgetState } from './types.ts'; /** Thrown when an SDK method is called in an invalid lifecycle state. */ export declare class VerbaChatError extends Error { constructor(message: string); } /** * Main class for the Verba Chat Widget. * * ### Lifecycle * ``` * new VerbaChat(config) → .init() → .show() / .hide() → .destroy() * ``` * * ### Floating mode (default) * When no `container` is provided a floating bubble button is created in the * bottom-right corner of the viewport. Clicking the bubble opens/closes the * iframe with a smooth CSS animation. * * ### Inline mode * When `container` is a CSS selector or `HTMLElement`, the iframe is mounted * directly inside that element and the bubble button is omitted. */ export declare class VerbaChat { private readonly config; private state; private isVisible; private isInline; container: HTMLElement | null; iframe: HTMLIFrameElement | null; bubble: HTMLButtonElement | null; private popup; private popupTextEl; private badge; private isPopupGreeting; private greetingTimeoutId; private bubbleConfigFallbackTimeoutId; private resolvedBubbleConfig; private messenger; private readonly cleanupCallbacks; /** * Create a new `VerbaChat` instance. * * @param config - SDK configuration. Only `tagId` is required. * * @throws {VerbaChatError} if `tagId` is empty. */ constructor(config: VerbaChatConfig); /** * Inject the widget into the DOM * * In **floating mode** a chat bubble is rendered in the viewport corner. * In **inline mode** the iframe is mounted directly into the configured container. * * @throws {VerbaChatError} if called more than once or after `destroy()`. */ init(): this; /** * Make the widget visible. * In floating mode this opens the iframe above the bubble. * * @throws {VerbaChatError} if `init()` has not been called. */ show(): this; /** * Hide the widget (does not destroy it — all state is preserved). * * @throws {VerbaChatError} if `init()` has not been called. */ hide(): this; /** * Completely tear down the SDK: * - Removes all DOM elements it created. * - Removes all event listeners. * - Resets state to `'destroyed'`. * * After calling `destroy()` this instance cannot be reused — create a new one. */ destroy(): void; /** Current lifecycle state of this SDK instance. */ get currentState(): WidgetState; private mountInline; private mountFloating; /** * Builds the bubble button, badge, and greeting popup, and wires up their * event listeners. Deferred until the widget config is known — called either * from the `BUBBLE_CONFIG` handler (server-merged config) or the fallback * timeout (local-only config), whichever fires first. Idempotent: a no-op if * the bubble has already been built. */ private buildBubble; /** * Syncs the floating widget's fullscreen state with the current viewport. * No-op in inline mode. Safe to call whenever the widget is visible. */ private applyMobileFullscreenState; /** * Toggles the enlarged iframe panel requested by the widget via * `EXPAND_WIDGET`/`SHRINK_WIDGET` postMessages. No-op in inline mode, * since inline widgets already fill their host container. */ private setExpandedState; /** * Shows the first-time greeting popup, unless it's already been dismissed * (persisted in `localStorage`), the chat is already open, or disabled via * `bubble.greeting.disabled`. No-op in inline mode. */ private maybeShowGreeting; /** * Shows a truncated preview of `message` in the popup, triggered by the * embedded widget via the `SHOW_WIDGET_MESSAGE` postMessage. Only relevant * while the chat is closed — no-op in inline mode or while the chat is open. * Always supersedes (and permanently dismisses) the first-time greeting. */ private showMessagePopup; /** Dismiss button handler — hides the popup and persists the greeting dismissal. */ private dismissPopup; /** Hides the popup (if visible) and persists the greeting dismissal — used when the chat opens. */ private hidePopupAndPersistGreeting; private get greetingStorageKey(); private readGreetingDismissed; private writeGreetingDismissed; private assertState; private assertNotState; private resolveContainer; private buildWidgetUrl; } export type { BubblePosition, PostMessagePayload, Theme, ThemeConfig, VerbaChatConfig, WidgetState, } from './types.ts';