import { ApiProperty } from '@nestjs/swagger';
import { PublicGoodDto } from './public-good.dto';

export class PublicGoodDetailDto extends PublicGoodDto {
  @ApiProperty({ nullable: true })
  productCode!: string | null;

  @ApiProperty({ nullable: true })
  englishName!: string | null;

  @ApiProperty({ nullable: true })
  productionCycleHours!: number | null;

  @ApiProperty({ nullable: true })
  minWeightG!: string | null;

  @ApiProperty({ type: Object })
  details!: Record<string, string | null>;

  @ApiProperty({ nullable: true, type: Object })
  media!: Record<string, unknown> | null;

  @ApiProperty({ type: Array, description: 'Variant images grouped by color' })
  mediaByColor!: Array<{
    colorId: string | null;
    colorName: string | null;
    colorHex: string | null;
    images: string[];
  }>;

  @ApiProperty({ nullable: true, type: Object })
  options!: Record<string, unknown> | null;

  @ApiProperty({ nullable: true, type: Object })
  sizeChart!: Record<string, unknown> | null;

  @ApiProperty({ nullable: true, type: Object })
  packageSpecs!: Record<string, unknown> | null;

  @ApiProperty({ type: Array })
  variants!: Array<{
    id: string;
    sku: string;
    sizeId: string | null;
    sizeName: string | null;
    colorId: string | null;
    colorName: string | null;
    colorHex: string | null;
    imageUrl: string | null;
    price: string | null;
    originalPrice: string | null;
    weightG: string | null;
    boxLengthCm: string | null;
    boxWidthCm: string | null;
    boxHeightCm: string | null;
    enabled: boolean;
    sortOrder: number;
  }>;

  @ApiProperty({ nullable: true })
  detailSyncedAt!: string | null;

  /** 灰度字段：PUBLIC_DETAIL_FROM_FAMILY=true 且主链接有所属族时输出，否则完全不含该键 */
  @ApiProperty({
    required: false,
    nullable: true,
    type: Object,
    description: '产品族块：并集尺码表/包装规则 + 五维价格矩阵（尺码×颜色×印花数量×工艺×物流）',
  })
  family?: {
    familyId: string;
    familyCode: string | null;
    familyName: string;
    sizes: Array<{ key: string; name: string | null }>;
    colors: Array<{ key: string; name: string | null; hex: string | null; imageUrl: string | null }>;
    printCounts: string[];
    crafts: string[];
    logistics: string[];
    sizeChart: Record<string, unknown> | null;
    packageSpecs: Record<string, unknown> | null;
    priceMatrix: Record<string, unknown>;
    minPrice: string | null;
  } | null;
}

export class PublicTagGroupFilterDto {
  @ApiProperty()
  id!: string;

  @ApiProperty()
  groupName!: string;

  @ApiProperty({ nullable: true })
  groupIcon!: string | null;

  @ApiProperty({ nullable: true })
  groupColor!: string | null;

  @ApiProperty()
  sortOrder!: number;

  @ApiProperty({ type: Array })
  tags!: Array<{
    id: string;
    tagName: string;
    tagColor: string | null;
    tagFontColor: string | null;
    sortOrder: number;
    productCount: number;
  }>;
}
