#import <Foundation/Foundation.h>
#import <string>

#import "daclient.h"
#import "Common.h"
#import "JDAEvent.h"
#import "JDAResponse.h"

NS_ASSUME_NONNULL_BEGIN

struct JDAPoseCheckConfigurations
{
    float pseudoPitchMin = 105;
    float pseudoPitchMax = 170;
    float pseudoYawMin = 65;
    float pseudoYawMax = 135;
    float normalizedOffCenterThreshold = 0.05;
    float landscapeResolutionScaleForDistance = 1.4;
};

struct JDAPhotinusConfigurations
{
    std::string nonce;
    int hardwareLatency = 4;
};

struct JDAStandardLivenessConfigurations
{
    float normalizedNearFarCutOffPoint = 0.7;
    float requiredDistanceMovementRatio = 0.85;
    float initialPoseCheckFaceWidthRatioMin = 0.5;
    float initialPoseCheckFaceWidthRatioMax = 0.9;
    float targetFaceWidthRatioForProfilePicture = -1;
    int delayMillisecondsBetweenDistance = 1500;
    JDAPoseCheckConfigurations poseCheck;
};

struct JDAPremiumLivenessConfigurations
{
    float normalizedNearFarCutOffPoint = 0.7;
    float requiredDistanceMovementRatio = 0.85;
    float initialPoseCheckFaceWidthRatioMin = 0.5;
    float initialPoseCheckFaceWidthRatioMax = 0.9;
    float targetFaceWidthRatioForProfilePicture = -1;
    int delayMillisecondsBetweenDistance = 1500;
    JDAPoseCheckConfigurations poseCheck;
    JDAPhotinusConfigurations nearPhotinus;
};


JDACLIENT_EXPORT const NSErrorDomain JDALivenessUXErrorDomain;
JDACLIENT_EXPORT const NSInteger JDALivenessUXErrorCancelled;
JDACLIENT_EXPORT const NSInteger JDALivenessUXErrorUnexpected;
JDACLIENT_EXPORT const NSInteger JDALivenessUXErrorInvalidOperation;
JDACLIENT_EXPORT const NSErrorUserInfoKey JDALivenessUXUnexpectedErrorDescriptionKey;


C_EXPORT int64_t get_timestamp_std_chrono();


@class JDALivenessUX;

NS_SWIFT_NAME(JDALivenessUX.ResponseHandler)
@protocol JDALivenessUXResponseHandler

- (void)livenessUX:(JDALivenessUX*)livenessUX didReceiveEventForForwarding:(const daclient_event_t*)nativeEvent;
- (void)livenessUX:(JDALivenessUX*)livenessUX didReceiveResponse:(JDAResponse*)response;

@end


JDACLIENT_EXPORT @interface JDALivenessUX : NSObject

@property daclient_timestamp_source _Nullable timestampProvider;
@property (weak) id<JDALivenessUXResponseHandler> _Nullable responseHandler;

- (instancetype)init NS_UNAVAILABLE;
- (instancetype)initWithStandardLivenessConfigurations:(const JDAStandardLivenessConfigurations&)standardLivenessConfigurations;
- (instancetype)initWithPremiumLivenessConfigurations:(const JDAPremiumLivenessConfigurations&)premiumLivenessConfigurations;

- (void)runWithCompletionHandler:(void (^) (NSError* _Nullable error))completionHandler;
- (void)runWithCompletionDispatchQueue:(dispatch_queue_t)completionDispatchQueue completionHandler:(void (^) (NSError* _Nullable error))completionHandler NS_SWIFT_NAME(run(completionDispatchQueue:completionHandler:)) NS_SWIFT_DISABLE_ASYNC;
- (void)cancel;

- (void)onBeforeFrame DEPRECATED_MSG_ATTRIBUTE("Call onBeforeFrameWithTimestamp: instead to enable future Photinus improvements") NS_UNAVAILABLE;
- (void)onBeforeFrameWithTimestamp:(CFTimeInterval)timestamp;
- (void)onAfterFrame;
- (void)onReceiveNativeEvent:(const daclient_event_t*)nativeEvent;

- (void)confirmColorChange;

@end

NS_ASSUME_NONNULL_END

