import type { MindSpace, MindSpaceAsset, MindSpacePage, PortalUser } from '../types';

export const PREVIEW_USER: PortalUser = {
  id: 'preview-user',
  username: 'preview',
  slug: 'preview',
  email: 'preview@tkmind.local',
  displayName: '预览用户',
  role: 'user',
  status: 'active',
  planType: 'free',
  workspaceRoot: '/preview',
  balanceCents: 1280,
  totalCreditCents: 5000,
  tokensUsed: 0,
};

export const PREVIEW_SPACE: MindSpace = {
  id: 'preview-space',
  userId: PREVIEW_USER.id,
  name: '我的空间',
  status: 'active',
  quota: {
    quotaBytes: 5 * 1024 * 1024,
    usedBytes: 1.2 * 1024 * 1024,
    reservedBytes: 0,
    availableBytes: 3.8 * 1024 * 1024,
    maxFileBytes: 5 * 1024 * 1024,
    publicPageLimit: 3,
    publicPageUsed: 1,
    aiDailyLimit: 20,
    aiDailyUsed: 6,
    monthlyViewLimit: 1000,
    monthlyViewUsed: 42,
  },
  categories: [
    {
      id: 'cat-oa',
      code: 'oa',
      name: 'OA 工作区',
      visibilityPolicy: 'private',
      aiAccessPolicy: 'allowed',
      publishPolicy: 'review',
      isSystem: true,
      sortOrder: 1,
      itemCount: 4,
    },
    {
      id: 'cat-private',
      code: 'private',
      name: '私人区',
      visibilityPolicy: 'private',
      aiAccessPolicy: 'allowed',
      publishPolicy: 'blocked',
      isSystem: true,
      sortOrder: 2,
      itemCount: 2,
    },
    {
      id: 'cat-public',
      code: 'public',
      name: '公开区',
      visibilityPolicy: 'public',
      aiAccessPolicy: 'allowed',
      publishPolicy: 'allowed',
      isSystem: true,
      sortOrder: 3,
      itemCount: 3,
    },
    {
      id: 'cat-draft',
      code: 'draft',
      name: '页面草稿',
      visibilityPolicy: 'private',
      aiAccessPolicy: 'allowed',
      publishPolicy: 'review',
      isSystem: true,
      sortOrder: 4,
      itemCount: 2,
    },
    {
      id: 'cat-archive',
      code: 'archive',
      name: '归档',
      visibilityPolicy: 'private',
      aiAccessPolicy: 'denied',
      publishPolicy: 'blocked',
      isSystem: true,
      sortOrder: 5,
      itemCount: 0,
    },
  ],
  createdAt: Date.now() - 86_400_000,
  updatedAt: Date.now(),
};

