import type { AgentConversation, AgentConversationMessage, AgentMemory, AgentModelOption, AgentSourceAttribution } from "../../api/agent";

export type UserBranch = {
  id: number;
  name: string;
};

export type DraftMode = "none" | "suggestion" | "activity" | "mutualAid" | "activityRegister";

export type SuggestionDraft = {
  title?: string;
  summary?: string;
  body?: string;
  branchIds?: number[];
  branchName?: string;
};

export type ActivityDraft = {
  title?: string;
  description?: string;
  location?: string;
  startsAt?: string;
  endsAt?: string;
  registerDeadline?: string;
  capacity?: number;
  branchIds?: number[];
  branchName?: string;
};

export type MutualAidDraft = {
  postType?: "resource" | "need";
  title?: string;
  description?: string;
  contactPhone?: string;
  contactWechat?: string;
  tagsText?: string;
  publisherTitle?: string;
  branchId?: number;
  branchName?: string;
};

export type ActivityRegisterDraft = {
  activityId?: number;
  title?: string;
  startsAt?: string;
  location?: string;
};

export type ConversationDraft = {
  mode: DraftMode;
  suggestion?: SuggestionDraft;
  activity?: ActivityDraft;
  mutualAid?: MutualAidDraft;
  activityRegister?: ActivityRegisterDraft;
};

export type PendingAction = {
  actionCode: string;
  payload?: Record<string, unknown>;
  targetId?: number;
  reason?: string;
  previewText?: string;
};

export type MessageAction = {
  label: string;
  action: string;
};

export type ClarificationOption = {
  index: number;
  label: string;
  action: string;
  description?: string;
  freeInput?: boolean;
};

export type ChatMessage = {
  id: string;
  messageId?: number;
  role: "user" | "assistant";
  text: string;
  time: string;
  actions?: MessageAction[];
  choiceOptions?: ClarificationOption[];
  draftLines?: string[];
  variant?: "default" | "pending" | "success" | "clarify";
  /** 可跳转的小程序页面路径 */
  pageTarget?: string;
  sources?: AgentSourceAttribution[];
  feedbackRating?: "up" | "down" | "neutral" | "";
  feedbackPending?: boolean;
};

export type ConversationItem = {
  id: number;
  title: string;
  summary: string;
  updatedAt: string;
  modelCode?: string;
};
