import type {
  ActivityEntry,
  Attachment,
  BoardGroup,
  CalendarEvent,
  FocusSession,
  Invite,
  Label,
  MailAddress,
  Mailbox,
  MailMessage,
  Member,
  Note,
  OutgoingMail,
  Task as BaseTask,
  Workspace
} from "@productier/api-client";

// Extend Task with recurrence fields
export interface Task extends BaseTask {
  recurrenceRule?: string;
  recurrenceEnd?: string;
  archived?: boolean;
}

export type {
  ActivityEntry,
  Attachment,
  BoardGroup,
  CalendarEvent,
  FocusSession,
  Invite,
  Label,
  MailAddress,
  Mailbox,
  MailMessage,
  Member,
  Note,
  OutgoingMail,
  Workspace
};

export type ThemeMode = "light" | "dark";
export type WorkspaceRole = Workspace["role"];
export type TaskStatus = Task["status"];
export type FocusMode = FocusSession["mode"];
export type QueueStatus = "queued" | "synced" | "conflict";
export type QueueEntityType = "board_group" | "label" | "task" | "event" | "note" | "focus_session";
export type QueueAction = "create" | "update";

export interface SessionUser {
  id: string;
  name: string;
  email: string;
}

export interface OfflineQueueItem {
  id: string;
  entityType: QueueEntityType;
  action: QueueAction;
  entityId?: string;
  description: string;
  createdAt: string;
  status: QueueStatus;
  payload?: Record<string, unknown>;
}

export interface AppState {
  theme: ThemeMode;
  session: SessionUser | null;
  workspaces: Workspace[];
  members: Member[];
  invites: Invite[];
  boardGroups: BoardGroup[];
  labels: Label[];
  tasks: Task[];
  events: CalendarEvent[];
  notes: Note[];
  focusSessions: FocusSession[];
  activities: ActivityEntry[];
  offlineQueue: OfflineQueueItem[];
  // CRM
  contacts: import("./types-crm").Contact[];
  companies: import("./types-crm").Company[];
  inboxItems: import("./types-crm").InboxItem[];
  timeEntries: import("./types-crm").TimeEntry[];
  savedViews: import("./types-crm").SavedView[];
  // Integrations
  integrations: import("./types-integrations").Integration[];
  webhooks: import("./types-integrations").Webhook[];
  notifications: import("./types-integrations").Notification[];
}
