import { IsString, IsBoolean, IsOptional, IsIn, MinLength, MaxLength, IsInt } from 'class-validator';

export class CreateLegalPageDto {
  @IsString()
  @MinLength(2)
  @MaxLength(100)
  slug: string;

  @IsString()
  @MinLength(3)
  @MaxLength(255)
  title: string;

  @IsString()
  @MinLength(10)
  content: string;

  @IsString()
  @IsIn(['en', 'es', 'fr', 'pt', 'zh'])
  @IsOptional()
  language?: string = 'en';

  @IsBoolean()
  @IsOptional()
  isPublished?: boolean = false;
}

export class UpdateLegalPageDto {
  @IsString()
  @MinLength(3)
  @MaxLength(255)
  @IsOptional()
  title?: string;

  @IsString()
  @MinLength(10)
  @IsOptional()
  content?: string;

  @IsBoolean()
  @IsOptional()
  isPublished?: boolean;
}

export class PublishLegalPageDto {
  @IsBoolean()
  isPublished: boolean;
}

export class RevertToVersionDto {
  @IsInt()
  version: number;
}

export interface LegalPageListFilter {
  slug?: string;
  language?: string;
  isPublished?: boolean;
  search?: string;
}

export interface LegalPageResponse {
  id: string;
  slug: string;
  title: string;
  content: string;
  language: string;
  version: number;
  isPublished: boolean;
  lastUpdatedBy: string | null;
  createdAt: Date;
  updatedAt: Date;
}

export interface LegalPageVersionResponse {
  id: string;
  version: number;
  title: string;
  content: string;
  createdBy: string | null;
  createdAt: Date;
}
