import { api } from "@/lib/api-client";

export interface Avatar {
  id: number | string;
  name: string;
  thumbnail?: string;
  voice?: string;
  gender?: string;
}

export const mediaService = {
  generateListeningAudio(data: { text: string; voice_id?: string }): Promise<{ audio_url: string; audio_base64?: string; content_type?: string }> {
    return api.post("/exam/listening/media", data);
  },

  generateSpeakingAudio(data: { text: string; voice_id?: string }): Promise<{ audio_url: string; audio_base64?: string }> {
    return api.post("/exam/speaking/media", data);
  },

  getAvatars(): Promise<Avatar[]> {
    return api.get("/exam/avatars");
  },

  createAvatarVideo(data: { script: string; avatar_id: string; title?: string }): Promise<{ video_id: string; status: string }> {
    return api.post("/exam/avatar/video", data);
  },

  getVideoStatus(videoId: string): Promise<{ status: string; video_url?: string; progress?: number }> {
    return api.get(`/exam/avatar/video/${videoId}`);
  },
};
