export interface PsaConnectionResponse {
  id: string
  account_id: string
  provider: string
  display_name: string
  site_url: string
  company_id: string
  is_active: boolean
  last_validated_at: string | null
  created_at: string
  updated_at: string
  public_key_hint: string
  private_key_hint: string
}

export interface PsaConnectionCreate {
  provider: string
  display_name: string
  site_url: string
  company_id: string
  public_key: string
  private_key: string
}

export interface PsaConnectionUpdate {
  display_name?: string
  site_url?: string
  company_id?: string
  public_key?: string
  private_key?: string
}

export interface PsaConnectionTestResponse {
  success: boolean
  message: string
  server_version: string | null
}

export interface PSATicketInfo {
  id: string
  summary: string
  company_name: string | null
  board_name: string | null
  status_name: string | null
  priority_name: string | null
}

export interface TicketLinkResponse {
  session_id: string
  psa_ticket_id: string | null
  ticket: PSATicketInfo | null
}

export interface PSATicketSearchResult {
  id: string
  summary: string
  company_name: string | null
  board_name: string | null
  status_name: string | null
  priority_name: string | null
  closed: boolean
}

export interface PSATicketStatusItem {
  id: number
  name: string
  is_closed: boolean
}

export interface PsaPreviewResponse {
  content: string
  ticket: PSATicketSearchResult
  available_statuses: PSATicketStatusItem[]
  character_count: number
  previous_posts: number
}

export interface PsaPostResponse {
  id: string
  session_id: string
  ticket_id: string
  note_type: string
  status: string
  external_note_id: string | null
  error_message: string | null
  status_changed_from: string | null
  status_changed_to: string | null
  posted_at: string
}

export interface PsaPostLogEntry {
  id: string
  ticket_id: string
  note_type: string
  status: string
  error_message: string | null
  status_changed_from: string | null
  status_changed_to: string | null
  posted_at: string
  content_preview: string
}

export interface PsaMemberResponse {
  id: string
  identifier: string
  name: string
  email: string | null
}

export interface PsaMemberMappingResponse {
  id: string | null
  user_id: string
  user_email: string
  user_name: string
  external_member_id: string | null
  external_member_name: string | null
  matched_by: string | null
}

export interface AutoMatchResult {
  matched: PsaMemberMappingResponse[]
  unmatched_users: number
}

export interface FlowpilotSettings {
  auto_push: boolean
  auto_time_entry: boolean
  time_rounding: string  // "15min" | "30min" | "exact" | "none"
  note_visibility: string  // "internal" | "both"
  include_diagnostic_steps: boolean
  prompt_status_on_resolution: boolean
  prompt_status_on_escalation: boolean
}
