@wabbit-dashboard/embed 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,926 @@
1
+ /**
2
+ * Type definitions for Wabbit Embed SDK
3
+ */
4
+ /**
5
+ * Chat widget configuration
6
+ *
7
+ * Note: apiKey and apiUrl are inherited from WabbitConfig
8
+ * They can be overridden here if needed for chat-specific configuration
9
+ */
10
+ interface ChatConfig {
11
+ enabled: boolean;
12
+ collectionId: string;
13
+ apiKey?: string;
14
+ apiUrl?: string;
15
+ wsUrl?: string;
16
+ position?: 'bottom-right' | 'bottom-left';
17
+ triggerType?: 'button' | 'auto' | 'scroll';
18
+ triggerDelay?: number;
19
+ theme?: 'auto' | 'light' | 'dark';
20
+ primaryColor?: string;
21
+ welcomeMessage?: string;
22
+ placeholder?: string;
23
+ }
24
+ /**
25
+ * Form field types
26
+ */
27
+ type FormFieldType = 'text' | 'email' | 'number' | 'textarea' | 'select' | 'radio' | 'checkbox' | 'rating';
28
+ /**
29
+ * Form field definition
30
+ */
31
+ interface FormField {
32
+ id: string;
33
+ type: FormFieldType;
34
+ label: string;
35
+ placeholder?: string;
36
+ required: boolean;
37
+ options?: string[];
38
+ max?: number;
39
+ }
40
+ /**
41
+ * Form settings
42
+ */
43
+ interface FormSettings {
44
+ successMessage?: string;
45
+ }
46
+ /**
47
+ * Form definition from API
48
+ */
49
+ interface FormDefinition {
50
+ formId: string;
51
+ name?: string;
52
+ fields: FormField[];
53
+ settings: FormSettings;
54
+ }
55
+ /**
56
+ * Form submission response
57
+ */
58
+ interface FormSubmissionResponse {
59
+ success: boolean;
60
+ message?: string;
61
+ error?: string;
62
+ submissionId?: string;
63
+ }
64
+ /**
65
+ * Form widget configuration
66
+ *
67
+ * Note: apiKey and apiUrl are inherited from WabbitConfig
68
+ * They can be overridden here if needed for form-specific configuration
69
+ */
70
+ interface FormConfig {
71
+ enabled: boolean;
72
+ containerId?: string;
73
+ formId: string;
74
+ apiKey?: string;
75
+ apiUrl?: string;
76
+ theme?: 'auto' | 'light' | 'dark';
77
+ primaryColor?: string;
78
+ onSubmit?: (data: Record<string, any>, submissionId?: string) => void;
79
+ onError?: (error: Error) => void;
80
+ onLoad?: () => void;
81
+ }
82
+ /**
83
+ * Email capture configuration
84
+ */
85
+ interface EmailCaptureConfig {
86
+ enabled: boolean;
87
+ triggerAfterMessages?: number;
88
+ title?: string;
89
+ description?: string;
90
+ fields?: ('email' | 'name' | 'company')[];
91
+ onCapture?: (data: Record<string, string>) => void;
92
+ }
93
+ /**
94
+ * Global SDK configuration
95
+ */
96
+ interface WabbitConfig {
97
+ apiKey: string;
98
+ apiUrl?: string;
99
+ wsUrl?: string;
100
+ chat?: ChatConfig;
101
+ forms?: FormConfig;
102
+ emailCapture?: EmailCaptureConfig;
103
+ onReady?: () => void;
104
+ onError?: (error: Error) => void;
105
+ }
106
+
107
+ /**
108
+ * Main Wabbit SDK class
109
+ *
110
+ * This is the main entry point for initializing and managing
111
+ * all Wabbit widgets (chat, forms, email capture).
112
+ */
113
+
114
+ /**
115
+ * Wabbit SDK main class
116
+ */
117
+ declare class Wabbit {
118
+ private static instance;
119
+ private config;
120
+ private constructor();
121
+ /**
122
+ * Initialize the Wabbit SDK
123
+ *
124
+ * @param config - SDK configuration
125
+ * @returns Wabbit instance
126
+ *
127
+ * @example
128
+ * ```typescript
129
+ * const wabbit = Wabbit.init({
130
+ * apiKey: 'pk_live_xxx',
131
+ * chat: { enabled: true, collectionId: 'abc123' }
132
+ * });
133
+ * ```
134
+ */
135
+ static init(config: WabbitConfig): Wabbit;
136
+ /**
137
+ * Get the current Wabbit instance
138
+ *
139
+ * @returns Wabbit instance or null if not initialized
140
+ */
141
+ static getInstance(): Wabbit | null;
142
+ /**
143
+ * Destroy the SDK instance and cleanup
144
+ */
145
+ static destroy(): void;
146
+ /**
147
+ * Get current configuration
148
+ */
149
+ getConfig(): WabbitConfig;
150
+ private chatWidget;
151
+ private formsWidget;
152
+ private emailCaptureWidget;
153
+ /**
154
+ * Get chat widget instance
155
+ */
156
+ get chat(): any;
157
+ /**
158
+ * Get forms widget instance
159
+ */
160
+ get forms(): any;
161
+ /**
162
+ * Get email capture widget instance
163
+ */
164
+ get emailCapture(): any;
165
+ /**
166
+ * Initialize legacy forms (backward compatibility)
167
+ *
168
+ * Automatically initializes forms with data-wabbit-form-id attribute
169
+ * This maintains compatibility with the old embed-form.js script
170
+ */
171
+ private initLegacyForms;
172
+ /**
173
+ * Initialize legacy forms when DOM is ready
174
+ */
175
+ private initLegacyFormsOnReady;
176
+ /**
177
+ * Setup observer for dynamically added legacy forms
178
+ */
179
+ private setupLegacyFormObserver;
180
+ }
181
+
182
+ /**
183
+ * Chat Widget - Main class that integrates all chat components
184
+ */
185
+
186
+ declare class ChatWidget {
187
+ private config;
188
+ private wsClient;
189
+ private bubble;
190
+ private panel;
191
+ private isOpen;
192
+ private cleanup;
193
+ private themeCleanup;
194
+ constructor(config: ChatConfig);
195
+ /**
196
+ * Initialize the chat widget
197
+ */
198
+ init(): Promise<void>;
199
+ /**
200
+ * Setup WebSocket event handlers
201
+ */
202
+ private setupWebSocketHandlers;
203
+ /**
204
+ * Handle trigger type configuration
205
+ */
206
+ private handleTriggerType;
207
+ /**
208
+ * Get WebSocket URL
209
+ */
210
+ private getWebSocketUrl;
211
+ /**
212
+ * Handle send message
213
+ * Made public so EmailCaptureWidget can hook into it
214
+ */
215
+ handleSendMessage(content: string): void;
216
+ /**
217
+ * Open the chat panel
218
+ */
219
+ open(): void;
220
+ /**
221
+ * Close the chat panel
222
+ */
223
+ close(): void;
224
+ /**
225
+ * Toggle chat panel
226
+ */
227
+ toggle(): void;
228
+ /**
229
+ * Send a message programmatically
230
+ */
231
+ sendMessage(content: string): void;
232
+ /**
233
+ * Setup theme watcher for 'auto' theme mode
234
+ */
235
+ private setupThemeWatcher;
236
+ /**
237
+ * Destroy the widget and cleanup
238
+ */
239
+ destroy(): void;
240
+ }
241
+
242
+ /**
243
+ * WebSocket client for chat functionality
244
+ *
245
+ * Based on demo-website/src/lib/websocket.ts but without React dependencies
246
+ */
247
+ type ConnectionStatus = 'disconnected' | 'connecting' | 'connected' | 'reconnecting';
248
+ interface Message {
249
+ id: string;
250
+ role: 'user' | 'assistant' | 'system';
251
+ content: string;
252
+ timestamp: Date;
253
+ metadata?: any;
254
+ }
255
+ declare class ChatWebSocketClient {
256
+ private ws;
257
+ private apiKey;
258
+ private sessionId;
259
+ private status;
260
+ private reconnectAttempts;
261
+ private maxReconnectAttempts;
262
+ private reconnectDelay;
263
+ private wsUrl;
264
+ onStatusChange: ((status: ConnectionStatus) => void) | null;
265
+ onWelcome: ((sessionId: string, collectionId: string, message: string) => void) | null;
266
+ onMessage: ((message: Message) => void) | null;
267
+ onMessageHistory: ((messages: Message[]) => void) | null;
268
+ onError: ((error: string) => void) | null;
269
+ onDisconnect: (() => void) | null;
270
+ constructor(apiKey: string, wsUrl: string, sessionId?: string | null);
271
+ private setStatus;
272
+ getStatus(): ConnectionStatus;
273
+ connect(): Promise<void>;
274
+ private handleMessage;
275
+ sendMessage(content: string, metadata?: any): void;
276
+ disconnect(): void;
277
+ private attemptReconnect;
278
+ clearSession(): void;
279
+ getStoredSessionId(): string | null;
280
+ }
281
+
282
+ /**
283
+ * Chat Bubble - Floating button component
284
+ */
285
+ type ChatBubblePosition = 'bottom-right' | 'bottom-left';
286
+ interface ChatBubbleOptions {
287
+ position: ChatBubblePosition;
288
+ onClick: () => void;
289
+ }
290
+ declare class ChatBubble {
291
+ private element;
292
+ private options;
293
+ constructor(options: ChatBubbleOptions);
294
+ /**
295
+ * Create and render the bubble
296
+ */
297
+ render(): HTMLElement;
298
+ /**
299
+ * Show the bubble
300
+ */
301
+ show(): void;
302
+ /**
303
+ * Hide the bubble
304
+ */
305
+ hide(): void;
306
+ /**
307
+ * Remove the bubble from DOM
308
+ */
309
+ destroy(): void;
310
+ }
311
+
312
+ /**
313
+ * Chat Panel - Expandable chat window component
314
+ */
315
+
316
+ type ChatPanelPosition = 'bottom-right' | 'bottom-left';
317
+ interface ChatPanelOptions {
318
+ position: ChatPanelPosition;
319
+ welcomeMessage?: string;
320
+ placeholder?: string;
321
+ onSendMessage: (content: string) => void;
322
+ onClose: () => void;
323
+ disabled?: boolean;
324
+ }
325
+ declare class ChatPanel {
326
+ private element;
327
+ private messagesContainer;
328
+ private inputElement;
329
+ private sendButton;
330
+ private options;
331
+ private messages;
332
+ private isWaitingForResponse;
333
+ constructor(options: ChatPanelOptions);
334
+ /**
335
+ * Create and render the panel
336
+ */
337
+ render(): HTMLElement;
338
+ /**
339
+ * Add a message to the panel
340
+ */
341
+ addMessage(message: Message): void;
342
+ /**
343
+ * Add multiple messages
344
+ */
345
+ setMessages(messages: Message[]): void;
346
+ /**
347
+ * Add system message
348
+ */
349
+ addSystemMessage(content: string): void;
350
+ /**
351
+ * Set waiting for response state
352
+ */
353
+ setWaitingForResponse(waiting: boolean): void;
354
+ /**
355
+ * Set disabled state
356
+ */
357
+ setDisabled(disabled: boolean): void;
358
+ /**
359
+ * Render a single message
360
+ */
361
+ private renderMessage;
362
+ /**
363
+ * Format message content (simple markdown-like)
364
+ */
365
+ private formatMessage;
366
+ /**
367
+ * Handle send message
368
+ */
369
+ private handleSend;
370
+ /**
371
+ * Update send button state
372
+ */
373
+ private updateSendButtonState;
374
+ /**
375
+ * Scroll to bottom of messages
376
+ */
377
+ private scrollToBottom;
378
+ /**
379
+ * Show the panel
380
+ */
381
+ show(): void;
382
+ /**
383
+ * Hide the panel
384
+ */
385
+ hide(): void;
386
+ /**
387
+ * Remove the panel from DOM
388
+ */
389
+ destroy(): void;
390
+ }
391
+
392
+ /**
393
+ * Form Widget
394
+ *
395
+ * Main class for managing form widgets
396
+ */
397
+
398
+ /**
399
+ * Form Widget class
400
+ */
401
+ declare class FormWidget {
402
+ private config;
403
+ private container;
404
+ private formElement;
405
+ private styles;
406
+ private renderer;
407
+ private apiClient;
408
+ private currentTheme;
409
+ private themeCleanup;
410
+ private formObserver;
411
+ constructor(config: FormConfig);
412
+ /**
413
+ * Initialize the form widget
414
+ */
415
+ init(): void;
416
+ /**
417
+ * Load and render form
418
+ */
419
+ private loadForm;
420
+ /**
421
+ * Find container element
422
+ */
423
+ private findContainer;
424
+ /**
425
+ * Attach form submit handler
426
+ */
427
+ private attachSubmitHandler;
428
+ /**
429
+ * Setup rating field interactions
430
+ */
431
+ private setupRatingInteractions;
432
+ /**
433
+ * Update rating star colors
434
+ */
435
+ private updateRatingStars;
436
+ /**
437
+ * Handle form submission
438
+ */
439
+ private handleSubmit;
440
+ /**
441
+ * Format error message to be user-friendly
442
+ * Removes HTTP status codes and technical details
443
+ */
444
+ private formatErrorMessage;
445
+ /**
446
+ * Show success message
447
+ */
448
+ private showSuccess;
449
+ /**
450
+ * Show error message
451
+ */
452
+ private showError;
453
+ /**
454
+ * Setup theme watcher
455
+ */
456
+ private setupThemeWatcher;
457
+ /**
458
+ * Update form theme
459
+ */
460
+ private updateFormTheme;
461
+ /**
462
+ * Calculate hover color (darker by 10%)
463
+ */
464
+ private calculateHoverColor;
465
+ /**
466
+ * Get API URL from script tag (for backward compatibility)
467
+ */
468
+ private getApiUrlFromScript;
469
+ /**
470
+ * Destroy the form widget
471
+ */
472
+ destroy(): void;
473
+ }
474
+
475
+ /**
476
+ * Theme detection utilities
477
+ */
478
+ type Theme = 'light' | 'dark';
479
+ /**
480
+ * Detect current theme from the page
481
+ *
482
+ * Simple detection:
483
+ * 1. Check data-theme attribute (explicit setting)
484
+ * 2. Check dark class (common pattern)
485
+ * 3. Default to light (most pages are light)
486
+ *
487
+ * Note: We default to 'light' instead of checking system preference
488
+ * because most web pages are light-themed, and it's better to have
489
+ * readable dark text on light background than light text on light background.
490
+ *
491
+ * @returns Current theme ('light' or 'dark')
492
+ */
493
+ declare function detectTheme(): Theme;
494
+ /**
495
+ * Watch for theme changes
496
+ *
497
+ * @param callback - Callback to execute when theme changes
498
+ * @returns Cleanup function
499
+ */
500
+ declare function watchTheme(callback: (theme: Theme) => void): () => void;
501
+
502
+ /**
503
+ * Form styles management
504
+ *
505
+ * Handles theme-aware styling and dynamic style injection
506
+ */
507
+
508
+ /**
509
+ * Theme color schemes for forms
510
+ */
511
+ interface ThemeColors {
512
+ formBg: string;
513
+ labelColor: string;
514
+ inputBg: string;
515
+ inputText: string;
516
+ inputBorder: string;
517
+ inputBorderFocus: string;
518
+ placeholderColor: string;
519
+ radioColor: string;
520
+ ratingInactive: string;
521
+ errorBg: string;
522
+ errorColor: string;
523
+ errorBorder: string;
524
+ successBg: string;
525
+ successColor: string;
526
+ successBorder: string;
527
+ buttonBg: string;
528
+ buttonBgHover: string;
529
+ }
530
+ /**
531
+ * Form styles manager
532
+ */
533
+ declare class FormStyles {
534
+ private styleElement;
535
+ private currentTheme;
536
+ private styleId;
537
+ private _primaryColor;
538
+ /**
539
+ * Theme color schemes
540
+ */
541
+ private themes;
542
+ constructor(primaryColor?: string, containerId?: string);
543
+ /**
544
+ * Get current theme colors
545
+ */
546
+ getColors(theme?: Theme): ThemeColors;
547
+ /**
548
+ * Update theme
549
+ */
550
+ updateTheme(theme: Theme): void;
551
+ /**
552
+ * Update primary color
553
+ */
554
+ updatePrimaryColor(color: string): void;
555
+ /**
556
+ * Get primary color (for reference)
557
+ */
558
+ getPrimaryColor(): string;
559
+ /**
560
+ * Darken a color by a percentage
561
+ */
562
+ private darkenColor;
563
+ /**
564
+ * Inject styles into document
565
+ */
566
+ private injectStyles;
567
+ /**
568
+ * Generate CSS for form styles
569
+ */
570
+ private generateCSS;
571
+ /**
572
+ * Cleanup styles
573
+ */
574
+ destroy(): void;
575
+ }
576
+
577
+ /**
578
+ * Form renderer
579
+ *
580
+ * Handles rendering form HTML from form definition
581
+ */
582
+
583
+ /**
584
+ * Form renderer class
585
+ */
586
+ declare class FormRenderer {
587
+ private styles;
588
+ constructor(styles: FormStyles);
589
+ /**
590
+ * Render form HTML
591
+ */
592
+ render(formData: FormDefinition, theme: Theme): string;
593
+ /**
594
+ * Render a single field
595
+ */
596
+ private renderField;
597
+ /**
598
+ * Render text input field
599
+ */
600
+ private renderTextInput;
601
+ /**
602
+ * Render textarea field
603
+ */
604
+ private renderTextarea;
605
+ /**
606
+ * Render select field
607
+ */
608
+ private renderSelect;
609
+ /**
610
+ * Render radio group
611
+ */
612
+ private renderRadio;
613
+ /**
614
+ * Render checkbox group
615
+ */
616
+ private renderCheckbox;
617
+ /**
618
+ * Render rating field
619
+ */
620
+ private renderRating;
621
+ }
622
+
623
+ /**
624
+ * API client for making HTTP requests
625
+ */
626
+ /**
627
+ * API client options
628
+ */
629
+ interface ApiClientOptions {
630
+ baseUrl: string;
631
+ apiKey: string;
632
+ timeout?: number;
633
+ }
634
+ /**
635
+ * Request options for API calls
636
+ */
637
+ interface RequestOptions {
638
+ /**
639
+ * Whether to include API key in headers (default: true)
640
+ * Set to false for public endpoints like form definitions
641
+ */
642
+ requireAuth?: boolean;
643
+ }
644
+ /**
645
+ * API response wrapper
646
+ */
647
+ interface ApiResponse<T = any> {
648
+ success: boolean;
649
+ data?: T;
650
+ error?: string;
651
+ message?: string;
652
+ }
653
+ /**
654
+ * API client class
655
+ */
656
+ declare class ApiClient {
657
+ private baseUrl;
658
+ private apiKey;
659
+ private timeout;
660
+ constructor(options: ApiClientOptions);
661
+ /**
662
+ * Make a GET request
663
+ *
664
+ * @param endpoint - API endpoint path
665
+ * @param options - Request options (e.g., requireAuth)
666
+ */
667
+ get<T = any>(endpoint: string, options?: RequestOptions): Promise<ApiResponse<T>>;
668
+ /**
669
+ * Make a POST request
670
+ *
671
+ * @param endpoint - API endpoint path
672
+ * @param data - Request body data
673
+ * @param options - Request options (e.g., requireAuth)
674
+ */
675
+ post<T = any>(endpoint: string, data?: any, options?: RequestOptions): Promise<ApiResponse<T>>;
676
+ /**
677
+ * Make a request
678
+ */
679
+ private request;
680
+ }
681
+
682
+ /**
683
+ * Simple event emitter for SDK
684
+ */
685
+ type EventHandler = (...args: any[]) => void;
686
+ /**
687
+ * Simple event emitter class
688
+ */
689
+ declare class EventEmitter {
690
+ private events;
691
+ /**
692
+ * Subscribe to an event
693
+ */
694
+ on(event: string, handler: EventHandler): void;
695
+ /**
696
+ * Unsubscribe from an event
697
+ */
698
+ off(event: string, handler: EventHandler): void;
699
+ /**
700
+ * Emit an event
701
+ */
702
+ emit(event: string, ...args: any[]): void;
703
+ /**
704
+ * Remove all listeners for an event
705
+ */
706
+ removeAllListeners(event?: string): void;
707
+ /**
708
+ * Get listener count for an event
709
+ */
710
+ listenerCount(event: string): number;
711
+ }
712
+
713
+ /**
714
+ * Configuration management utilities
715
+ */
716
+
717
+ /**
718
+ * Validate SDK configuration
719
+ *
720
+ * @param config - Configuration to validate
721
+ * @throws {Error} If configuration is invalid
722
+ */
723
+ declare function validateConfig(config: Partial<WabbitConfig>): void;
724
+ /**
725
+ * Merge configuration with defaults
726
+ *
727
+ * @param config - User configuration
728
+ * @returns Merged configuration with defaults
729
+ */
730
+ declare function mergeConfig(config: WabbitConfig): WabbitConfig;
731
+
732
+ /**
733
+ * DOM utility functions
734
+ */
735
+ /**
736
+ * Escape HTML to prevent XSS attacks
737
+ *
738
+ * @param text - Text to escape
739
+ * @returns Escaped HTML string
740
+ */
741
+ declare function escapeHtml(text: string): string;
742
+ /**
743
+ * Wait for DOM to be ready
744
+ *
745
+ * @param callback - Callback to execute when DOM is ready
746
+ */
747
+ declare function onDOMReady(callback: () => void): void;
748
+ /**
749
+ * Create a DOM element with attributes
750
+ *
751
+ * @param tag - HTML tag name
752
+ * @param attributes - Element attributes
753
+ * @param children - Child elements or text
754
+ * @returns Created element
755
+ */
756
+ declare function createElement(tag: string, attributes?: Record<string, string>, children?: (Node | string)[]): HTMLElement;
757
+
758
+ /**
759
+ * localStorage wrapper with type safety
760
+ */
761
+ /**
762
+ * Storage interface
763
+ */
764
+ interface Storage {
765
+ getItem(key: string): string | null;
766
+ setItem(key: string, value: string): void;
767
+ removeItem(key: string): void;
768
+ clear(): void;
769
+ length?: number;
770
+ key?: (index: number) => string | null;
771
+ }
772
+ /**
773
+ * Safe storage wrapper
774
+ */
775
+ declare class SafeStorage {
776
+ private storage;
777
+ private prefix;
778
+ constructor(storage?: Storage, prefix?: string);
779
+ /**
780
+ * Get item from storage
781
+ */
782
+ get<T = any>(key: string): T | null;
783
+ /**
784
+ * Set item in storage
785
+ */
786
+ set<T = any>(key: string, value: T): boolean;
787
+ /**
788
+ * Remove item from storage
789
+ */
790
+ remove(key: string): void;
791
+ /**
792
+ * Clear all items with prefix
793
+ */
794
+ clear(): void;
795
+ }
796
+ declare const storage: SafeStorage;
797
+
798
+ /**
799
+ * Email Capture Modal Component
800
+ *
801
+ * Vanilla JavaScript implementation of the email capture modal
802
+ */
803
+
804
+ interface EmailCaptureData {
805
+ email: string;
806
+ name?: string;
807
+ company?: string;
808
+ }
809
+ declare class EmailCaptureModal {
810
+ private config;
811
+ private overlay;
812
+ private modal;
813
+ private isOpen;
814
+ private onSubmitCallback?;
815
+ private onDismissCallback?;
816
+ constructor(config: EmailCaptureConfig);
817
+ /**
818
+ * Show the email capture modal
819
+ */
820
+ show(onSubmit: (data: EmailCaptureData, dontShowAgain: boolean) => Promise<void>, onDismiss?: () => void): void;
821
+ /**
822
+ * Hide the email capture modal
823
+ */
824
+ hide(): void;
825
+ /**
826
+ * Render the modal
827
+ */
828
+ private render;
829
+ /**
830
+ * Render a form field
831
+ */
832
+ private renderField;
833
+ /**
834
+ * Attach event listeners
835
+ */
836
+ private attachEventListeners;
837
+ /**
838
+ * Handle form submission
839
+ */
840
+ private handleSubmit;
841
+ /**
842
+ * Handle dismiss
843
+ */
844
+ private handleDismiss;
845
+ /**
846
+ * Set form disabled state
847
+ */
848
+ private setFormDisabled;
849
+ /**
850
+ * Show error message
851
+ */
852
+ private showError;
853
+ /**
854
+ * Validate email format
855
+ */
856
+ private isValidEmail;
857
+ /**
858
+ * Destroy the modal
859
+ */
860
+ destroy(): void;
861
+ }
862
+
863
+ /**
864
+ * Email Capture Widget
865
+ *
866
+ * Manages email capture modal and integrates with chat widget
867
+ */
868
+
869
+ declare class EmailCaptureWidget {
870
+ private config;
871
+ private modal;
872
+ private messageCount;
873
+ private emailCaptured;
874
+ private wsClient;
875
+ private onCaptureCallback?;
876
+ constructor(config: EmailCaptureConfig);
877
+ /**
878
+ * Initialize the email capture widget
879
+ */
880
+ init(): void;
881
+ /**
882
+ * Set WebSocket client (from ChatWidget)
883
+ */
884
+ setWebSocketClient(wsClient: any): void;
885
+ /**
886
+ * Handle new message (called by ChatWidget)
887
+ */
888
+ handleMessage(): void;
889
+ /**
890
+ * Show the email capture modal
891
+ */
892
+ private showModal;
893
+ /**
894
+ * Handle email submission
895
+ */
896
+ private handleEmailSubmit;
897
+ /**
898
+ * Handle modal dismiss
899
+ */
900
+ private handleDismiss;
901
+ /**
902
+ * Destroy the widget
903
+ */
904
+ destroy(): void;
905
+ }
906
+
907
+ /**
908
+ * Wabbit Embed SDK
909
+ *
910
+ * Unified widget library for embedding chat, forms, and email capture
911
+ * functionality into customer websites.
912
+ *
913
+ * @packageDocumentation
914
+ */
915
+
916
+ declare function init(config: WabbitConfig): Wabbit;
917
+ declare function getInstance(): Wabbit | null;
918
+ declare function destroy(): void;
919
+ declare const WabbitSDK: {
920
+ init: typeof init;
921
+ getInstance: typeof getInstance;
922
+ destroy: typeof destroy;
923
+ };
924
+
925
+ export { ApiClient, ChatBubble, ChatPanel, ChatWebSocketClient, ChatWidget, EmailCaptureModal, EmailCaptureWidget, EventEmitter, FormRenderer, FormStyles, FormWidget, SafeStorage, Wabbit, createElement, WabbitSDK as default, destroy, detectTheme, escapeHtml, getInstance, init, mergeConfig, onDOMReady, storage, validateConfig, watchTheme };
926
+ export type { ApiClientOptions, ApiResponse, ChatConfig, ConnectionStatus, EmailCaptureConfig, EmailCaptureData, FormConfig, FormDefinition, FormField, FormFieldType, FormSettings, FormSubmissionResponse, Message, RequestOptions, WabbitConfig };