import type { RefObject, ReactNode } from "react"; import { BotData, ChatState } from "~/types/bot"; import { Message, ConversationStep } from "~/types/chat"; import { ProductCardData, RepliedProduct } from "~/types/product"; import { WidgetType } from "~/utils/session-storage"; import { InstallationSource } from "~/utils/installation-source"; export interface ChatContextType { botData: BotData | null; isLoadingBot: boolean; botError: string | null; chatState: ChatState; messages: Message[]; currentStep: ConversationStep; isInputDisabled: boolean; inputState: "starting" | "generating" | "minimized"; widgetType: WidgetType; installationSource: InstallationSource; dynamicWelcomeMessage: string | null; isLoadingWelcomeMessage: boolean; shouldInjectContext: boolean; setShouldInjectContext: (value: boolean) => void; initializeBot: (sharingId: string) => Promise; sendMessage: ( { message, imageUrl, apiMessage }: { message: string; imageUrl?: string; apiMessage?: string; }, repliedProduct?: ProductCardData ) => Promise; stopCurrentRequest: () => void; setCurrentStep: (step: ConversationStep) => void; setInputState: (state: "starting" | "generating" | "minimized") => void; addWelcomeMessage: () => void; setRepliedProduct: (repliedProduct: RepliedProduct | null) => void; setWidgetType: (widgetType: WidgetType) => void; messagesEndRef: RefObject; setAutoScrollEnabled: (enabled: boolean) => void; resetThreadId: () => void; startNewConversation: () => void; } export type StateSnapshot = { botData: BotData | null; chatState: ChatState; messages: Message[]; currentStep: ConversationStep; }; export interface ChatProviderProps { children: ReactNode; initialWidgetType?: WidgetType; installationSource?: InstallationSource; }