#import "RNHeapModuleWrapper.h"
#import <Foundation/Foundation.h>
#import <React/RCTUIManager.h>
#import <React/RCTBridgeModule.h>

#if __has_include("ContentsquareBridgeModule-Swift.h")
#import "ContentsquareBridgeModule-Swift.h"
#elif __has_include("ContentsquareBridgeModule/ContentsquareBridgeModule-Swift.h")
#import "ContentsquareBridgeModule/ContentsquareBridgeModule-Swift.h"
#endif

@interface RNHeapModuleWrapper()
@property (nonatomic, strong) RNHeapModule *heapModule;
@end

@implementation RNHeapModuleWrapper

- (instancetype)init {
    self = [super init];
    if (self) {
        _heapModule = [[RNHeapModule alloc] init];
        _heapModule.delegate = self;
    }
    return self;
}

- (void)handleInvocation:(nonnull NSString *)method args:(nonnull NSDictionary *)args resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
    [self.heapModule handleInvocation:method arguments:args resolver:resolve rejecter:reject];
}


- (void)handleResult:(nonnull NSString *)callbackId data:(nonnull NSDictionary *)data error:(nonnull NSString *)error {
    [self.heapModule handleResult:callbackId data:data error:error];
}

- (void)emitEvent:(NSString *)name data:(NSDictionary *)data { 
    if ([self.delegate respondsToSelector:@selector(emitEvent:data:)]) {
        [self.delegate emitEvent:name data:data];
    }
}
@end
