/**
 * Card Generator Configuration
 * 100%保持旧框架配置不变
 */

export interface BinInfo {
  bin?: string;
  extension?: string;
  fullPrefix?: string;
  weight?: number;
  issuer?: string;
  country?: string;
  allowPatterns?: boolean;
}

export interface CardTypeConfig {
  name: string;
  prefix?: string;
  prefixes?: BinInfo[];
  length: number;
  cvvLength: number;
  useLuhn: boolean;
  successfulPatterns?: string[];
  generation?: {
    mutationDigits?: [number, number];
  };
}

export const CARD_TYPES: Record<string, CardTypeConfig> = {
  unionpay: {
    name: '中国银联 (UnionPay)',
    // 农业银行622836开头的13位BIN（可生成6,500张）
    successfulPatterns: [
      // 原始基础数据（16张）
      '8127', '4196', '4577', '9496', '4005', '1058', '0809', '6490', '7194',
      '1288', '3748', '4235', '8483', '1070', '0063', '0548',
      // 今天通过的所有卡号后缀（54张）
      '5779', '4030', '8788', '1205', '0744', '8010', '0364', '4288', '2579',
      '1755', '3235', '4435', '0627', '5204', '3734', '6732', '0302', '7201',
      '7808', '2734', '0148', '0520', '3197', '0049', '1561', '4926', '7000',
      '2860', '1592', '2853', '4858', '2832', '3658', '6988', '3159', '8576',
      '0064', '3252', '3785', '9976', '0032', '8937', '0241', '0784', '6843',
      '2551', '7914', '7930', '1796', '2809', '1254', '7146', '8903', '4460'
    ],
    generation: {
      mutationDigits: [1, 2]  // 变异1-2位数字
    },
    prefixes: [
      { bin: '6228367540023', weight: 1, issuer: '中国农业银行', country: 'MO' },
      { bin: '6228367540057', weight: 1, issuer: '中国农业银行', country: 'MO' },
      { bin: '6228367540385', weight: 1, issuer: '中国农业银行', country: 'MO' },
      { bin: '6228367540707', weight: 1, issuer: '中国农业银行', country: 'MO' },
      { bin: '6228367540744', weight: 1, issuer: '中国农业银行', country: 'MO' },
      { bin: '6228367540810', weight: 1, issuer: '中国农业银行', country: 'MO' },
      { bin: '6228367540814', weight: 1, issuer: '中国农业银行', country: 'MO' },
      { bin: '6228367541130', weight: 1, issuer: '中国农业银行', country: 'MO' },
      { bin: '6228367541210', weight: 1, issuer: '中国农业银行', country: 'MO' },
      { bin: '6228367541299', weight: 1, issuer: '中国农业银行', country: 'MO' },
      { bin: '6228367541450', weight: 1, issuer: '中国农业银行', country: 'MO' },
      { bin: '6228367541880', weight: 1, issuer: '中国农业银行', country: 'MO' },
      { bin: '6228367542443', weight: 1, issuer: '中国农业银行', country: 'MO' },
      { bin: '6228367542464', weight: 1, issuer: '中国农业银行', country: 'MO' },
      { bin: '6228367542487', weight: 1, issuer: '中国农业银行', country: 'MO' },
      { bin: '6228367542602', weight: 1, issuer: '中国农业银行', country: 'MO' },
      { bin: '6228367542653', weight: 1, issuer: '中国农业银行', country: 'MO' },
      { bin: '6228367542738', weight: 1, issuer: '中国农业银行', country: 'MO' },
      { bin: '6228367542797', weight: 1, issuer: '中国农业银行', country: 'MO' },
      { bin: '6228367542940', weight: 1, issuer: '中国农业银行', country: 'MO' },
      { bin: '6228367543564', weight: 1, issuer: '中国农业银行', country: 'MO' },
      { bin: '6228367543770', weight: 1, issuer: '中国农业银行', country: 'MO' },
      { bin: '6228367543917', weight: 1, issuer: '中国农业银行', country: 'MO' },
      { bin: '6228367544252', weight: 1, issuer: '中国农业银行', country: 'MO' },
      { bin: '6228367544322', weight: 1, issuer: '中国农业银行', country: 'MO' },
      { bin: '6228367544445', weight: 1, issuer: '中国农业银行', country: 'MO' },
      { bin: '6228367544742', weight: 1, issuer: '中国农业银行', country: 'MO' },
      { bin: '6228367544873', weight: 1, issuer: '中国农业银行', country: 'MO' },
      { bin: '6228367545022', weight: 1, issuer: '中国农业银行', country: 'MO' },
      { bin: '6228367545055', weight: 1, issuer: '中国农业银行', country: 'MO' },
      { bin: '6228367545237', weight: 1, issuer: '中国农业银行', country: 'MO' },
      { bin: '6228367545452', weight: 1, issuer: '中国农业银行', country: 'MO' },
      { bin: '6228367545657', weight: 1, issuer: '中国农业银行', country: 'MO' },
      { bin: '6228367545800', weight: 1, issuer: '中国农业银行', country: 'MO' },
      { bin: '6228367545864', weight: 1, issuer: '中国农业银行', country: 'MO' },
      { bin: '6228367545956', weight: 1, issuer: '中国农业银行', country: 'MO' },
      { bin: '6228367545976', weight: 1, issuer: '中国农业银行', country: 'MO' },
      { bin: '6228367546042', weight: 1, issuer: '中国农业银行', country: 'MO' },
      { bin: '6228367546223', weight: 1, issuer: '中国农业银行', country: 'MO' },
      { bin: '6228367546361', weight: 1, issuer: '中国农业银行', country: 'MO' },
      { bin: '6228367546496', weight: 1, issuer: '中国农业银行', country: 'MO' },
      { bin: '6228367546781', weight: 1, issuer: '中国农业银行', country: 'MO' },
      { bin: '6228367546998', weight: 1, issuer: '中国农业银行', country: 'MO' },
      { bin: '6228367547093', weight: 1, issuer: '中国农业银行', country: 'MO' },
      { bin: '6228367547237', weight: 1, issuer: '中国农业银行', country: 'MO' },
      { bin: '6228367547238', weight: 1, issuer: '中国农业银行', country: 'MO' },
      { bin: '6228367547300', weight: 1, issuer: '中国农业银行', country: 'MO' },
      { bin: '6228367547416', weight: 1, issuer: '中国农业银行', country: 'MO' },
      { bin: '6228367547542', weight: 1, issuer: '中国农业银行', country: 'MO' },
      { bin: '6228367547562', weight: 1, issuer: '中国农业银行', country: 'MO' },
      { bin: '6228367547863', weight: 1, issuer: '中国农业银行', country: 'MO' },
      { bin: '6228367548160', weight: 1, issuer: '中国农业银行', country: 'MO' },
      { bin: '6228367548400', weight: 1, issuer: '中国农业银行', country: 'MO' },
      { bin: '6228367548435', weight: 1, issuer: '中国农业银行', country: 'MO' },
      { bin: '6228367548491', weight: 1, issuer: '中国农业银行', country: 'MO' },
      { bin: '6228367548575', weight: 1, issuer: '中国农业银行', country: 'MO' },
      { bin: '6228367548774', weight: 1, issuer: '中国农业银行', country: 'MO' },
      { bin: '6228367549031', weight: 1, issuer: '中国农业银行', country: 'MO' },
      { bin: '6228367549130', weight: 1, issuer: '中国农业银行', country: 'MO' },
      { bin: '6228367549131', weight: 1, issuer: '中国农业银行', country: 'MO' },
      { bin: '6228367549198', weight: 1, issuer: '中国农业银行', country: 'MO' },
      { bin: '6228367549574', weight: 1, issuer: '中国农业银行', country: 'MO' },
      { bin: '6228367549888', weight: 1, issuer: '中国农业银行', country: 'MO' },
      { bin: '6228367549976', weight: 1, issuer: '中国农业银行', country: 'MO' },
      { bin: '6228367586381', weight: 1, issuer: '中国农业银行', country: 'MO' }
    ],
    length: 16,
    cvvLength: 3,
    useLuhn: true
  },
  visa: {
    name: 'Visa',
    prefix: '4',
    length: 16,
    cvvLength: 3,
    useLuhn: true
  },
  mastercard: {
    name: 'MasterCard',
    prefix: '5',
    length: 16,
    cvvLength: 3,
    useLuhn: true
  },
  amex: {
    name: 'American Express',
    prefix: '34',
    length: 15,
    cvvLength: 4,
    useLuhn: true
  },
  discover: {
    name: 'Discover',
    prefix: '6011',
    length: 16,
    cvvLength: 3,
    useLuhn: true
  }
};

/**
 * 有效期配置
 */
export const EXPIRY_CONFIG = {
  minYear: 26,  // 2026
  maxYear: 30,  // 2030
  minMonth: 1,
  maxMonth: 12
};

/**
 * 输出格式配置
 */
export const OUTPUT_FORMATS = {
  pipe: {
    name: 'Pipe分隔 (|)',
    formatter: (card: any) => `${card.number}|${card.month}|${card.year}|${card.cvv}`
  },
  json: {
    name: 'JSON格式',
    formatter: (card: any) => JSON.stringify(card, null, 2)
  },
  csv: {
    name: 'CSV格式',
    formatter: (card: any) => `${card.number},${card.month},${card.year},${card.cvv}`
  },
  pretty: {
    name: '美化格式',
    formatter: (card: any) => `
Card Number: ${card.number}
Expiry Date: ${card.month}/${card.year}
CVV: ${card.cvv}
Type: ${card.type}
    `.trim()
  }
};
