import {
  IsArray,
  IsString,
  IsOptional,
  IsNotEmpty,
  IsNumber,
  IsEnum,
  ArrayMaxSize,
  Min,
  Max,
} from "class-validator";
import { ApiProperty, ApiPropertyOptional } from "@nestjs/swagger";

export enum CouponStrategyEnum {
  SAFE = "SAFE",
  BALANCED = "BALANCED",
  AGGRESSIVE = "AGGRESSIVE",
  VALUE = "VALUE",
  MIRACLE = "MIRACLE",
}

export class AnalyzeMatchDto {
  @ApiProperty({ description: "Match ID to analyze" })
  @IsString()
  @IsNotEmpty()
  matchId: string;
}

export class DailyBankoDto {
  @ApiPropertyOptional({
    description: "Optional match IDs — system fetches if empty",
    example: ["match-1", "match-2"],
  })
  @IsOptional()
  @IsArray()
  @IsString({ each: true })
  @ArrayMaxSize(50)
  matchIds?: string[];
}

export class SuggestCouponDto {
  @ApiPropertyOptional({
    description: "Match IDs — system fetches if empty",
    example: ["match-1", "match-2"],
  })
  @IsOptional()
  @IsArray()
  @IsString({ each: true })
  @ArrayMaxSize(50)
  matchIds?: string[];

  @ApiPropertyOptional({
    enum: CouponStrategyEnum,
    default: CouponStrategyEnum.BALANCED,
  })
  @IsOptional()
  @IsEnum(CouponStrategyEnum)
  strategy?: CouponStrategyEnum;

  @ApiPropertyOptional({ description: "Maximum matches in coupon", example: 5 })
  @IsOptional()
  @IsNumber()
  @Min(1)
  @Max(20)
  maxMatches?: number;

  @ApiPropertyOptional({
    description: "Minimum confidence threshold (0-100)",
    example: 60,
  })
  @IsOptional()
  @IsNumber()
  @Min(0)
  @Max(100)
  minConfidence?: number;
}

export class FrequencyCouponDto {
  @ApiPropertyOptional({
    description: "Optional match IDs — system auto-fetches if empty",
    example: ["match-1", "match-2"],
  })
  @IsOptional()
  @IsArray()
  @IsString({ each: true })
  @ArrayMaxSize(50)
  matchIds?: string[];

  @ApiPropertyOptional({
    description: "Maximum matches in parlay (2-5)",
    example: 3,
    default: 3,
  })
  @IsOptional()
  @IsNumber()
  @Min(2)
  @Max(5)
  maxMatches?: number;

  @ApiPropertyOptional({
    description: "Minimum combined signal threshold (0.50-0.99)",
    example: 0.7,
    default: 0.7,
  })
  @IsOptional()
  @IsNumber()
  @Min(0.5)
  @Max(0.99)
  minSignal?: number;

  @ApiPropertyOptional({
    description: "Filter markets: OU1.5, OU2.5, OU3.5, BTTS, MS (default: all)",
    example: ["OU2.5", "BTTS"],
  })
  @IsOptional()
  @IsArray()
  @IsString({ each: true })
  markets?: string[];
}
