/**
 * Type declarations for @vreden/youtube_scraper
 * YouTube video downloader for audio and video formats
 */

declare module "@vreden/youtube_scraper" {
  // Metadata types
  export interface VredenAuthor {
    name?: string;
    url?: string;
  }

  export interface VredenDuration {
    seconds: number;
    timestamp: string;
  }

  export interface VredenMetadata {
    type?: "video";
    videoId?: string;
    url?: string;
    title?: string;
    description?: string;
    image?: string;
    thumbnail?: string;
    seconds?: number;
    timestamp?: string;
    duration?: VredenDuration;
    ago?: string;
    views?: number;
    author?: VredenAuthor;
  }

  // Download types
  export interface VredenDownload {
    status?: boolean;
    quality?: string;
    availableQuality?: number[];
    url?: string;
    filename?: string;
  }

  // Result type
  export interface VredenYoutubeResult {
    status?: boolean;
    creator?: string;
    metadata?: VredenMetadata;
    download?: VredenDownload;
  }

  // Channel metadata types
  export interface VredenChannelThumbnail {
    quality?: string;
    url?: string;
    width?: number;
    height?: number;
  }

  export interface VredenChannelStatistics {
    view?: string;
    video?: string;
    subscriber?: string;
  }

  export interface VredenChannelResult {
    id?: string;
    title?: string;
    description?: string;
    username?: string;
    thumbnails?: VredenChannelThumbnail[];
    banner?: string;
    published_date?: string;
    published_format?: string;
    statistics?: VredenChannelStatistics;
  }

  // Search result types
  export interface VredenSearchResult {
    type?: "video" | "channel" | "playlist";
    videoId?: string;
    title?: string;
    description?: string;
    thumbnail?: string;
    duration?: string;
    views?: number;
    author?: VredenAuthor;
    url?: string;
  }

  /**
   * Download YouTube audio as MP3
   * @param link - YouTube URL or video ID
   * @param quality - Audio quality in kbps (92, 128, 256, 320)
   */
  export function ytmp3(
    link: string,
    quality?: 92 | 128 | 256 | 320
  ): Promise<VredenYoutubeResult>;

  /**
   * Download YouTube video as MP4
   * @param link - YouTube URL or video ID
   * @param quality - Video quality in pixels (144, 360, 480, 720, 1080)
   */
  export function ytmp4(
    link: string,
    quality?: 144 | 360 | 480 | 720 | 1080
  ): Promise<VredenYoutubeResult>;

  /**
   * Alternative MP3 downloader using api.vreden.my.id
   * @param link - YouTube URL or video ID
   * @param quality - Audio quality in kbps (92, 128, 256, 320)
   */
  export function apimp3(
    link: string,
    quality?: 92 | 128 | 256 | 320
  ): Promise<VredenYoutubeResult>;

  /**
   * Alternative MP4 downloader using api.vreden.my.id
   * @param link - YouTube URL or video ID
   * @param quality - Video quality in pixels (144, 360, 480, 720, 1080)
   */
  export function apimp4(
    link: string,
    quality?: 144 | 360 | 480 | 720 | 1080
  ): Promise<VredenYoutubeResult>;

  /**
   * Search YouTube for videos, channels, and playlists
   * @param query - Search query string
   */
  export function search(query: string): Promise<VredenSearchResult[]>;

  /**
   * Fetch detailed video metadata
   * @param link - YouTube video URL or ID
   */
  export function metadata(link: string): Promise<VredenMetadata>;

  /**
   * Fetch channel metadata
   * @param usernameOrUrl - YouTube channel URL or username (@handle or custom URL)
   */
  export function channel(usernameOrUrl: string): Promise<VredenChannelResult>;
}