export type VideoPointType = 'purpose' | 'key' | 'inspiration' | string

export type FeedbackTargetType = 'demand' | 'video' | 'hit_content'
export type FeedbackAction = 'support' | 'oppose' | 'correct' | 'supplement'

export interface FeedbackSummary {
  count: number
}

export interface VideoDiscoveryDemand {
  id: number
  demand_name: string
  biz_dt: string
  grade: string
  score: number | null
  prior_total_score: number | null
  posterior_rov_avg: number | null
  posterior_rov_count: number
  has_posterior: boolean
  category_ids: number[]
  category_names: string[]
  strategies: string[]
  reason: string | null
  video_count: number
  feedback_summary: FeedbackSummary
}

export interface VideoDiscoveryPoint {
  id: number
  point_type: VideoPointType
  expanded_text: string
  point_desc: string | null
  reason: string
  feedback_summary: FeedbackSummary
}

export interface VideoDiscoveryVideo {
  vid: string
  title: string | null
  url1: string | null
  url2: string | null
  video_detail_url: string | null
  point_count: number
  points: VideoDiscoveryPoint[]
  feedback_summary: FeedbackSummary
}

export interface VideoDiscoveryDemandDetail extends VideoDiscoveryDemand {
  point_count: number
  video_source: 'pool' | 'expansion'
  videos: VideoDiscoveryVideo[]
}

export interface VideoDiscoveryDemandResponse {
  biz_dt: string | null
  items: VideoDiscoveryDemand[]
}

export interface DemandFeedbackTarget {
  target_type: FeedbackTargetType
  demand_grade_id: number
  video_id?: string
  demand_video_expansion_id?: number
  title: string
  context: Array<{ label: string; value: string }>
  feedback_summary: FeedbackSummary
}

export interface DemandFeedbackItem {
  id: number
  target_type: FeedbackTargetType
  biz_dt: string
  demand_grade_id: number
  video_id: string | null
  demand_video_expansion_id: number | null
  feedback_action: FeedbackAction
  reason_code: string | null
  content: string | null
  target_snapshot: Record<string, unknown>
  feedback_user: {
    id: number
    username: string
    display_name: string
  }
  created_at: string | null
}

export interface DemandFeedbackHistoryResponse {
  items: DemandFeedbackItem[]
  total: number
  limit: number
  offset: number
}

export interface CreateDemandFeedbackInput {
  client_request_id: string
  target_type: FeedbackTargetType
  demand_grade_id: number
  video_id?: string
  demand_video_expansion_id?: number
  feedback_action: FeedbackAction
  reason_code?: string
  content?: string
}

export interface CreateDemandFeedbackResponse {
  item: DemandFeedbackItem
  feedback_summary: FeedbackSummary
}