export const PREVIEW_PAGES: MindSpacePage[] = [
  {
    id: 'page-1',
    categoryId: 'cat-draft',
    categoryCode: 'draft',
    sourceSessionId: null,
    sourceMessageId: null,
    sourceAssetId: null,
    title: '2026 市场趋势分析',
    summary: '基于上传资料生成的分析报告草稿',
    pageType: 'report',
    templateId: 'report',
    status: 'draft',
    visibility: 'private',
    currentVersionId: 'page-1-v2',
    versionNo: 2,
    contentFormat: 'markdown',
    createdAt: Date.now() - 172_800_000,
    updatedAt: Date.now() - 43_200_000,
  },
  {
    id: 'page-2',
    categoryId: 'cat-draft',
    categoryCode: 'draft',
    sourceSessionId: null,
    sourceMessageId: null,
    sourceAssetId: null,
    title: '马来西亚旅游攻略',
    summary: 'HTML 静态页预览示例',
    pageType: 'html',
    templateId: 'editorial',
    status: 'ready',
    visibility: 'private',
    currentVersionId: 'page-2-v1',
    versionNo: 1,
    contentFormat: 'html',
    createdAt: Date.now() - 259_200_000,
    updatedAt: Date.now() - 86_400_000,
  },
  {
    id: 'page-3',
    categoryId: 'cat-public',
    categoryCode: 'public',
    sourceSessionId: null,
    sourceMessageId: null,
    sourceAssetId: null,
    title: '客户成功月报',
    summary: '重点客户续费、风险和行动计划整理',
    pageType: 'report',
    templateId: 'report',
    status: 'ready',
    visibility: 'private',
    currentVersionId: 'page-3-v1',
    versionNo: 1,
    contentFormat: 'markdown',
    createdAt: Date.now() - 360_000_000,
    updatedAt: Date.now() - 132_000_000,
  },
  {
    id: 'page-4',
    categoryId: 'cat-oa',
    categoryCode: 'oa',
    sourceSessionId: null,
    sourceMessageId: null,
    sourceAssetId: 'asset-1',
    title: '季度经营报告摘要',
    summary: '从上传 PDF 中提取出的经营指标与风险提示',
    pageType: 'report',
    templateId: 'report',
    status: 'draft',
    visibility: 'private',
    currentVersionId: 'page-4-v1',
    versionNo: 1,
    contentFormat: 'markdown',
    createdAt: Date.now() - 420_000_000,
    updatedAt: Date.now() - 180_000_000,
  },
  {
    id: 'page-5',
    categoryId: 'cat-private',
    categoryCode: 'private',
    sourceSessionId: null,
    sourceMessageId: null,
    sourceAssetId: null,
    title: '私人旅行清单',
    summary: '证件、药品、行程和当地交通备忘',
    pageType: 'html',
    templateId: 'editorial',
    status: 'draft',
    visibility: 'private',
    currentVersionId: 'page-5-v1',
    versionNo: 1,
    contentFormat: 'html',
    createdAt: Date.now() - 480_000_000,
    updatedAt: Date.now() - 240_000_000,
  },
  {
    id: 'page-6',
    categoryId: 'cat-draft',
    categoryCode: 'draft',
    sourceSessionId: null,
    sourceMessageId: null,
    sourceAssetId: null,
    title: 'AI 服务选型笔记',
    summary: '模型能力、成本、延迟和部署方式对比',
    pageType: 'knowledge',
    templateId: 'knowledge-card',
    status: 'draft',
    visibility: 'private',
    currentVersionId: 'page-6-v1',
    versionNo: 1,
    contentFormat: 'markdown',
    createdAt: Date.now() - 560_000_000,
    updatedAt: Date.now() - 318_000_000,
  },
  {
    id: 'page-7',
    categoryId: 'cat-public',
    categoryCode: 'public',
    sourceSessionId: null,
    sourceMessageId: null,
    sourceAssetId: null,
    title: '公开发布指南',
    summary: '发布前检查、脱敏、封面和分享渠道说明',
    pageType: 'editorial',
    templateId: 'editorial',
    status: 'published',
    visibility: 'public',
    currentVersionId: 'page-7-v1',
    versionNo: 1,
    contentFormat: 'markdown',
    createdAt: Date.now() - 620_000_000,
    updatedAt: Date.now() - 402_000_000,
  },
  {
    id: 'page-8',
    categoryId: 'cat-archive',
    categoryCode: 'archive',
    sourceSessionId: null,
    sourceMessageId: null,
    sourceAssetId: null,
    title: '旧版活动复盘',
    summary: '已归档的增长活动数据和经验记录',
    pageType: 'report',
    templateId: 'report',
    status: 'offline',
    visibility: 'private',
    currentVersionId: 'page-8-v1',
    versionNo: 1,
    contentFormat: 'markdown',
    createdAt: Date.now() - 720_000_000,
    updatedAt: Date.now() - 520_000_000,
  },
];

export const PREVIEW_ASSETS: Record<string, MindSpaceAsset[]> = {
  oa: [
    {
      id: 'asset-1',
      categoryId: 'cat-oa',
      categoryCode: 'oa',
      assetType: 'document',
      mimeType: 'application/pdf',
      filename: 'quarterly-report.pdf',
      displayName: '季度经营报告.pdf',
      sizeBytes: 482_112,
      checksum: 'preview',
      riskLevel: 'none',
      visibility: 'private',
      status: 'ready',
      scanStatus: 'passed',
      sourceType: 'upload',
      createdAt: Date.now() - 604_800_000,
      updatedAt: Date.now() - 604_800_000,
    },
    {
      id: 'asset-2',
      categoryId: 'cat-oa',
      categoryCode: 'oa',
      assetType: 'spreadsheet',
      mimeType: 'text/csv',
      filename: 'sales-data.csv',
      displayName: '销售数据.csv',
      sizeBytes: 28_672,
      checksum: 'preview',
      riskLevel: 'low',
      visibility: 'private',
      status: 'ready',
      scanStatus: 'passed',
      sourceType: 'upload',
      createdAt: Date.now() - 302_400_000,
      updatedAt: Date.now() - 302_400_000,
    },
  ],
  private: [],
  public: [],
  draft: [],
  archive: [],
};
