import type { ResearchMapData } from './brand'

export interface PlacementTopicData {
  id: string
  brand_id: string
  brand_display_name?: string
  topic_name?: string
  seed_query?: string
  brief?: string
  product_id?: string
  research_map?: ResearchMapData
  create_at: number
  update_at: number
}

export interface ListPlacementTopicsData {
  list: PlacementTopicData[]
}

export interface CreatePlacementTopicData {
  topic: PlacementTopicData
  job_id: string
  status: string
  message?: string
}

export function hasResearchMap(topic: PlacementTopicData | null | undefined): boolean {
  const map = topic?.research_map
  if (!map) return false
  return Boolean(
    map.audience_summary?.trim() ||
      map.content_goal?.trim() ||
      (map.questions?.length ?? 0) > 0 ||
      (map.pillars?.length ?? 0) > 0 ||
      (map.research_items?.length ?? 0) > 0 ||
      (map.patrol_keywords?.length ?? 0) > 0,
  )
}