export type ChatMessageType = 'text' | 'table' | 'card' | 'menu';
export type ChatDisplayMode = 'embedded' | 'floating';

export interface ChatMenuOption {
  id: string;
  label: string;
  value: string;
}

export interface ChatSendPayload {
  action: 'sendMessage';
  sessionId: string;
  chatInput: string;
}

export interface ChatWebhookResponse {
  status: 'success' | 'error';
  meta: { intent: string };
  message: { text: string; type: ChatMessageType };
  data: Record<string, unknown>[];
  error: null | { code: number; message: string };
}

export interface ChatUiMessage {
  id: string;
  role: 'user' | 'assistant' | 'error';
  text: string;
  type?: ChatMessageType;
  data?: Record<string, unknown>[];
  timestamp: number;
  status?: 'sent' | 'pending' | 'failed';
}

export interface ChatAssistantContextValue {
  sessionId: string;
  messages: ChatUiMessage[];
  isOpen: boolean;
  isSending: boolean;
  preferredMode: ChatDisplayMode;
  effectiveMode: ChatDisplayMode;
  isEmbeddedOpen: boolean;
  sendMessage: (text: string) => Promise<void>;
  retryLastMessage: () => Promise<void>;
  startNewConversation: () => void;
  toggleOpen: () => void;
  close: () => void;
  setPreferredMode: (mode: ChatDisplayMode) => void;
}
