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

// ── 各模块 API ─────────────────────────────────────────────────────────────────
export { authApi } from "./auth";
export { queriesApi } from "./queries";
export { citationsApi } from "./citations";
export { reportsApi } from "./reports";
export { subscriptionsApi } from "./subscriptions";
export { adminApi } 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 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";

/**
 * 聚合 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,
};
