#import "RNScanbotSDK.h"

@import ScanbotSDKNativeWrapper;


@implementation RNScanbotSDK

NSString *const AnalyticsEvent = @"analyticsEvent";

RCT_EXPORT_MODULE(RNScanbotSDK);

// Mandatory override
- (NSArray<NSString *> *)supportedEvents {
    return @[AnalyticsEvent];
}

// MARK: SDK Operations

RCT_EXPORT_METHOD(initialize:(NSDictionary *)options
                  resolve:(RCTPromiseResolveBlock)resolve
                  reject:(RCTPromiseRejectBlock)reject) {
    RNProxyDelegate* delegate = [[RNProxyDelegate alloc] initWithResolveBlock:resolve andRejectBlock:reject];
    [SBDWrapper initializeSDKWithConfiguration:options resultDelegate:delegate framework: SBDFrameworkRnCap];
}

RCT_EXPORT_METHOD(getLicenseInfo:(RCTPromiseResolveBlock)resolve
                  reject:(RCTPromiseRejectBlock)reject) {
    RNProxyDelegate* delegate = [[RNProxyDelegate alloc] initWithResolveBlock:resolve andRejectBlock:reject];
    [SBSDKManager getLicenseInfoWithResultDelegate:delegate];
}

RCT_EXPORT_METHOD(getOcrConfigs:(RCTPromiseResolveBlock)resolve
                  reject:(RCTPromiseRejectBlock)reject) {
    RNProxyDelegate* delegate = [[RNProxyDelegate alloc] initWithResolveBlock:resolve andRejectBlock:reject];
    [SBDOCREngine getOCRConfigsWithResultDelegate:delegate];
}

RCT_EXPORT_METHOD(cleanupStorage:(RCTPromiseResolveBlock)resolve
                  reject:(RCTPromiseRejectBlock)reject) {
    RNProxyDelegate* delegate = [[RNProxyDelegate alloc] initWithResolveBlock:resolve andRejectBlock:reject];
    [SBDWrapper cleanupWithResultDelegate:delegate];
}

RCT_EXPORT_METHOD(mockCamera:(NSDictionary *)args
                  resolve:(RCTPromiseResolveBlock)resolve
                  reject:(RCTPromiseRejectBlock)reject) {
    RNProxyDelegate* delegate = [[RNProxyDelegate alloc] initWithResolveBlock:resolve andRejectBlock:reject];
    [SBSDKManager mockCameraWithOptions:args resultDelegate:delegate];
}

RCT_EXPORT_METHOD(setAnalyticsServiceCallback:(RCTPromiseResolveBlock)resolve
                  reject:(RCTPromiseRejectBlock)reject) {
    RNProxyDelegate* delegate = [[RNProxyDelegate alloc] initWithResolveBlock:resolve andRejectBlock: reject];
    [SBDWrapper analyticsSubscribeWithResultDelegate:delegate eventCallback:^(NSDictionary<NSString *,id> * event) {
        [self sendEventWithName:AnalyticsEvent body:event];
    }];
}

RCT_EXPORT_METHOD(removeAnalyticsServiceCallback:(RCTPromiseResolveBlock)resolve
                  reject:(RCTPromiseRejectBlock)reject) {
    RNProxyDelegate* delegate = [[RNProxyDelegate alloc] initWithResolveBlock:resolve andRejectBlock:reject];
    [SBDWrapper analyticsUnsubscribeWithResultDelegate:delegate];
}


// MARK: Barcode Scanner

RCT_EXPORT_METHOD(scanBarcodesFromImage:(NSDictionary *)args
                  resolve:(RCTPromiseResolveBlock)resolve
                  reject:(RCTPromiseRejectBlock)reject) {
    RNProxyDelegate* delegate = [[RNProxyDelegate alloc] initWithResolveBlock:resolve andRejectBlock:reject];
    [SBBarcode scanFromImageWithOptions:args resultDelegate:delegate];
}

