"use strict";

import { Linking, Platform } from 'react-native';
import OKLiteManager from "./NativeReactNativeLiteCard.js";
class OnekeyLite {
  addConnectListener(listener) {
    this.removeConnectListeners();
    return OKLiteManager.onNFCUIEvent(event => {
      listener({
        code: Number(event.code),
        message: event.message
      });
    });
  }
  removeConnectListeners() {}
  addAccordListener() {
    return OKLiteManager.onNFCActiveConnection(() => {});
  }
  getLiteInfo() {
    return new Promise(resolve => {
      OKLiteManager.getLiteInfo(this.convertToPromise(resolve));
    });
  }
  checkNFCPermission() {
    return new Promise(resolve => {
      OKLiteManager.checkNFCPermission(this.convertToPromise(resolve));
    });
  }
  setMnemonic(mnemonic, pwd, overwrite = false) {
    return new Promise(resolve => {
      OKLiteManager.setMnemonic(mnemonic, pwd, overwrite, this.convertToPromise(resolve));
    });
  }
  getMnemonicWithPin(pwd) {
    return new Promise(resolve => {
      OKLiteManager.getMnemonicWithPin(pwd, this.convertToPromise(resolve));
    });
  }
  changePin(oldPin, newPin) {
    return new Promise(resolve => {
      OKLiteManager.changePin(oldPin, newPin, this.convertToPromise(resolve));
    });
  }
  reset() {
    return new Promise(resolve => {
      OKLiteManager.reset(this.convertToPromise(resolve));
    });
  }
  convertToPromise(resolve) {
    return (...result) => {
      resolve({
        error: result[0],
        data: result[1],
        cardInfo: result[2]
      });
    };
  }
  cancel() {
    if (Platform.OS === 'android') OKLiteManager.cancel();
  }
  intoSetting() {
    if (Platform.OS === 'android') {
      OKLiteManager.intoSetting();
    } else {
      Linking.openSettings();
    }
  }
}
const onekeyLite = new OnekeyLite();
export default onekeyLite;
export { CardErrors } from "./NativeReactNativeLiteCard.js";
//# sourceMappingURL=index.js.map