import { NativeModules } from 'react-native';
import languages from './languages/mlkitSupportedLanguages.json';

const { GoogleMlkitTranslate } = NativeModules;

type SupportedLanguages = typeof languages;

interface GoogleMlkitTranslateType {
  supportedLanguages: SupportedLanguages;
  translate(
    text: string,
    sourceLanguage: string,
    targetLanguage: string,
    requireWifiToDownloadModel?: boolean
  ): Promise<string>;
  translateMany(
    texts: string[],
    sourceLanguage: string,
    targetLanguage: string,
    requireWifiToDownloadModel?: boolean
  ): Promise<string[]>;
  // getDownloadedModels(): Promise<string[]>;
  // deleteDownloadedModel(languageCode: string): Promise<void>;
  // downloadModel(languageCode: string, requireWifi?: boolean): Promise<void>;
}

export default {
  supportedLanguages: languages,
  translate(
    text: string,
    sourceLanguage: string,
    targetLanguage: string,
    requireWifiToDownloadModel = true
  ): Promise<string> {
    return GoogleMlkitTranslate.translate(
      text,
      sourceLanguage,
      targetLanguage,
      requireWifiToDownloadModel
    );
  },
  translateMany(
    texts: string[],
    sourceLanguage: string,
    targetLanguage: string,
    requireWifiToDownloadModel = true
  ): Promise<string[]> {
    return GoogleMlkitTranslate.translateMany(
      texts,
      sourceLanguage,
      targetLanguage,
      requireWifiToDownloadModel
    );
  },
  // getDownloadedModels: GoogleMlkitTranslate.getDownloadedModels,
  // deleteDownloadedModel: GoogleMlkitTranslate.deleteDownloadedModel,
  // downloadModel(
  //   languageCode: string,
  //   requireWifi: boolean = true
  // ): Promise<void> {
  //   return GoogleMlkitTranslate.downloadModel(languageCode, requireWifi);
  // },
} as GoogleMlkitTranslateType;
