// ─── Rich payload types ───────────────────────────────────────────────────────
export type NativeBtn =
  | { type: 'reply'; id: string; text: string }
  | { type: 'url';   text: string; url: string }
  | { type: 'copy';  text: string; copyText: string }
  | { type: 'call';  text: string; phoneNumber: string }

export interface RichPayload {
  text?:    string
  footer?:  string
  nativeButtons?: NativeBtn[]
  nativeList?: {
    buttonText: string
    sections: Array<{ title: string; rows: Array<{ id: string; title: string; description?: string }> }>
  }
  nativeCarousel?: {
    cards: Array<{
      title?: string; body?: string; footer?: string
      image?: { url: string }
      buttons: Array<{ type?: string; id?: string; text: string }>
    }>
  }
  poll?: { name: string; values: string[]; selectableCount?: number }
}

export interface Message {
    id: number;
    chat_id: number;
    message_id: string;
    text: string;
    type: string;
    direction: 'in' | 'out';
    status: 'sending' | 'pending' | 'sent' | 'delivered' | 'read' | 'deleted' | 'failed';
    timestamp: string;
    media_url?: string;
    media_type?: string;
    media_size?: number;
    quoted_id?: string | null;
    quoted_message_id?: string | null;
    quoted_message_text?: string | null;
    quoted_participant?: string | null;
    reactions?: Record<string, string> | null;
    participant?: string | null;
    instance_name?: string;
    sender_jid?: string;
    rich_payload?: RichPayload | null;
}

export interface WhatsAppInstance {
    instance: string;
    /** New Whats API status: open, connected, disconnected, connecting, etc. */
    status: 'connecting' | 'qr' | 'connected' | 'disconnected' | 'open' | 'close';
    phone?: string;
    hasQr: boolean;
    createdAt: string;
    profilePictureUrl?: string;
    photoUpdatesRemaining?: number;
    partner_id?: number | null;
    partner_name?: string | null;
    /** For UI display primarily from the Console/Admin View */
    id?: string;
    nome?: string;
    avatar?: string | null;
    webhook_url?: string;
    metrics?: {
        sent: number;
        failed: number;
    };
}

// ─── Inbox / Chat UI types ────────────────────────────────────────────────────
// Formato legado consumido por ChatList, ChatListItem, ChatSidebar e hooks de inbox.
// Produzido pelo mapper chatToLegacy() em useNewInboxBridge.

export interface NewWhatsChat {
  id: any
  instance_name: string
  remote_jid: string
  phone: string
  lead_name: string | null
  avatar_url: string | null
  avatar_version: string | null
  bio: string | null
  displayName: string | null
  subject: string | null
  last_message_text: string | null
  last_message_time: string | null
  last_message_from_me: 0 | 1
  last_message_status: string | null
  last_message_type?: string | null
  last_message_sender?: string | null
  unread_count: number
  is_pinned: boolean | null
  is_archived: boolean | null
  muted_until?: string | null
  bot_paused?: boolean | null
  labels?: Array<{ label_id: string; name?: string }>
}

export interface PresenceState {
  state: 'composing' | 'recording' | 'paused' | 'available' | 'unavailable'
  ts: number
}

export type PurgeMode = 'all' | 'data_only';
export type StepStatus = 'waiting' | 'running' | 'ok' | 'error' | 'skip';

export interface PurgeStep {
    id: string;
    label: string;
    detail: string;
    icon?: any;
    status: StepStatus;
}

export default function TypesPage() { return null; }
