import api from './client'

export interface OutputType {
  id: string
  name: string
  description: string | null
  renderer: string
  render_settings: Record<string, unknown>
  output_format: string
  sort_order: number
  compatible_categories: string[]
  render_backend: string
  is_animation: boolean
  transparent_bg: boolean
  cycles_device: string | null
  pricing_tier_id: number | null
  pricing_tier_name: string | null
  price_per_item: number | null
  workflow_definition_id: string | null
  is_active: boolean
  created_at: string
  updated_at: string
}

export async function listOutputTypes(
  includeInactive = false,
  category?: string,
): Promise<OutputType[]> {
  const params: Record<string, unknown> = { include_inactive: includeInactive }
  if (category) params.category = category
  const res = await api.get<OutputType[]>('/output-types', { params })
  return res.data
}

export async function createOutputType(data: Partial<OutputType>): Promise<OutputType> {
  const res = await api.post<OutputType>('/output-types', data)
  return res.data
}

export async function updateOutputType(id: string, data: Partial<OutputType>): Promise<OutputType> {
  const res = await api.patch<OutputType>(`/output-types/${id}`, data)
  return res.data
}

export async function deleteOutputType(id: string): Promise<void> {
  await api.delete(`/output-types/${id}`)
}
