#import <React/RCTBridgeModule.h>
#import <React/RCTEventEmitter.h>

/**
 * EKYCModuleBridge.m
 *
 * Exposes EKYCModule (Swift) to the React Native Objective-C bridge.
 * Every @objc(EKYCModule) method in EKYCModule.swift must have a
 * corresponding RCT_EXTERN_METHOD entry here.
 */

RCT_EXTERN_MODULE(EKYCModule, RCTEventEmitter)

// MARK: - SDK Init
RCT_EXTERN_METHOD(initSdkEkyc : (RCTPromiseResolveBlock)
                      resolve rejecter : (RCTPromiseRejectBlock)reject)
RCT_EXTERN_METHOD(getVersion : (RCTPromiseResolveBlock)
                      resolve rejecter : (RCTPromiseRejectBlock)reject)
RCT_EXTERN_METHOD(getSDKInfo : (RCTPromiseResolveBlock)
                      resolve rejecter : (RCTPromiseRejectBlock)reject)
RCT_EXTERN_METHOD(setTransactionId : (NSString *)transactionId resolver : (
    RCTPromiseResolveBlock)resolve rejecter : (RCTPromiseRejectBlock)reject)

// MARK: - NFC
RCT_EXTERN_METHOD(
    startNfcScan : (NSString *)appKey documentNumber : (NSString *)
        documentNumber birthDate : (NSString *)birthDate expireDate : (
            NSString *)expireDate transactionId : (NSString *)
            transactionId facePathStorage : (NSString *)
                facePathStorage resolver : (RCTPromiseResolveBlock)
                    resolve rejecter : (RCTPromiseRejectBlock)reject)

// MARK: - C06
RCT_EXTERN_METHOD(checkC06 : (NSString *)appKey sod : (NSString *)sod
                      idCardNumber : (NSString *)idCardNumber recentLocation : (
                          NSString *)recentLocation transactionId : (NSString *)
                          transactionId resolver : (RCTPromiseResolveBlock)
                              resolve rejecter : (RCTPromiseRejectBlock)reject)

// MARK: - OCR
RCT_EXTERN_METHOD(startOcr : (NSString *)appKey idImage : (
    NSString *)idImage expectedDocumentSide : (NSString *)
                      expectedDocumentSide transactionId : (NSString *)
                          transactionId resolver : (RCTPromiseResolveBlock)
                              resolve rejecter : (RCTPromiseRejectBlock)reject)

// MARK: - Liveness
RCT_EXTERN_METHOD(
    startLiveness : (NSString *)appKey selfieImage : (NSString *)selfieImage
        transactionId : (NSString *)transactionId isActiveLiveness : (BOOL)
            isActiveLiveness isShowCameraFont : (BOOL)isShowCameraFont
            customActionsArray : (NSArray *)customActionsArray
            activeActionCount : (NSInteger)activeActionCount
            forceCaptureTimeout : (double)forceCaptureTimeout
            isActiveLivenessColor : (BOOL)isActiveLivenessColor
            resolver : (RCTPromiseResolveBlock)resolve
            rejecter : (RCTPromiseRejectBlock)reject)

// MARK: - FaceCompare
RCT_EXTERN_METHOD(startFaceCompare : (NSString *)appKey transactionId : (
    NSString *)transactionId selfieImage : (NSString *)
                      selfieImage idImage : (NSString *)
                          idImage resolver : (RCTPromiseResolveBlock)
                              resolve rejecter : (RCTPromiseRejectBlock)reject)

// MARK: - eKYC UI Flow
RCT_EXTERN_METHOD(
    startEkycUI : (NSString *)appKey flowSDK : (NSString *)
        flowSDK language : (NSString *)language transactionId : (NSString *)
            transactionId optionConfigJson : (NSString *)
                optionConfigJson appKeyConfigJson : (NSString *)
                    appKeyConfigJson styleConfigJson : (NSString *)
                        styleConfigJson resolver : (RCTPromiseResolveBlock)
                            resolve rejecter : (RCTPromiseRejectBlock)reject)

// MARK: - SMS OTP
RCT_EXTERN_METHOD(
    sendOtp : (NSString *)appKey phoneNumber : (NSString *)
        phoneNumber purpose : (NSString *)purpose referenceId : (NSString *)
            referenceId resolver : (RCTPromiseResolveBlock)
                resolve rejecter : (RCTPromiseRejectBlock)reject)

RCT_EXTERN_METHOD(
    verifyOtp : (NSString *)appKey phoneNumber : (NSString *)
        phoneNumber purpose : (NSString *)purpose referenceId : (NSString *)
            referenceId requestId : (NSString *)requestId otpCode : (NSString *)
                otpCode resolver : (RCTPromiseResolveBlock)
                    resolve rejecter : (RCTPromiseRejectBlock)reject)

RCT_EXTERN_METHOD(resendOtp : (NSString *)appKey phoneNumber : (NSString *)
                      phoneNumber purpose : (NSString *)purpose referenceId : (
                          NSString *)referenceId requestId : (NSString *)
                          requestId resolver : (RCTPromiseResolveBlock)
                              resolve rejecter : (RCTPromiseRejectBlock)reject)

