import type { Song, ApiResponse, PaginatedData } from "./types";

// 歌曲API响应类型
export type CardSongResponse = ApiResponse<PaginatedData<CardSong>>;

// 歌曲卡片类型
export interface CardSong {
  id: number;
  name: string;
  category: string;
  category_display: string;
  description: string;
  card_type: string;
  card_type_display: string;
  rarity: string;
  rarity_display: string;
  image: string | null;
  image_url: string | null;
  model_url: string | null;
  model_version: string | null;
  status: string;
  status_display: string;
  published_at: string;
  price: string;
  created_at: string;
  updated_at: string;
  batches_count: number;
  cards_count: number;
  active_cards_count: number;
  attributes: {
    genre?: string;
    duration?: string;
    bpm?: number;
    composer?: string;
    lyricist?: string;
    arrangement?: string;
    audio_file?: string;
    lyrics?: string;
  };
}

// 歌曲详情API响应类型
export type CardSongDetailResponse = ApiResponse<CardSongDetail>;

// 歌曲详情类型
export interface CardSongDetail {
  id: number;
  name: string;
  category: string;
  category_display: string;
  description: string;
  card_type: string;
  card_type_display: string;
  rarity: string;
  rarity_display: string;
  image: string | null;
  image_url: string | null;
  model_url: string | null;
  model_version: string | null;
  status: string;
  status_display: string;
  published_at: string;
  price: string;
  created_at: string;
  updated_at: string;
  batches_count: number;
  cards_count: number;
  active_cards_count: number;
  attributes: {
    genre?: string;
    duration?: string;
    bpm?: number;
    composer?: string;
    lyricist?: string;
    arrangement?: string;
    audio_file?: string;
    lyrics?: string;
  };
}

// 批次类型
export interface SongBatch {
  id: number;
  batch_number: string;
  template: number;
  template_name: string;
  category: string;
  category_display: string;
  quantity: number;
  description: string;
  status: string;
  status_display: string;
  exported: boolean;
  exported_at: string | null;
  excel_file: string | null;
  excel_file_url: string | null;
  sent_to_production: boolean;
  production_date: string | null;
  published: boolean;
  published_at: string | null;
  created_at: string;
  updated_at: string;
  start_id: string;
  end_id: string;
}

// 批次响应类型
export type SongBatchesResponse = ApiResponse<PaginatedData<SongBatch>>;

// 创建歌曲批次请求
export interface CreateBatchRequest {
  template: number;
  quantity: number;
}

// 创建批次响应
export interface CreateBatchResponseData {
  batch: SongBatch;
  cards_count: number;
}

export type CreateBatchResponse = ApiResponse<CreateBatchResponseData>;

// 批次生产状态响应
export interface MarkBatchAsProducedResponseData {
  batch: SongBatch;
}

export type MarkBatchAsProducedResponse = ApiResponse<MarkBatchAsProducedResponseData>;

// 歌曲创建请求类型
export interface CreateSongRequest {
  name: string;
  category: string;
  card_type?: string;
  rarity: string;
  price: number;
  status: string;
  description?: string;
  image?: string | null;
  song_attributes: {
    genre?: string;
    duration?: string;
    bpm?: number;
    composer?: string;
    lyricist?: string;
    arrangement?: string;
    audio_file?: string;
    lyrics?: string;
  };
}

// 歌曲更新请求类型
export interface UpdateSongRequest {
  name?: string;
  category?: string;
  card_type?: string;
  rarity?: string;
  price?: number;
  status?: string;
  description?: string;
  song_attributes?: {
    genre?: string;
    duration?: string;
    bpm?: number;
    composer?: string;
    lyricist?: string;
    arrangement?: string;
    audio_file?: string;
    lyrics?: string;
  };
}

// 歌曲发布响应数据
export interface PublishSongResponseData {
  template: CardSongDetail;
}

export type PublishSongResponse = ApiResponse<PublishSongResponseData>;

// 歌曲文件上传响应
export interface UploadSongFileResponse {
  url: string;
  key: string;
  is_permanent: boolean;
}

// 歌曲文件上传请求
export interface UploadSongFileRequest {
  file: File;
  isPermanent?: boolean;
  filename?: string;
} 