import IUserDataStore from './IUserDataStore';
import {IndexedDB} from './IndexedDB';
import {LocalStorage} from './LocalStorage';
import {ObjectStrore} from './ObjectStore';

class UserDataStoreService {
  private static _instance: IUserDataStore;

  static {
    if (IndexedDB.isSupported()) {
      this._instance = new IndexedDB();
    } else if (LocalStorage.isSupported()) {
      this._instance = new LocalStorage();
    } else {
      this._instance = new ObjectStrore();
    }
  }

  public static getInstance(): IUserDataStore {
    return this._instance;
  }
}

export default UserDataStoreService.getInstance();