RCT_EXPORT_METHOD(scanBarcodesFromPdf:(NSDictionary *)args
                  resolve:(RCTPromiseResolveBlock)resolve
                  reject:(RCTPromiseRejectBlock)reject) {
    RNProxyDelegate* delegate = [[RNProxyDelegate alloc] initWithResolveBlock:resolve andRejectBlock:reject];
    [SBBarcode scanFromPDFWithOptions:args resultDelegate:delegate];
}

RCT_EXPORT_METHOD(parseBarcodeDocument:(NSDictionary *)args
                  resolve:(RCTPromiseResolveBlock)resolve
                  reject:(RCTPromiseRejectBlock)reject) {
    RNProxyDelegate* delegate = [[RNProxyDelegate alloc] initWithResolveBlock:resolve andRejectBlock:reject];
    [SBBarcode parseDocumentWithOptions:args resultDelegate:delegate];
}

// MARK: Data Detectors

RCT_EXPORT_METHOD(scanCheckFromImage:(NSDictionary*)args
                  resolve:(RCTPromiseResolveBlock)resolve
                  reject:(RCTPromiseRejectBlock)reject) {
    RNProxyDelegate* delegate = [[RNProxyDelegate alloc] initWithResolveBlock:resolve andRejectBlock:reject];
    [SBDCheck scanFromImageWithOptions:args resultDelegate:delegate];
}

RCT_EXPORT_METHOD(scanCreditCardFromImage:(NSDictionary *)args
                  resolve:(RCTPromiseResolveBlock)resolve
                  reject:(RCTPromiseRejectBlock)reject) {
    RNProxyDelegate* delegate = [[RNProxyDelegate alloc] initWithResolveBlock:resolve andRejectBlock:reject];
    [SBDCreditCard scanFromImageWithOptions:args resultDelegate:delegate];
}

RCT_EXPORT_METHOD(scanMrzFromImage:(NSDictionary*)args
                  resolve:(RCTPromiseResolveBlock)resolve
                  reject:(RCTPromiseRejectBlock)reject) {
    RNProxyDelegate* delegate = [[RNProxyDelegate alloc] initWithResolveBlock:resolve andRejectBlock:reject];
    [SBDMrz scanFromImageWithOptions:args resultDelegate:delegate];
}

RCT_EXPORT_METHOD(extractDocumentDataFromImage:(NSDictionary *)args
                  resolve:(RCTPromiseResolveBlock)resolve
                  reject:(RCTPromiseRejectBlock)reject) {
    RNProxyDelegate* delegate = [[RNProxyDelegate alloc] initWithResolveBlock:resolve andRejectBlock:reject];
    [SBDDocumentDataExtractor scanFromImageWithOptions:args resultDelegate:delegate];
}

RCT_EXPORT_METHOD(verifyDocument:(NSDictionary *)args
                  resolve:(RCTPromiseResolveBlock)resolve
                  reject:(RCTPromiseRejectBlock)reject) {
    RNProxyDelegate* delegate = [[RNProxyDelegate alloc] initWithResolveBlock:resolve andRejectBlock:reject];
    [SBDDocumentDataExtractor verifyDocumentWithOptions:args resultDelegate:delegate];
}

// MARK: Document Scanner

RCT_EXPORT_METHOD(createDocumentFromImages:(NSDictionary*)args
                  resolve:(RCTPromiseResolveBlock)resolve
                  reject:(RCTPromiseRejectBlock)reject) {
    RNProxyDelegate* delegate = [[RNProxyDelegate alloc] initWithResolveBlock:resolve andRejectBlock:reject];
    [SBDDocument createScannedDocumentWithOperationConfig:args resultDelegate:delegate];
}

RCT_EXPORT_METHOD(createDocumentFromPdf:(NSDictionary*)args
                  resolve:(RCTPromiseResolveBlock)resolve
                  reject:(RCTPromiseRejectBlock)reject) {
    RNProxyDelegate* delegate = [[RNProxyDelegate alloc] initWithResolveBlock:resolve andRejectBlock:reject];
    [SBDDocument createScannedDocumentFromPDFWithOperationConfig:args resultDelegate:delegate];
}

