/// Equipment management
export default class TXDeviceManager {
  private nativeSdk: any;

  constructor(trtcReactNativeSdk: any) {
    this.nativeSdk = trtcReactNativeSdk;
  }
  /**
  - Querying whether the front camera is being used
  */
  isFrontCamera(): Promise<boolean> {
    return this.nativeSdk.isFrontCamera();
  }
  /**
  - Switching to the front/rear camera (for mobile OS)
  @param isFrontCamera:  `true` Front camera   `false` rear camera
  */
  switchCamera(isFrontCamera: boolean): Promise<void> {
    return this.nativeSdk.switchCamera({ isFrontCamera });
  }
  /**
  - Getting the maximum zoom ratio of the camera (for mobile OS)
  @return  Maximum scaling multiple
  */
  getCameraZoomMaxRatio(): Promise<number> {
    return this.nativeSdk.getCameraZoomMaxRatio();
  }
  /**
  - Setting the camera zoom ratio (for mobile OS)
  @param value	Value range: 1-5. 1 indicates the widest angle of view (original), and 5 the narrowest angle of view (zoomed in).The maximum value is recommended to be 5. If the value exceeds 5, the video will become blurred.
  */
  setCameraZoomRatio(value: number): Promise<void> {
    return this.nativeSdk.setCameraZoomRatio({
      value: value.toString(),
    });
  }
  /**
  - Enabling auto focus (for mobile OS)
  - After auto focus is enabled, the camera will automatically detect and always focus on faces.
  @param enable `true` open, `false` close. Default value: true
  @return 0: Successful, operation negative number: Fail
  */
  enableCameraAutoFocus(enable: boolean): Promise<number> {
    return this.nativeSdk.enableCameraAutoFocus({
      enable: enable,
    });
  }
  /**
  - Querying whether automatic face detection is supported (for mobile OS)
  @return Return value: `true` supports `false` not support
  */
  isAutoFocusEnabled(): Promise<boolean> {
    return this.nativeSdk.isAutoFocusEnabled();
  }
  /**
  - Adjusting the focus (for mobile OS)
  @param x	Focus position x coordinates
  @param y	Focus position y coordinates
  */
  setCameraFocusPosition(x: number, y: number): Promise<void> {
    return this.nativeSdk.setCameraFocusPosition({
      x: x,
      y: y,
    });
  }
  /**
  - Enabling/Disabling flash, i.e., the torch mode (for mobile OS)
  @param enable	`true` Open; `false` Close, default value: false
  */
  enableCameraTorch(enable: boolean): Promise<boolean> {
    return this.nativeSdk.enableCameraTorch({
      enable: enable,
    });
  }
  /**
  - Setting the system volume type (for mobile OS)
  @param type	The type of system volume, if there is no special needs, it is not recommended to set it by yourself.
  */
  setSystemVolumeType(type: number): Promise<void> {
    return this.nativeSdk.setSystemVolumeType({
      type: type,
    });
  }
  /**
  - Setting the audio route (for mobile OS)
  - A mobile phone has two audio playback devices: the receiver at the top and the speaker at the bottom.
  - If the audio route is set to the receiver, the volume is relatively low, and audio can be heard only when the phone is put near the ear. This mode has a high level of privacy and is suitable for answering calls.
  - If the audio route is set to the speaker, the volume is relatively high, and there is no need to put the phone near the ear. This mode enables the "hands-free" feature.
  @param route	Audio routing, where the sound is output (speaker, handset)
  */
  setAudioRoute(route: number): Promise<void> {
    return this.nativeSdk.setAudioRoute({
      route: route,
    });
  }
}
