import { ApiPropertyOptional } from '@nestjs/swagger';
import {
  IsOptional,
  IsArray,
  IsNumber,
  Min,
  Max,
  IsEnum,
  IsBoolean,
  IsDateString,
  IsString,
} from 'class-validator';

/**
 * Rate Search Filters DTO
 *
 * Advanced filters for narrowing down rate search results
 * All filters are optional
 */
export class RateSearchFiltersDto {
  @ApiPropertyOptional({
    description: 'List of company names to include in search',
    type: [String],
    example: ['SSC Consolidation', 'ECU Worldwide'],
  })
  @IsOptional()
  @IsArray()
  @IsString({ each: true })
  companies?: string[];

  @ApiPropertyOptional({
    description: 'Minimum volume in CBM (cubic meters)',
    minimum: 0,
    example: 1,
  })
  @IsOptional()
  @IsNumber()
  @Min(0)
  minVolumeCBM?: number;

  @ApiPropertyOptional({
    description: 'Maximum volume in CBM (cubic meters)',
    minimum: 0,
    example: 100,
  })
  @IsOptional()
  @IsNumber()
  @Min(0)
  maxVolumeCBM?: number;

  @ApiPropertyOptional({
    description: 'Minimum weight in kilograms',
    minimum: 0,
    example: 100,
  })
  @IsOptional()
  @IsNumber()
  @Min(0)
  minWeightKG?: number;

  @ApiPropertyOptional({
    description: 'Maximum weight in kilograms',
    minimum: 0,
    example: 15000,
  })
  @IsOptional()
  @IsNumber()
  @Min(0)
  maxWeightKG?: number;

  @ApiPropertyOptional({
    description: 'Exact number of pallets (0 means any)',
    minimum: 0,
    example: 10,
  })
  @IsOptional()
  @IsNumber()
  @Min(0)
  palletCount?: number;

  @ApiPropertyOptional({
    description: 'Minimum price in selected currency',
    minimum: 0,
    example: 1000,
  })
  @IsOptional()
  @IsNumber()
  @Min(0)
  minPrice?: number;

  @ApiPropertyOptional({
    description: 'Maximum price in selected currency',
    minimum: 0,
    example: 5000,
  })
  @IsOptional()
  @IsNumber()
  @Min(0)
  maxPrice?: number;

  @ApiPropertyOptional({
    description: 'Minimum transit time in days',
    minimum: 0,
    example: 20,
  })
  @IsOptional()
  @IsNumber()
  @Min(0)
  minTransitDays?: number;

  @ApiPropertyOptional({
    description: 'Maximum transit time in days',
    minimum: 0,
    example: 40,
  })
  @IsOptional()
  @IsNumber()
  @Min(0)
  maxTransitDays?: number;

  @ApiPropertyOptional({
    description: 'Container types to filter by',
    type: [String],
    example: ['LCL', '20DRY', '40HC'],
  })
  @IsOptional()
  @IsArray()
  @IsString({ each: true })
  containerTypes?: string[];

  @ApiPropertyOptional({
    description: 'Preferred currency for price filtering',
    enum: ['USD', 'EUR'],
    example: 'USD',
  })
  @IsOptional()
  @IsEnum(['USD', 'EUR'])
  currency?: 'USD' | 'EUR';

  @ApiPropertyOptional({
    description: 'Only show all-in prices (without separate surcharges)',
    example: false,
  })
  @IsOptional()
  @IsBoolean()
  onlyAllInPrices?: boolean;

  @ApiPropertyOptional({
    description: 'Departure date to check rate validity (ISO 8601)',
    example: '2025-06-15',
  })
  @IsOptional()
  @IsDateString()
  departureDate?: string;
}
