// ── 基础客户端 ─────────────────────────────────────────────────────────────────
export { fetchWithAuth, getApiUrl, API_BASE } from "./client";

// ── 各模块 API ─────────────────────────────────────────────────────────────────
export { authApi } from "./auth";
export { queriesApi } from "./queries";
export type { ApiQueryItem, QueryListResponse, CreateQueryPayload, UpdateQueryPayload } from "./queries";
export { citationsApi } from "./citations";
export type { CitationRecord, CitationListResponse, CitationStats } from "./citations";
export { reportsApi } from "./reports";
export { subscriptionsApi } from "./subscriptions";
export { adminApi } from "./admin";
export type { AdminStatsData, AdminUser, AdminUserListResponse, AdminActionResponse } from "./admin";
export { agentsApi } from "./agents";
export { lifecycleApi } from "./lifecycle";
export { contentsApi } from "./contents";
export { clientsApi } from "./clients";
export { knowledgeApi } from "./knowledge";
export { contentGenerationApi } from "./content";
export { distributionApi } from "./distribution";
export { analyticsApi } from "./analytics";
export { alertsApi } from "./alerts";
export { brandsApi } from "./brands";
export type { CreateBrandPayload, UpdateBrandPayload, AddCompetitorPayload } from "./brands";
export { suggestionsApi } from "./suggestions";
export { onboardingApi } from "./onboarding";
export { platformRulesApi } from "./platform-rules";
export { imageApi, IMAGE_GENERATION_CONFIG } from "./image";
export { organizationApi } from "./organization";
export type {
  OrganizationMember,
  OrganizationInfo,
  MemberRole,
  MemberStatus,
  InviteMemberPayload,
  UpdateMemberRolePayload,
} from "./organization";

// ── 类型导出 ───────────────────────────────────────────────────────────────────
export type { Agent, AgentRunLog } from "./agents";
export type {
  GeoProject,
  ProjectStage,
  ProjectStatus,
  LifecycleStats,
  CreateProjectPayload,
  UpdateProjectPayload,
} from "./lifecycle";
export type {
  Content,
  ContentType,
  ContentStatus,
  KnowledgeEntry,
  CreateContentPayload,
  UpdateContentPayload,
} from "./contents";
export type {
  Client,
  ClientStatus,
  CreateClientPayload,
  UpdateClientPayload,
} from "./clients";
export type {
  KnowledgeBase,
  KnowledgeDocument,
  SearchResult,
  SearchResponse,
  CreateKnowledgeBasePayload,
  UploadDocumentPayload,
} from "./knowledge";
export type {
  OverviewStatsResponse,
  TopContentItem,
  TopContentResponse,
  InsightResponse,
  PublishRecordCreate,
  PublishRecordResponse,
  MetricsUpdateRequest,
  MetricsResponse,
  ContentPerformanceResponse,
} from "./analytics";
export type {
  PlatformInfo,
  PlatformListResponse,
  ValidationIssue,
  ContentValidateResponse,
  ScheduleItem,
  PublishStrategyResponse,
  ContentFormatResponse,
  ScheduleCreateResponse,
} from "./distribution";
export type {
  ContentGenerateRequest,
  ContentGenerateResponse,
  PipelineStage,
  TopicItem,
  GenerateTopicsResponse,
} from "./content";

// ── 向后兼容：聚合 api 对象 ────────────────────────────────────────────────────
import { authApi } from "./auth";
import { queriesApi } from "./queries";
import { citationsApi } from "./citations";
import { reportsApi } from "./reports";
import { subscriptionsApi } from "./subscriptions";
import { adminApi } from "./admin";
import { agentsApi } from "./agents";
import { lifecycleApi } from "./lifecycle";
import { contentsApi } from "./contents";
import { clientsApi } from "./clients";
import { knowledgeApi } from "./knowledge";
import { contentGenerationApi } from "./content";
import { distributionApi } from "./distribution";
import { analyticsApi } from "./analytics";
import { alertsApi } from "./alerts";
import { brandsApi } from "./brands";
import { suggestionsApi } from "./suggestions";
import { onboardingApi } from "./onboarding";
import { platformRulesApi } from "./platform-rules";
import { imageApi } from "./image";

/**
 * 聚合 API 对象，保持与原 `import { api } from "@/lib/api"` 的向后兼容。
 * 新代码推荐直接从 "@/lib/api" 导入各模块（如 `import { authApi } from "@/lib/api"`）。
 */
export const api = {
  auth: authApi,
  queries: queriesApi,
  citations: citationsApi,
  reports: reportsApi,
  subscriptions: subscriptionsApi,
  admin: adminApi,
  agents: agentsApi,
  lifecycle: lifecycleApi,
  contents: contentsApi,
  clients: clientsApi,
  knowledge: knowledgeApi,
  contentGeneration: contentGenerationApi,
  distribution: distributionApi,
  analytics: analyticsApi,
  alerts: alertsApi,
  brands: brandsApi,
  suggestions: suggestionsApi,
  onboarding: onboardingApi,
  platformRules: platformRulesApi,
  image: imageApi,
};