RCT_EXPORT_METHOD(createDocumentFromLegacyPages:(NSDictionary*)args
                  resolve:(RCTPromiseResolveBlock)resolve
                  reject:(RCTPromiseRejectBlock)reject) {
    RNProxyDelegate* delegate = [[RNProxyDelegate alloc] initWithResolveBlock:resolve andRejectBlock:reject];
    [SBDDocument documentFromLegacyPagesWithOperationConfig:args resultDelegate:delegate];
}

RCT_EXPORT_METHOD(documentExists:(NSDictionary*)args
                  resolve:(RCTPromiseResolveBlock)resolve
                  reject:(RCTPromiseRejectBlock)reject) {
    RNProxyDelegate* delegate = [[RNProxyDelegate alloc] initWithResolveBlock:resolve andRejectBlock:reject];
    [SBDDocument documentExistsWithOperationConfig:args resultDelegate:delegate];
}

RCT_EXPORT_METHOD(loadDocument:(NSDictionary*)args
                  resolve:(RCTPromiseResolveBlock)resolve
                  reject:(RCTPromiseRejectBlock)reject) {
    RNProxyDelegate* delegate = [[RNProxyDelegate alloc] initWithResolveBlock:resolve andRejectBlock:reject];
    [SBDDocument loadDocumentWithOperationConfig:args resultDelegate:delegate];
}

RCT_EXPORT_METHOD(getStoredDocumentUuids:(RCTPromiseResolveBlock)resolve
                  reject:(RCTPromiseRejectBlock)reject){
    RNProxyDelegate* delegate = [[RNProxyDelegate alloc] initWithResolveBlock:resolve andRejectBlock:reject];
    [SBDDocument storedDocumentIDsWithResultDelegate:delegate];
}

RCT_EXPORT_METHOD(cloneDocument:(NSDictionary*)args
                  resolve:(RCTPromiseResolveBlock)resolve
                  reject:(RCTPromiseRejectBlock)reject) {
    RNProxyDelegate* delegate = [[RNProxyDelegate alloc] initWithResolveBlock:resolve andRejectBlock:reject];
    [SBDDocument cloneDocumentWithOperationConfig:args resultDelegate:delegate];
}

RCT_EXPORT_METHOD(deleteDocument:(NSDictionary*)args
                  resolve:(RCTPromiseResolveBlock)resolve
                  reject:(RCTPromiseRejectBlock)reject) {
    RNProxyDelegate* delegate = [[RNProxyDelegate alloc] initWithResolveBlock:resolve andRejectBlock:reject];
    [SBDDocument deleteDocumentWithOperationConfig:args resultDelegate:delegate];
}

RCT_EXPORT_METHOD(deleteAllDocuments:(RCTPromiseResolveBlock)resolve
                  reject:(RCTPromiseRejectBlock)reject){
    RNProxyDelegate* delegate = [[RNProxyDelegate alloc] initWithResolveBlock:resolve andRejectBlock:reject];
    [SBDDocument deleteAllDocumentsWithResultDelegate:delegate];
}

RCT_EXPORT_METHOD(addPages:(NSDictionary*)args
                  resolve:(RCTPromiseResolveBlock)resolve
                  reject:(RCTPromiseRejectBlock)reject) {
    RNProxyDelegate* delegate = [[RNProxyDelegate alloc] initWithResolveBlock:resolve andRejectBlock:reject];
    [SBDDocument addPagesWithOperationConfig:args resultDelegate:delegate];
}

RCT_EXPORT_METHOD(movePage:(NSDictionary*)args
                  resolve:(RCTPromiseResolveBlock)resolve
                  reject:(RCTPromiseRejectBlock)reject) {
    RNProxyDelegate* delegate = [[RNProxyDelegate alloc] initWithResolveBlock:resolve andRejectBlock:reject];
    [SBDDocument movePageWithOperationConfig:args resultDelegate:delegate];
}

RCT_EXPORT_METHOD(modifyPage:(NSDictionary*)args
                  resolve:(RCTPromiseResolveBlock)resolve
                  reject:(RCTPromiseRejectBlock)reject) {
    RNProxyDelegate* delegate = [[RNProxyDelegate alloc] initWithResolveBlock:resolve andRejectBlock:reject];
    [SBDDocument modifyPageWithOperationConfig:args resultDelegate:delegate];
}

