import type { ThreadsAccountData } from '../types/api'

export function threadsAccountLabel(account: ThreadsAccountData | null | undefined) {
  if (!account) return '選擇帳號'
  const name = account.display_name?.trim()
  if (name) return name
  const username = account.username?.trim()
  if (username) return `@${username.replace(/^@/, '')}`
  return '未命名帳號'
}

export function threadsAccountConnected(account: ThreadsAccountData | null | undefined) {
  return Boolean(account?.browser_connected || account?.api_connected)
}

export function threadsAccountStatusLabel(account: ThreadsAccountData | null | undefined) {
  if (!account) return '新增或選擇帳號'
  const parts: string[] = []
  if (account.browser_connected) parts.push('已同步')
  if (account.api_connected) parts.push('API')
  return parts.length ? parts.join(' · ') : '尚未連線'
}