import type { PlatformType } from '../types/platform.js';

/**
 * 平台信息
 */
export interface PlatformInfo {
  type: PlatformType;
  name: string;
  nameEn: string;
  icon: string;
  color: string;
  loginUrl: string;
  creatorUrl: string;
  maxTitleLength: number;
  maxDescriptionLength: number;
  maxTags: number;
  supportedVideoFormats: string[];
  maxVideoSize: number; // MB
  maxVideoDuration: number; // 秒
  /** 是否已适配支持 */
  supported: boolean;
}

/**
 * 所有支持的平台
 */
export const PLATFORMS: Record<PlatformType, PlatformInfo> = {
  douyin: {
    type: 'douyin',
    name: '抖音',
    nameEn: 'Douyin',
    icon: 'douyin',
    color: '#000000',
    loginUrl: 'https://creator.douyin.com/',
    creatorUrl: 'https://creator.douyin.com/',
    maxTitleLength: 55,
    maxDescriptionLength: 1000,
    maxTags: 5,
    supportedVideoFormats: ['mp4', 'mov'],
    maxVideoSize: 4096,
    maxVideoDuration: 900,
    supported: true,
  },
  kuaishou: {
    type: 'kuaishou',
    name: '快手',
    nameEn: 'Kuaishou',
    icon: 'kuaishou',
    color: '#FF4906',
    loginUrl: 'https://cp.kuaishou.com/',
    creatorUrl: 'https://cp.kuaishou.com/',
    maxTitleLength: 50,
    maxDescriptionLength: 500,
    maxTags: 10,
    supportedVideoFormats: ['mp4', 'mov'],
    maxVideoSize: 4096,
    maxVideoDuration: 600,
    supported: false,
  },
  weixin_video: {
    type: 'weixin_video',
    name: '视频号',
    nameEn: 'WeChat Channels',
    icon: 'weixin',
    color: '#07C160',
    loginUrl: 'https://channels.weixin.qq.com/platform/login',
    creatorUrl: 'https://channels.weixin.qq.com/platform',
    maxTitleLength: 30,
    maxDescriptionLength: 1000,
    maxTags: 5,
    supportedVideoFormats: ['mp4'],
    maxVideoSize: 1024,
    maxVideoDuration: 1800,
    supported: true,
  },
  xiaohongshu: {
    type: 'xiaohongshu',
    name: '小红书',
    nameEn: 'Xiaohongshu',
    icon: 'xiaohongshu',
    color: '#FE2C55',
    loginUrl: 'https://creator.xiaohongshu.com/',
    creatorUrl: 'https://creator.xiaohongshu.com/',
    maxTitleLength: 20,
    maxDescriptionLength: 1000,
    maxTags: 10,
    supportedVideoFormats: ['mp4', 'mov'],
    maxVideoSize: 1024,
    maxVideoDuration: 900,
    supported: true,
  },
  bilibili: {
    type: 'bilibili',
    name: 'B站',
    nameEn: 'Bilibili',
    icon: 'bilibili',
    color: '#00A1D6',
    loginUrl: 'https://member.bilibili.com/',
    creatorUrl: 'https://member.bilibili.com/platform/home',
    maxTitleLength: 80,
    maxDescriptionLength: 2000,
    maxTags: 12,
    supportedVideoFormats: ['mp4', 'flv'],
    maxVideoSize: 8192,
    maxVideoDuration: 14400,
    supported: false,
  },
  toutiao: {
    type: 'toutiao',
    name: '头条号',
    nameEn: 'Toutiao',
    icon: 'toutiao',
    color: '#F85959',
    loginUrl: 'https://mp.toutiao.com/',
    creatorUrl: 'https://mp.toutiao.com/',
    maxTitleLength: 30,
    maxDescriptionLength: 500,
    maxTags: 5,
    supportedVideoFormats: ['mp4'],
    maxVideoSize: 4096,
    maxVideoDuration: 1800,
    supported: false,
  },
  baijiahao: {
    type: 'baijiahao',
    name: '百家号',
    nameEn: 'Baijiahao',
    icon: 'baidu',
    color: '#2932E1',
    loginUrl: 'https://baijiahao.baidu.com/builder/theme/bjh/login',
    creatorUrl: 'https://baijiahao.baidu.com/builder/rc/home',
    maxTitleLength: 30,
    maxDescriptionLength: 500,
    maxTags: 10,
    supportedVideoFormats: ['mp4'],
    maxVideoSize: 4096,
    maxVideoDuration: 3600,
    supported: true,
  },
  qie: {
    type: 'qie',
    name: '企鹅号',
    nameEn: 'Qie',
    icon: 'qq',
    color: '#12B7F5',
    loginUrl: 'https://om.qq.com/',
    creatorUrl: 'https://om.qq.com/',
    maxTitleLength: 30,
    maxDescriptionLength: 300,
    maxTags: 10,
    supportedVideoFormats: ['mp4'],
    maxVideoSize: 4096,
    maxVideoDuration: 3600,
    supported: false,
  },
  dayuhao: {
    type: 'dayuhao',
    name: '大鱼号',
    nameEn: 'Dayuhao',
    icon: 'uc',
    color: '#FF6A00',
    loginUrl: 'https://mp.uc.cn/',
    creatorUrl: 'https://mp.uc.cn/',
    maxTitleLength: 30,
    maxDescriptionLength: 500,
    maxTags: 5,
    supportedVideoFormats: ['mp4'],
    maxVideoSize: 4096,
    maxVideoDuration: 3600,
    supported: false,
  },
};

/**
 * 平台类型列表
 */
export const PLATFORM_TYPES = Object.keys(PLATFORMS) as PlatformType[];

/**
 * 获取平台信息
 */
export function getPlatformInfo(platform: PlatformType): PlatformInfo {
  return PLATFORMS[platform];
}