RCT_EXPORT_METHOD(removePagesFromDocument:(NSDictionary*)args
                  resolve:(RCTPromiseResolveBlock)resolve
                  reject:(RCTPromiseRejectBlock)reject) {
    RNProxyDelegate* delegate = [[RNProxyDelegate alloc] initWithResolveBlock:resolve andRejectBlock:reject];
    [SBDDocument removePagesWithOperationConfig:args resultDelegate:delegate];
}

RCT_EXPORT_METHOD(removeAllPages:(NSDictionary*)args
                  resolve:(RCTPromiseResolveBlock)resolve
                  reject:(RCTPromiseRejectBlock)reject) {
    RNProxyDelegate* delegate = [[RNProxyDelegate alloc] initWithResolveBlock:resolve andRejectBlock:reject];
    [SBDDocument removeAllPagesWithOperationConfig:args resultDelegate:delegate];
}

RCT_EXPORT_METHOD(scanDocumentFromImage:(NSDictionary*)args
                  resolve:(RCTPromiseResolveBlock)resolve
                  reject:(RCTPromiseRejectBlock)reject) {
    RNProxyDelegate* delegate = [[RNProxyDelegate alloc] initWithResolveBlock:resolve andRejectBlock:reject];
    [SBDDocument scanFromImageWithOperationConfig:args resultDelegate:delegate];
}

RCT_EXPORT_METHOD(analyzeDocumentQualityOnImage:(NSDictionary*)args
                  resolve:(RCTPromiseResolveBlock)resolve
                  reject:(RCTPromiseRejectBlock)reject) {
    RNProxyDelegate* delegate = [[RNProxyDelegate alloc] initWithResolveBlock:resolve andRejectBlock:reject];
    [SBDDocument documentQualityAnalyzerWithOperationConfig:args resultDelegate:delegate];
}


// MARK: Legacy Page

RCT_EXPORT_METHOD(removeLegacyPage:(NSDictionary*)args
                  resolve:(RCTPromiseResolveBlock)resolve
                  reject:(RCTPromiseRejectBlock)reject) {
    RNProxyDelegate* delegate = [[RNProxyDelegate alloc] initWithResolveBlock:resolve andRejectBlock:reject];
    [SBDPageOperations removePageWithPageDict:args resultDelegate:delegate];
}

RCT_EXPORT_METHOD(removeAllLegacyPages:(RCTPromiseResolveBlock)resolve
                  reject:(RCTPromiseRejectBlock)reject) {
    RNProxyDelegate* delegate = [[RNProxyDelegate alloc] initWithResolveBlock:resolve andRejectBlock:reject];
    [SBDPageOperations removeAllLegacyPagesWithResultDelegate:delegate];
}

RCT_EXPORT_METHOD(refreshImageUrisOnLegacyPage:(NSDictionary*)args
                  resolve:(RCTPromiseResolveBlock)resolve
                  reject:(RCTPromiseRejectBlock)reject) {
    RNProxyDelegate* delegate = [[RNProxyDelegate alloc] initWithResolveBlock:resolve andRejectBlock:reject];
    [SBDPageOperations refreshImageUrisWithOperationConfig:args resultDelegate:delegate];
}

RCT_EXPORT_METHOD(setDocumentImageOnLegacyPage:(NSDictionary*)args
                  resolve:(RCTPromiseResolveBlock)resolve
                  reject:(RCTPromiseRejectBlock)reject) {
    RNProxyDelegate* delegate = [[RNProxyDelegate alloc] initWithResolveBlock:resolve andRejectBlock:reject];
    [SBDPageOperations setDocumentImageWithOperationConfig:args resultDelegate:delegate];
}


// MARK: Image Processing

RCT_EXPORT_METHOD(applyFiltersOnImage:(NSDictionary*)args
                  resolve:(RCTPromiseResolveBlock)resolve
                  reject:(RCTPromiseRejectBlock)reject) {
    RNProxyDelegate* delegate = [[RNProxyDelegate alloc] initWithResolveBlock:resolve andRejectBlock:reject];
    [SBImageProcessor applyImageFilterWithOperationConfig:args resultDelegate:delegate];
}

