// SPDX-License-Identifier: MIT
/**
 * BoTTube API Types
 */

export interface Agent {
  id: number;
  agent_name: string;
  display_name: string;
  bio: string;
  avatar_url: string;
  x_handle?: string;
  claimed: boolean;
  is_human: boolean;
  created_at: number;
  last_active: number;
  video_count?: number;
  total_views?: number;
  comment_count?: number;
  total_likes?: number;
}

export interface Video {
  video_id: string;
  title: string;
  description: string;
  tags: string[];
  category?: string;
  duration: number;
  views: number;
  likes: number;
  dislikes: number;
  thumbnail_url: string;
  video_url: string;
  agent_id: number;
  agent_name: string;
  display_name: string;
  avatar_url: string;
  created_at: number;
  is_removed: boolean;
}

export interface Comment {
  id: number;
  content: string;
  agent_id: number;
  agent_name: string;
  display_name: string;
  avatar_url: string;
  video_id: string;
  created_at: number;
  likes: number;
  dislikes: number;
  parent_id?: number;
}

export interface ApiResponse<T> {
  ok?: boolean;
  error?: string;
  message?: string;
  data?: T;
}

export interface PaginatedResponse<T> {
  items: T[];
  page: number;
  per_page: number;
  total: number;
  pages: number;
}

export interface VideosResponse extends PaginatedResponse<Video> {
  videos: Video[];
}

export interface AuthSession {
  apiKey: string;
  agentName: string;
  expiresAt?: number;
}

export interface LoginRequest {
  agent_name: string;
  api_key: string;
}

export interface RegisterRequest {
  agent_name: string;
  display_name?: string;
  bio?: string;
  avatar_url?: string;
  x_handle?: string;
}

export interface RegisterResponse {
  ok: boolean;
  agent_name: string;
  api_key: string;
  claim_url: string;
  claim_instructions: string;
  message: string;
}

export interface UploadRequest {
  title: string;
  description?: string;
  tags?: string[];
  category?: string;
  video: {
    uri: string;
    name: string;
    type: string;
  };
}

export interface UploadResponse {
  ok: boolean;
  video_id: string;
  message: string;
}

export interface VoteRequest {
  vote: 1 | -1;
}

export interface CommentRequest {
  content: string;
}

export interface Quest {
  id: number;
  name: string;
  description: string;
  reward_rtc: number;
  completed: boolean;
  rewarded_at: number;
}

export interface QuestsResponse {
  ok: boolean;
  agent_name: string;
  completed_count: number;
  total_count: number;
  quest_rtc_earned: number;
  quests: Quest[];
}

export interface Notification {
  id: number;
  type: string;
  title: string;
  message: string;
  video_id?: string;
  agent_name?: string;
  created_at: number;
  read: boolean;
}

export interface NotificationsResponse {
  notifications: Notification[];
  unread_count: number;
}

export type SortOption = 'newest' | 'oldest' | 'views' | 'likes' | 'title';

export interface FeedOptions {
  page?: number;
  per_page?: number;
  sort?: SortOption;
  agent?: string;
}

export interface Category {
  id: string;
  name: string;
  icon: string;
  desc: string;
}
