import { IsIn, IsObject, IsOptional, IsString } from 'class-validator';

const PRIORITIES = ['P0', 'P1', 'P2', 'P3', 'P4'] as const;
const STATES = ['NEW', 'OPEN', 'PENDING_CUSTOMER', 'PENDING_INTERNAL', 'RESOLVED', 'CLOSED', 'CANCELLED'] as const;

export class CreateTicketDto {
  @IsString() subject!: string;
  @IsOptional() @IsIn(PRIORITIES) priority?: (typeof PRIORITIES)[number];
  @IsOptional() @IsString() threadId?: string;
  /** Opaque, app-supplied attribute bag — stored on the ticket, never interpreted by the kernel. */
  @IsOptional() @IsObject() metadata?: Record<string, unknown>;
}

export class EscalateDto {
  @IsString() threadId!: string;
  @IsOptional() @IsString() subject?: string;
  @IsOptional() @IsObject() metadata?: Record<string, unknown>;
}

export class AssignTicketDto {
  @IsString() userId!: string;
}

export class PatchTicketDto {
  @IsIn(STATES) state!: (typeof STATES)[number];
  @IsOptional() @IsString() reason?: string;
}

export class CallbackDto {
  @IsString() preferChannel!: string;
  @IsOptional() @IsString() preferredTime?: string;
  @IsOptional() @IsString() notes?: string;
  @IsOptional() @IsString() ticketId?: string;
}

export class CreateQueueDto {
  @IsString() name!: string;
}

export class AvailabilityDto {
  @IsString() state!: string;
}
