import React, { ReactNode, RefObject } from 'react'; /** * Supported AI providers */ type AIProvider = 'openai' | 'anthropic' | 'mistral'; /** * Chat message role */ type MessageRole = 'user' | 'assistant'; /** * Position of the chatbot on screen */ type ChatPosition = 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left'; /** * Theme options */ type ThemeMode = 'light' | 'dark' | 'auto'; /** * Individual chat message */ interface Message { id: string; content: string; role: MessageRole; timestamp: Date; } /** * AI configuration for the chatbot */ interface AIConfig { /** AI provider to use */ provider: AIProvider; /** API key for the provider */ apiKey: string; /** Model to use (e.g., 'gpt-4', 'claude-3-opus-20240229', 'mistral-large-latest') */ model?: string; /** System prompt to set context for the AI */ systemPrompt?: string; /** Maximum tokens in the response */ maxTokens?: number; /** Temperature for response randomness (0-1) */ temperature?: number; } /** * Theme configuration */ interface ThemeConfig { /** Primary accent color */ primaryColor?: string; /** Background color of the chat window */ backgroundColor?: string; /** Text color */ textColor?: string; /** User message bubble color */ userBubbleColor?: string; /** User message text color */ userTextColor?: string; /** Assistant message bubble color */ assistantBubbleColor?: string; /** Assistant message text color */ assistantTextColor?: string; /** Border radius for bubbles and buttons */ borderRadius?: number; /** Font family */ fontFamily?: string; } /** * Main chatbot component props */ interface ChatbotProps { /** AI configuration including provider, API key, and model settings */ aiConfig: AIConfig; /** Position of the chat toggle button on screen */ position?: ChatPosition; /** Horizontal offset from the edge (in pixels) */ offsetX?: number; /** Vertical offset from the edge (in pixels) */ offsetY?: number; /** Width of the chat window */ chatWidth?: number | string; /** Height of the chat window */ chatHeight?: number | string; /** Custom icon for the toggle button */ toggleIcon?: ReactNode; /** Label text next to the toggle icon */ toggleLabel?: string; /** Whether to show the toggle label */ showToggleLabel?: boolean; /** Color theme mode */ theme?: ThemeMode; /** Custom theme configuration */ themeConfig?: ThemeConfig; /** Welcome message(s) shown when chat opens. If array, one is picked randomly */ welcomeMessage?: string | string[]; /** Placeholder text for the input field */ placeholder?: string; /** Close chat when clicking outside */ closeOnClickOutside?: boolean; /** Keep messages when chat is closed */ persistMessages?: boolean; /** Text shown while AI is thinking */ loadingText?: string; /** Called when chat is opened */ onOpen?: () => void; /** Called when chat is closed */ onClose?: () => void; /** Called when user sends a message */ onMessageSent?: (message: string) => void; /** Called when AI responds */ onMessageReceived?: (message: string) => void; /** Called when an error occurs */ onError?: (error: Error) => void; } /** * Chat state for the useChat hook */ interface ChatState { messages: Message[]; isLoading: boolean; error: Error | null; } declare const Chatbot: React.FC; interface UseChatOptions { aiConfig: AIConfig; onMessageSent?: (message: string) => void; onMessageReceived?: (message: string) => void; onError?: (error: Error) => void; } interface UseChatReturn extends ChatState { sendMessage: (content: string) => Promise; addMessage: (message: Omit) => void; clearMessages: () => void; clearError: () => void; } /** * Hook for managing chat state and AI interactions */ declare function useChat({ aiConfig, onMessageSent, onMessageReceived, onError, }: UseChatOptions): UseChatReturn; /** * Hook that detects clicks outside of the specified element * @param ref - React ref of the element to detect outside clicks for * @param handler - Callback function to run when click outside is detected * @param enabled - Whether the hook is enabled (default: true) */ declare function useClickOutside(ref: RefObject, handler: () => void, enabled?: boolean): void; declare const lightTheme: ThemeConfig; declare const darkTheme: ThemeConfig; /** * Apply theme config as CSS variables */ declare function applyTheme(config: ThemeConfig, element: HTMLElement): void; /** * Get system theme preference */ declare function getSystemTheme(): 'light' | 'dark'; interface ProviderMessage { role: MessageRole; content: string; } interface AIProviderInterface { sendMessage(messages: ProviderMessage[], config: AIConfig): Promise; } declare class OpenAIProvider implements AIProviderInterface { sendMessage(messages: ProviderMessage[], config: AIConfig): Promise; } declare class AnthropicProvider implements AIProviderInterface { sendMessage(messages: ProviderMessage[], config: AIConfig): Promise; } declare class MistralProvider implements AIProviderInterface { sendMessage(messages: ProviderMessage[], config: AIConfig): Promise; } declare function getProvider(config: AIConfig): AIProviderInterface; /** * Simple markdown parser - converts basic markdown to HTML * Supports: bold, italic, links, code, lists */ declare function parseMarkdown(text: string): string; /** * Sanitize HTML to prevent XSS attacks */ declare function sanitizeHtml(html: string): string; export { AnthropicProvider, Chatbot, MistralProvider, OpenAIProvider, applyTheme, darkTheme, Chatbot as default, getProvider, getSystemTheme, lightTheme, parseMarkdown, sanitizeHtml, useChat, useClickOutside }; export type { AIConfig, AIProvider, AIProviderInterface, ChatPosition, ChatbotProps, Message, MessageRole, ProviderMessage, ThemeConfig, ThemeMode };