RCT_EXPORT_METHOD(applyFiltersOnImageFile:(NSDictionary*)args
                  resolve:(RCTPromiseResolveBlock)resolve
                  reject:(RCTPromiseRejectBlock)reject) {
    RNProxyDelegate* delegate = [[RNProxyDelegate alloc] initWithResolveBlock:resolve andRejectBlock:reject];
    [SBImageProcessor applyImageFilterFromFileWithOperationConfig:args resultDelegate:delegate];
}


RCT_EXPORT_METHOD(rotateImage:(NSDictionary*)args
                  resolve:(RCTPromiseResolveBlock)resolve
                  reject:(RCTPromiseRejectBlock)reject) {
    RNProxyDelegate* delegate = [[RNProxyDelegate alloc] initWithResolveBlock:resolve andRejectBlock:reject];
    [SBImageProcessor rotateImageWithOperationConfig:args resultDelegate:delegate];
}

RCT_EXPORT_METHOD(rotateImageFile:(NSDictionary*)args
                  resolve:(RCTPromiseResolveBlock)resolve
                  reject:(RCTPromiseRejectBlock)reject) {
    RNProxyDelegate* delegate = [[RNProxyDelegate alloc] initWithResolveBlock:resolve andRejectBlock:reject];
    [SBImageProcessor rotateImageFromFileWithOperationConfig:args resultDelegate:delegate];
}

RCT_EXPORT_METHOD(readImageData:(NSDictionary*)args
                  resolve:(RCTPromiseResolveBlock)resolve
                  reject:(RCTPromiseRejectBlock)reject) {
    RNProxyDelegate* delegate = [[RNProxyDelegate alloc] initWithResolveBlock:resolve andRejectBlock:reject];
    [SBImageProcessor readImageDataWithOptions:args resultDelegate:delegate];
}

RCT_EXPORT_METHOD(resizeImage:(NSDictionary*)args
                  resolve:(RCTPromiseResolveBlock)resolve
                  reject:(RCTPromiseRejectBlock)reject) {
    RNProxyDelegate* delegate = [[RNProxyDelegate alloc] initWithResolveBlock:resolve andRejectBlock:reject];
    [SBImageProcessor resizeImageWithOperationConfig:args resultDelegate:delegate];
}

RCT_EXPORT_METHOD(resizeImageFile:(NSDictionary*)args
                  resolve:(RCTPromiseResolveBlock)resolve
                  reject:(RCTPromiseRejectBlock)reject) {
    RNProxyDelegate* delegate = [[RNProxyDelegate alloc] initWithResolveBlock:resolve andRejectBlock:reject];
    [SBImageProcessor resizeImageFromFileWithOperationConfig:args resultDelegate:delegate];
}

RCT_EXPORT_METHOD(cropImage:(NSDictionary*)args
                  resolve:(RCTPromiseResolveBlock)resolve
                  reject:(RCTPromiseRejectBlock)reject) {
    RNProxyDelegate* delegate = [[RNProxyDelegate alloc] initWithResolveBlock:resolve andRejectBlock:reject];
    [SBImageProcessor cropImageWithOperationConfig:args resultDelegate:delegate];
}

RCT_EXPORT_METHOD(cropImageFile:(NSDictionary*)args
                  resolve:(RCTPromiseResolveBlock)resolve
                  reject:(RCTPromiseRejectBlock)reject) {
    RNProxyDelegate* delegate = [[RNProxyDelegate alloc] initWithResolveBlock:resolve andRejectBlock:reject];
    [SBImageProcessor cropImageFromFileWithOperationConfig:args resultDelegate:delegate];
}

// MARK: OCR Engine


RCT_EXPORT_METHOD(recognizeOcrOnImages:(NSDictionary*)args
                  resolve:(RCTPromiseResolveBlock)resolve
                  reject:(RCTPromiseRejectBlock)reject) {
    RNProxyDelegate* delegate = [[RNProxyDelegate alloc] initWithResolveBlock:resolve andRejectBlock:reject];
    [SBDOCREngine recognizeOnImagesWithOperationConfig:args resultDelegate:delegate];
}

