import { IsString, IsOptional, IsBoolean, IsNumber, IsArray, IsObject, MaxLength, MinLength, IsUUID } from 'class-validator';

export class CreateProfileDto {
  @IsString()
  @MinLength(2)
  @MaxLength(10)
  code: string;

  @IsString()
  @MinLength(2)
  @MaxLength(100)
  name: string;

  @IsOptional()
  @IsString()
  description?: string;

  @IsOptional()
  @IsBoolean()
  isSystem?: boolean;

  @IsOptional()
  @IsString()
  @MaxLength(20)
  color?: string;

  @IsOptional()
  @IsString()
  @MaxLength(50)
  icon?: string;

  @IsOptional()
  @IsArray()
  @IsString({ each: true })
  basePermissions?: string[];

  @IsOptional()
  @IsArray()
  @IsString({ each: true })
  availableModules?: string[];

  @IsOptional()
  @IsNumber()
  monthlyPrice?: number;

  @IsOptional()
  @IsArray()
  @IsString({ each: true })
  includedPlatforms?: string[];

  @IsOptional()
  @IsArray()
  @IsString({ each: true })
  defaultTools?: string[];

  @IsOptional()
  @IsObject()
  featureFlags?: Record<string, boolean>;
}

export class UpdateProfileDto {
  @IsOptional()
  @IsString()
  @MinLength(2)
  @MaxLength(100)
  name?: string;

  @IsOptional()
  @IsString()
  description?: string;

  @IsOptional()
  @IsString()
  @MaxLength(20)
  color?: string;

  @IsOptional()
  @IsString()
  @MaxLength(50)
  icon?: string;

  @IsOptional()
  @IsArray()
  @IsString({ each: true })
  basePermissions?: string[];

  @IsOptional()
  @IsArray()
  @IsString({ each: true })
  availableModules?: string[];

  @IsOptional()
  @IsNumber()
  monthlyPrice?: number;

  @IsOptional()
  @IsArray()
  @IsString({ each: true })
  includedPlatforms?: string[];

  @IsOptional()
  @IsArray()
  @IsString({ each: true })
  defaultTools?: string[];

  @IsOptional()
  @IsObject()
  featureFlags?: Record<string, boolean>;
}

export class AssignProfileDto {
  @IsUUID()
  userId: string;

  @IsUUID()
  profileId: string;

  @IsOptional()
  @IsBoolean()
  isPrimary?: boolean;

  @IsOptional()
  @IsString()
  expiresAt?: string;
}

export class CreateProfileToolDto {
  @IsString()
  @MaxLength(50)
  toolCode: string;

  @IsString()
  @MaxLength(100)
  toolName: string;

  @IsOptional()
  @IsString()
  description?: string;

  @IsOptional()
  @IsString()
  @MaxLength(50)
  category?: string;

  @IsOptional()
  @IsBoolean()
  isMobileOnly?: boolean;

  @IsOptional()
  @IsBoolean()
  isWebOnly?: boolean;

  @IsOptional()
  @IsString()
  @MaxLength(50)
  icon?: string;

  @IsOptional()
  @IsObject()
  configuration?: Record<string, any>;

  @IsOptional()
  @IsNumber()
  sortOrder?: number;
}
