// ── Entity Types ──────────────────────────────────────────────────────────────

export const ReviewEntityType = {
  FUTURE_SIGNAL:       'FUTURE_SIGNAL',
  MATCH_EXPLANATION:   'MATCH_EXPLANATION',
  LOW_CONFIDENCE_MATCH:'LOW_CONFIDENCE_MATCH',
  CONTACT_RELEASE:     'CONTACT_RELEASE',
  AI_OUTPUT:           'AI_OUTPUT',
  PROPERTY_DATA_ISSUE: 'PROPERTY_DATA_ISSUE',
} as const
export type ReviewEntityType = typeof ReviewEntityType[keyof typeof ReviewEntityType]

// ── Task Status ───────────────────────────────────────────────────────────────

export const ReviewTaskStatus = {
  PENDING:         'PENDING',
  IN_REVIEW:       'IN_REVIEW',
  APPROVED:        'APPROVED',
  REJECTED:        'REJECTED',
  NEEDS_MORE_DATA: 'NEEDS_MORE_DATA',
  ESCALATED:       'ESCALATED',
} as const
export type ReviewTaskStatus = typeof ReviewTaskStatus[keyof typeof ReviewTaskStatus]

// ── Priority ──────────────────────────────────────────────────────────────────

export const ReviewPriority = {
  LOW:      'LOW',
  MEDIUM:   'MEDIUM',
  HIGH:     'HIGH',
  CRITICAL: 'CRITICAL',
} as const
export type ReviewPriority = typeof ReviewPriority[keyof typeof ReviewPriority]

// ── Note ──────────────────────────────────────────────────────────────────────

export interface ReviewNote {
  id: string
  content: string
  createdBy: string
  createdAt: string
}

// ── Task ──────────────────────────────────────────────────────────────────────

export interface ReviewTask {
  id: string
  entityType: ReviewEntityType
  entityId: string
  title: string
  description?: string
  priority: ReviewPriority
  status: ReviewTaskStatus
  assignedTo?: string
  createdBy: string
  createdAt: string
  updatedAt: string
  dueDate?: string
  reviewNotes: ReviewNote[]
  relatedOrganizationId?: string
  // Risk / confidence context
  confidenceScore?: number
  riskLevel?: string
  // AI-output context
  promptVersion?: string
  // Legacy compat (match-based items)
  matchId?: string
  needId?: string
  propertyId?: string
  matchScore?: number
}

// ── Backward-compat aliases ───────────────────────────────────────────────────

export type ReviewQueueItem = ReviewTask
export type ReviewQueueStatus = ReviewTaskStatus

/** @deprecated use ReviewTaskStatus */
export const ReviewQueueStatus = ReviewTaskStatus