RCT_EXPORT_METHOD(recognizeOcrOnDocument:(NSDictionary*)args
                  resolve:(RCTPromiseResolveBlock)resolve
                  reject:(RCTPromiseRejectBlock)reject) {
    RNProxyDelegate* delegate = [[RNProxyDelegate alloc] initWithResolveBlock:resolve andRejectBlock:reject];
    [SBDOCREngine recognizeOnDocumentWithOperationConfig:args resultDelegate:delegate];
}

// MARK: PDF / TIFF Generation

RCT_EXPORT_METHOD(generatePdfFromImages:(NSDictionary*)args
                  resolve:(RCTPromiseResolveBlock)resolve
                  reject:(RCTPromiseRejectBlock)reject) {
    RNProxyDelegate* delegate = [[RNProxyDelegate alloc] initWithResolveBlock:resolve andRejectBlock:reject];
    [SBDPDFGenerator generateFromImagesWithOperationConfig:args resultDelegate:delegate];
}

RCT_EXPORT_METHOD(generatePdfFromDocument:(NSDictionary*)args
                  resolve:(RCTPromiseResolveBlock)resolve
                  reject:(RCTPromiseRejectBlock)reject) {
    RNProxyDelegate* delegate = [[RNProxyDelegate alloc] initWithResolveBlock:resolve andRejectBlock:reject];
    [SBDPDFGenerator generateFromDocumentWithOperationConfiguration:args resultDelegate:delegate];
}

RCT_EXPORT_METHOD(generateTiffFromImages:(NSDictionary*)args
                  resolve:(RCTPromiseResolveBlock)resolve
                  reject:(RCTPromiseRejectBlock)reject) {
    RNProxyDelegate* delegate = [[RNProxyDelegate alloc] initWithResolveBlock:resolve andRejectBlock:reject];
    [SBDTIFFGenerator generateFromImagesWithOperationConfig:args resultDelegate:delegate];
}

RCT_EXPORT_METHOD(generateTiffFromDocument:(NSDictionary*)args
                  resolve:(RCTPromiseResolveBlock)resolve
                  reject:(RCTPromiseRejectBlock)reject) {
    RNProxyDelegate* delegate = [[RNProxyDelegate alloc] initWithResolveBlock:resolve andRejectBlock:reject];
    [SBDTIFFGenerator generateFromDocumentWithOperationConfiguration:args resultDelegate:delegate];
}

RCT_EXPORT_METHOD(extractImageFilesFromPdf:(NSDictionary*)args
                  resolve:(RCTPromiseResolveBlock)resolve
                  reject:(RCTPromiseRejectBlock)reject) {
    RNProxyDelegate* delegate = [[RNProxyDelegate alloc] initWithResolveBlock:resolve andRejectBlock:reject];
    [SBPDFExtractor extractImagesFromPdfWithOperationConfig:args resultDelegate:delegate];
}


// MARK: ImageRef

RCT_EXPORT_METHOD(imageRefSerialize:(NSDictionary*)args
                  resolve:(RCTPromiseResolveBlock)resolve
                  reject:(RCTPromiseRejectBlock)reject) {
    RNProxyDelegate* delegate = [[RNProxyDelegate alloc] initWithResolveBlock:resolve andRejectBlock:reject];
    [SBImageRef imageRefSerializeWithOperationConfig:args resultDelegate:delegate];
}

RCT_EXPORT_METHOD(imageRefDeserialize:(NSDictionary*)args
                  resolve:(RCTPromiseResolveBlock)resolve
                  reject:(RCTPromiseRejectBlock)reject) {
    RNProxyDelegate* delegate = [[RNProxyDelegate alloc] initWithResolveBlock:resolve andRejectBlock:reject];
    [SBImageRef imageRefDeserializeWithOperationConfig:args resultDelegate:delegate];
}

RCT_EXPORT_METHOD(imageRefFromImageFileUri:(NSDictionary*)args
                  resolve:(RCTPromiseResolveBlock)resolve
                  reject:(RCTPromiseRejectBlock)reject) {
    RNProxyDelegate* delegate = [[RNProxyDelegate alloc] initWithResolveBlock:resolve andRejectBlock:reject];
    [SBImageRef imageRefFromImageFileUriWithOperationConfig:args resultDelegate:delegate];
}

