import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { AlertSeverity, CheckStatus, MonitoringCheckType } from '../enums/website-monitoring.enum';
import { BreachCheckWebsiteResponseDto } from './breach-check-website-response.dto';

export class BreachCheckResultResponseDto {
  @ApiProperty({
    description: 'Result ID',
    example: 1,
  })
  id: number;

  @ApiProperty({
    description: 'Website ID',
    example: 1,
  })
  websiteId: number;

  @ApiProperty({
    description: 'Type of monitoring check performed',
    enum: MonitoringCheckType,
    example: MonitoringCheckType.CONTENT_CHANGE,
  })
  checkType: MonitoringCheckType;

  @ApiProperty({
    description: 'Timestamp when the check was performed',
    example: '2024-01-01T00:00:00.000Z',
  })
  timestamp: Date;

  @ApiProperty({
    description: 'Status of the check result',
    enum: CheckStatus,
    example: CheckStatus.PASS,
  })
  status: CheckStatus;

  @ApiProperty({
    description: 'Severity level of the check result',
    enum: AlertSeverity,
    example: AlertSeverity.INFO,
  })
  severity: AlertSeverity;

  @ApiPropertyOptional({
    description: 'Detailed information about the check result',
    example: {
      changedElements: ['title', 'header'],
      previousHash: 'abc123...',
      currentHash: 'def456...',
      confidence: 0.95,
    },
  })
  details?: Record<string, any>;

  @ApiPropertyOptional({
    description: 'Raw data from the check',
  })
  rawData?: string;

  @ApiProperty({
    description: 'Whether an alert was generated',
    example: false,
  })
  alertGenerated: boolean;

  @ApiPropertyOptional({
    description: 'Response time in milliseconds',
    example: 250,
  })
  responseTimeMs?: number;

  @ApiPropertyOptional({
    description: 'Associated website',
    type: () => BreachCheckWebsiteResponseDto,
  })
  website?: BreachCheckWebsiteResponseDto;
}

export class BreachCheckResultListResponseDto {
  @ApiProperty({
    description: 'Array of breach check results',
    type: [BreachCheckResultResponseDto],
  })
  results: BreachCheckResultResponseDto[];

  @ApiProperty({
    description: 'Total number of results',
    example: 150,
  })
  total: number;

  @ApiProperty({
    description: 'Current page number',
    example: 1,
  })
  page: number;

  @ApiProperty({
    description: 'Number of items per page',
    example: 20,
  })
  limit: number;

  @ApiProperty({
    description: 'Total number of pages',
    example: 8,
  })
  totalPages: number;

  @ApiProperty({
    description: 'Whether there is a next page',
    example: true,
  })
  hasNext: boolean;

  @ApiProperty({
    description: 'Whether there is a previous page',
    example: false,
  })
  hasPrev: boolean;
}
