import { ApiProperty } from "@nestjs/swagger";
import { IsNotEmpty, IsNumber, IsOptional, IsString } from "class-validator";

export class FilterSettingDto {

    @ApiProperty({ example: 'gpt-4o-mini', required: true, description: 'Model for user' })
    @IsOptional()
    @IsString({ message: 'Model for user must be a string' })
    modelForUser: string;

    @ApiProperty({ example: 'gpt-4o-mini', required: true, description: 'Model for admin' })
    @IsOptional()
    @IsString({ message: 'Model for admin must be a string' })
    modelForAdmin: string;

    @ApiProperty({ example: 0.2, required: true, description: 'Temperature for user' })
    @IsOptional()
    @IsNumber({}, { message: 'Temperature for user must be a number' })
    temperatureForUser: number;

    @ApiProperty({ example: 0.2, required: true, description: 'Temperature for admin' })
    @IsOptional()
    @IsNumber({}, { message: 'Temperature for admin must be a number' })
    temperatureForAdmin: number;



    @ApiProperty({ example: 'systemPromptForAdminEn', required: true, description: 'System prompt for admin in English' })
    @IsOptional()
    @IsString({ message: 'System prompt for admin in English must be a string' })
    systemPromptForAdminEn: string;


    @ApiProperty({ example: 'systemPromptForUserEn', required: true, description: 'System prompt for user in English' })
    @IsOptional()
    @IsString({ message: 'System prompt for user in English must be a string' })
    systemPromptForUserEn: string;

    @ApiProperty({ example: 'systemPromptForAdminHe', required: true, description: 'System prompt for admin in Hebrew' })   
    @IsOptional()
    @IsString({ message: 'System prompt for admin in Hebrew must be a string' })
    systemPromptForAdminHe: string;

    @ApiProperty({ example: 'systemPromptForUserHe', required: true, description: 'System prompt for user in Hebrew' })
    @IsOptional()
    @IsString({ message: 'System prompt for user in Hebrew must be a string' })
    systemPromptForUserHe: string;
}



export class ValidateFilterSettingDto {
    @ApiProperty({ type: String, required: true, description: 'Image URL', example: 'https://storage.googleapis.com/blocked-images/8b289f54-e81d-4708-8a28-9f456c151f3b.png' })
    @IsNotEmpty({ message: 'Image URL is required' })
    @IsString({ message: 'Image URL must be a string' })
    imageUrl: string;

    @ApiProperty({ type: String, required: true, description: 'GPT Model', example: 'gpt-4.1' })
    @IsNotEmpty({ message: 'GPT Model is required' })
    @IsString({ message: 'GPT Model must be a string' })
    model: string;

    @ApiProperty({ type: String, required: true, description: 'Temperature for GPT', example: 1 })
    @IsNotEmpty({ message: 'Temperature for GPT is required' })
    @IsNumber({}, { message: 'Temperature for GPT must be a number' })
    temperature: number;

    @ApiProperty({ type: String, required: true, description: 'System prompt for GPT', example: `{
        "task": "modesty_compliance_check",
        "image": "<IMAGE_URL_OR_BINARY>",
        "criteria": {
          "detect_females_over_age": 7,                  // Detect any female over age 7
          "detect_male_full_nudity": true,               // Detect fully nude males
          "detect_male_shirtless": true,                 // Detect shirtless males
          "detect_female_body_part": true                // Detect any visible female body part (waist, chest, legs, etc.)
        },
        "output_fields": [
          "is_female_over_7_present",
          "is_male_full_nudity_present",
          "is_shirtless_male_present",
          "is_female_body_part_present",
          "final_kosher_status",
          "error"
        ]
      }
      
      ## Output Format
      The output must be a JSON object with the following fields:
      
      {
        "is_female_over_7_present": <boolean>,         // True if a full female (with face) over 7 is detected
        "is_male_full_nudity_present": <boolean>,      // True if any fully nude male is detected
        "is_shirtless_male_present": <boolean>,        // True if any shirtless male is detected
        "is_female_body_part_present": <boolean>,      // True if any partial body part of a female over age 7 is detected (even without face)
        "final_kosher_status": <boolean>,              // False if any of the above are true
        "error": <string | null>                       // Null if no error, else descriptive error string
      }
      
      // Notes:
      // - final_kosher_status must be false if any of the following are true:
      //    - is_female_over_7_present
      //    - is_female_body_part_present
      //    - is_male_full_nudity_present
      //    - is_shirtless_male_present
      // - Only if all four are false should final_kosher_status be true.
      // - The error field must be null unless an error occurs.
      ` })
    @IsNotEmpty({ message: 'System prompt for GPT is required' })
    @IsString({ message: 'System prompt for GPT must be a string' })
    systemPrompt: string;
}