RCT_EXPORT_METHOD(imageRefFromEncodedBuffer:(NSDictionary*)args
                  resolve:(RCTPromiseResolveBlock)resolve
                  reject:(RCTPromiseRejectBlock)reject) {
    RNProxyDelegate* delegate = [[RNProxyDelegate alloc] initWithResolveBlock:resolve andRejectBlock:reject];
    [SBImageRef imageRefFromEncodedBufferWithOperationConfig:args resultDelegate:delegate];
}

RCT_EXPORT_METHOD(imageRefHibernate:(NSDictionary*)args
                  resolve:(RCTPromiseResolveBlock)resolve
                  reject:(RCTPromiseRejectBlock)reject) {
    RNProxyDelegate* delegate = [[RNProxyDelegate alloc] initWithResolveBlock:resolve andRejectBlock:reject];
    [SBImageRef imageRefHibernateWithOperationConfig:args resultDelegate:delegate];
}

RCT_EXPORT_METHOD(imageRefClear:(NSDictionary*)args
                  resolve:(RCTPromiseResolveBlock)resolve
                  reject:(RCTPromiseRejectBlock)reject) {
    RNProxyDelegate* delegate = [[RNProxyDelegate alloc] initWithResolveBlock:resolve andRejectBlock:reject];
    [SBImageRef imageRefClearWithOperationConfig:args resultDelegate:delegate];
}

RCT_EXPORT_METHOD(imageRefRelease:(NSDictionary*)args
                  resolve:(RCTPromiseResolveBlock)resolve
                  reject:(RCTPromiseRejectBlock)reject) {
    RNProxyDelegate* delegate = [[RNProxyDelegate alloc] initWithResolveBlock:resolve andRejectBlock:reject];
    [SBImageRef imageRefReleaseWithOperationConfig:args resultDelegate:delegate];
}

RCT_EXPORT_METHOD(imageRefInfo:(NSDictionary*)args
                  resolve:(RCTPromiseResolveBlock)resolve
                  reject:(RCTPromiseRejectBlock)reject) {
    RNProxyDelegate* delegate = [[RNProxyDelegate alloc] initWithResolveBlock:resolve andRejectBlock:reject];
    [SBImageRef imageRefInfoWithOperationConfig:args resultDelegate:delegate];
}

RCT_EXPORT_METHOD(imageRefSaveImage:(NSDictionary*)args
                  resolve:(RCTPromiseResolveBlock)resolve
                  reject:(RCTPromiseRejectBlock)reject) {
    RNProxyDelegate* delegate = [[RNProxyDelegate alloc] initWithResolveBlock:resolve andRejectBlock:reject];
    [SBImageRef imageRefSaveImageWithOperationConfig:args resultDelegate:delegate];
}

RCT_EXPORT_METHOD(imageRefEncodeImage:(NSDictionary*)args
                  resolve:(RCTPromiseResolveBlock)resolve
                  reject:(RCTPromiseRejectBlock)reject) {
    RNProxyDelegate* delegate = [[RNProxyDelegate alloc] initWithResolveBlock:resolve andRejectBlock:reject];
    [SBImageRef imageRefEncodeImageWithOperationConfig:args resultDelegate:delegate];
}

RCT_EXPORT_METHOD(makeSnapshot:(RCTPromiseResolveBlock)resolve
                  reject:(RCTPromiseRejectBlock)reject) {
    RNProxyDelegate* delegate = [[RNProxyDelegate alloc] initWithResolveBlock:resolve andRejectBlock:reject];
    [SBImageRef imageRefProfilerSnapshotWithResultDelegate:delegate];
}

RCT_EXPORT_METHOD(imageRefReleaseAll:(RCTPromiseResolveBlock)resolve
                  reject:(RCTPromiseRejectBlock)reject) {
    RNProxyDelegate* delegate = [[RNProxyDelegate alloc] initWithResolveBlock:resolve andRejectBlock:reject];
    [SBImageRef imageRefReleaseAllWithResultDelegate:delegate];
}


@end