// MARK: - eSign
RCT_EXTERN_METHOD(initializeESign : (NSString *)finosToken isProd : (BOOL)
                      isProd resolver : (RCTPromiseResolveBlock)
                          resolve rejecter : (RCTPromiseRejectBlock)reject)

RCT_EXTERN_METHOD(getSdkToken : (NSString *)identity name : (NSString *)
                      name deviceId : (NSString *)
                          deviceId resolver : (RCTPromiseResolveBlock)
                              resolve rejecter : (RCTPromiseRejectBlock)reject)

RCT_EXTERN_METHOD(openSessionId : (NSString *)accessToken username : (
    NSString *)username rememberMe : (BOOL)
                      rememberMe resolver : (RCTPromiseResolveBlock)
                          resolve rejecter : (RCTPromiseRejectBlock)reject)

RCT_EXTERN_METHOD(registerDevice : (NSString *)recoverCode pinCode : (
    NSString *)pinCode fcmToken : (NSString *)
                      fcmToken resolver : (RCTPromiseResolveBlock)
                          resolve rejecter : (RCTPromiseRejectBlock)reject)

RCT_EXTERN_METHOD(listCerts : (NSInteger)pageNumber pageSize : (NSInteger)
                      pageSize resolver : (RCTPromiseResolveBlock)
                          resolve rejecter : (RCTPromiseRejectBlock)reject)

RCT_EXTERN_METHOD(verifyCert : (NSString *)serial resolver : (
    RCTPromiseResolveBlock)resolve rejecter : (RCTPromiseRejectBlock)reject)

RCT_EXTERN_METHOD(listSignRequest : (NSInteger)pageNumber pageSize : (NSInteger)
                      pageSize resolver : (RCTPromiseResolveBlock)
                          resolve rejecter : (RCTPromiseRejectBlock)reject)

RCT_EXTERN_METHOD(
    confirmSign : (NSString *)signRequestId pinCode : (NSString *)
        pinCode authId : (NSString *)authId authData : (NSString *)
            authData confirm : (BOOL)confirm resolver : (RCTPromiseResolveBlock)
                resolve rejecter : (RCTPromiseRejectBlock)reject)

RCT_EXTERN_METHOD(registerRemoteSigning : (NSString *)requestJson resolver : (
    RCTPromiseResolveBlock)resolve rejecter : (RCTPromiseRejectBlock)reject)

RCT_EXTERN_METHOD(signPdf : (NSString *)requestJson resolver : (
    RCTPromiseResolveBlock)resolve rejecter : (RCTPromiseRejectBlock)reject)

RCT_EXTERN_METHOD(signPdfMultiplePositions : (NSString *)
                      requestJson resolver : (RCTPromiseResolveBlock)
                          resolve rejecter : (RCTPromiseRejectBlock)reject)

RCT_EXTERN_METHOD(sendConfirmationDocument : (NSString *)
                      requestJson resolver : (RCTPromiseResolveBlock)
                          resolve rejecter : (RCTPromiseRejectBlock)reject)

RCT_EXTERN_METHOD(registerAndConfirm : (
    NSString *)requestJson confirmationDocBase64 : (NSString *)
                      confirmationDocBase64 resolver : (RCTPromiseResolveBlock)
                          resolve rejecter : (RCTPromiseRejectBlock)reject)

RCT_EXTERN_METHOD(initAuthorize : (NSString *)serial quantity : (NSInteger)
                      quantity time : (NSInteger)time message : (NSString *)
                          message resolver : (RCTPromiseResolveBlock)
                              resolve rejecter : (RCTPromiseRejectBlock)reject)

RCT_EXTERN_METHOD(listAuthorize : (NSInteger)pageNumber pageSize : (NSInteger)
                      pageSize status : (NSString *)
                          status resolver : (RCTPromiseResolveBlock)
                              resolve rejecter : (RCTPromiseRejectBlock)reject)

RCT_EXTERN_METHOD(registerAuthorize : (NSString *)authId authData : (
    NSString *)authData authorizeRequestId : (NSString *)authorizeRequestId
                      userPin : (NSString *)userPin confirm : (BOOL)
                          confirm resolver : (RCTPromiseResolveBlock)
                              resolve rejecter : (RCTPromiseRejectBlock)reject)

// MARK: - Lifecycle
RCT_EXTERN_METHOD(onResume)
RCT_EXTERN_METHOD(onPause)
RCT_EXTERN_METHOD(handleNewIntent)
RCT_EXTERN_METHOD(extractNfcDataForC06 : (NSString *)nfcResultJson resolver : (
    RCTPromiseResolveBlock)resolve rejecter : (RCTPromiseRejectBlock)reject)

// MARK: - Exit Handler (Dummy)
RCT_EXTERN_METHOD(registerExitHandler : (RCTPromiseResolveBlock)
                      resolve rejecter : (RCTPromiseRejectBlock)reject)

RCT_EXTERN_METHOD(resolveExit : (NSString *)action resolver : (
    RCTPromiseResolveBlock)resolve rejecter : (RCTPromiseRejectBlock)reject)

