/**
 * Types pour la feature Playlists
 * T0451: Structure de base pour les playlists
 * INT-TYPE-005: PlaylistVisibility enum aligned with backend
 * INT-CLEANUP-002: Import Track from tracks/types instead of duplicating
 */

// INT-CLEANUP-002: Import Track from tracks/types instead of duplicating
import type { Track } from '@/features/tracks/types/track';

// Re-export for backward compatibility
export type { Track };

/**
 * PlaylistVisibility enum - aligned with backend visibility concept
 * Backend currently uses is_public (bool), but enum supports future 'unlisted' value
 * Values: 'public', 'private', 'unlisted'
 */
export enum PlaylistVisibility {
  Public = 'public',
  Private = 'private',
  Unlisted = 'unlisted',
}

/**
 * Interface représentant une playlist
 * INT-TYPE-003: Playlist.id is UUID (string) from backend - always string
 */
export interface Playlist {
  // UUID from backend - always string
  id: string;
  // UUID from backend - always string
  user_id: string;
  title: string;
  description?: string;
  // INT-TYPE-005: Use PlaylistVisibility enum (maps to backend is_public for now)
  visibility?: PlaylistVisibility;
  // Legacy: keep is_public for backward compatibility with backend
  is_public: boolean;
  cover_url?: string;
  track_count: number;
  created_at: string;
  updated_at: string;
  tracks?: PlaylistTrack[];
  user?: {
    id: string;
    username: string;
    avatar_url?: string;
  };
}

/**
 * Interface représentant un track dans une playlist
 * INT-TYPE-003: All IDs are UUID (string) from backend - always string
 */
export interface PlaylistTrack {
  // UUID from backend - always string
  id: string;
  // UUID from backend - always string
  playlist_id: string;
  // UUID from backend - always string
  track_id: string;
  position: number;
  added_at: string;
  track?: Track;
}

/**
 * Requête pour créer une playlist
 */
export interface CreatePlaylistRequest {
  title: string;
  description?: string;
  is_public?: boolean;
  cover_url?: string;
}

/**
 * Requête pour mettre à jour une playlist
 */
export interface UpdatePlaylistRequest {
  title?: string;
  description?: string;
  is_public?: boolean;
  cover_url?: string;
}

/**
 * Réponse de liste de playlists avec pagination
 */
export interface PlaylistListResponse {
  playlists: Playlist[];
  total: number;
  page: number;
  limit: number;
}
