import {
  IsString,
  IsOptional,
  IsEnum,
  IsUUID,
  IsArray,
  IsObject,
  IsInt,
  Min,
  IsDateString,
} from 'class-validator';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import {
  ContentType,
  ContentStatus,
  SocialPlatform,
} from '../entities/content-piece.entity';

export class CreateContentPieceDto {
  @ApiProperty({ description: 'Content title' })
  @IsString()
  title: string;

  @ApiProperty({ description: 'Project ID', format: 'uuid' })
  @IsUUID()
  project_id: string;

  @ApiPropertyOptional({ description: 'Assigned user ID', format: 'uuid' })
  @IsOptional()
  @IsUUID()
  assigned_to?: string;

  @ApiPropertyOptional({ enum: ContentType, default: ContentType.SOCIAL_POST })
  @IsOptional()
  @IsEnum(ContentType)
  type?: ContentType;

  @ApiPropertyOptional({ enum: ContentStatus, default: ContentStatus.IDEA })
  @IsOptional()
  @IsEnum(ContentStatus)
  status?: ContentStatus;

  @ApiPropertyOptional({ description: 'Target platforms', type: [String] })
  @IsOptional()
  @IsArray()
  @IsEnum(SocialPlatform, { each: true })
  platforms?: SocialPlatform[];

  @ApiPropertyOptional({ description: 'Content text' })
  @IsOptional()
  @IsString()
  content?: string;

  @ApiPropertyOptional({ description: 'Content HTML' })
  @IsOptional()
  @IsString()
  content_html?: string;

  @ApiPropertyOptional({ description: 'AI prompt used' })
  @IsOptional()
  @IsString()
  prompt_used?: string;

  @ApiPropertyOptional({ description: 'AI generation metadata' })
  @IsOptional()
  @IsObject()
  ai_metadata?: Record<string, any>;

  @ApiPropertyOptional({ description: 'Asset IDs', type: [String] })
  @IsOptional()
  @IsArray()
  @IsUUID('4', { each: true })
  asset_ids?: string[];

  @ApiPropertyOptional({ description: 'Call to action' })
  @IsOptional()
  @IsString()
  call_to_action?: string;

  @ApiPropertyOptional({ description: 'Hashtags', type: [String] })
  @IsOptional()
  @IsArray()
  @IsString({ each: true })
  hashtags?: string[];

  @ApiPropertyOptional({ description: 'Scheduled publication date' })
  @IsOptional()
  @IsDateString()
  scheduled_at?: string;

  @ApiPropertyOptional({ description: 'Tags', type: [String] })
  @IsOptional()
  @IsArray()
  @IsString({ each: true })
  tags?: string[];

  @ApiPropertyOptional({ description: 'Additional metadata' })
  @IsOptional()
  @IsObject()
  metadata?: Record<string, any>;
}
