






#import "EyeAlertView.h"
#import "ReceivedFor.h"
#import "DryPortalManager.h"
#import "Masonry.h"

#define escapes(fun) __weak typeof(fun) weak##fun = fun;
#define rowAtomic(fun) __strong typeof(fun) fun = weak##fun;

@interface EyeAlertView()

@property (nonatomic, strong) UIView *audiogramMightView;
@property (nonatomic, copy) ChestLeadRoutePairEncodingsMomentary completion;
@property (nonatomic, strong) UIStackView *sheGatherSixView;

@end

@implementation EyeAlertView

- (void)dealloc {
    
}

- (instancetype)initWithFrame:(CGRect)frame
                          title:(NSString *)title
                        message:(NSString *)message
                   panButOutput:(NSArray<NSString *> *)panButOutput
                     completion:(ChestLeadRoutePairEncodingsMomentary)completion {
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
        self.completion = completion;
        
        
        self.audiogramMightView = [[UIView alloc] init];
        self.audiogramMightView.backgroundColor = [ReceivedFor cubicSentColor];
        self.audiogramMightView.layer.cornerRadius = ReceivedFor.dogMagicChar.overrideMood;
        self.audiogramMightView.clipsToBounds = YES;
        self.audiogramMightView.translatesAutoresizingMaskIntoConstraints = NO;
        [self addSubview:self.audiogramMightView];
        
        
        [NSLayoutConstraint activateConstraints:@[
            [self.audiogramMightView.centerXAnchor constraintEqualToAnchor:self.centerXAnchor],
            [self.audiogramMightView.centerYAnchor constraintEqualToAnchor:self.centerYAnchor],
            [self.audiogramMightView.widthAnchor constraintEqualToConstant:270]
        ]];
        
        
        UIView *unitSendView = nil;
        CGFloat songAbortedRetAnyLoad = 20;
        
        
        if (title.length > 0) {
            UILabel *titleLabel = [[UILabel alloc] init];
            titleLabel.text = title;
            titleLabel.textColor = UIColor.whiteColor;
            titleLabel.font = [UIFont boldSystemFontOfSize:18];
            titleLabel.textAlignment = NSTextAlignmentCenter;
            titleLabel.numberOfLines = 0;
            titleLabel.translatesAutoresizingMaskIntoConstraints = NO;
            [self.audiogramMightView addSubview:titleLabel];
            
            [NSLayoutConstraint activateConstraints:@[
                [titleLabel.topAnchor constraintEqualToAnchor:self.audiogramMightView.topAnchor constant:songAbortedRetAnyLoad],
                [titleLabel.leadingAnchor constraintEqualToAnchor:self.audiogramMightView.leadingAnchor constant:16],
                [titleLabel.trailingAnchor constraintEqualToAnchor:self.audiogramMightView.trailingAnchor constant:-16]
            ]];
            
            unitSendView = titleLabel;
        }
        
        
        if (message.length > 0) {
            UILabel *bankWhoLabel = [[UILabel alloc] init];
            bankWhoLabel.text = message;
            bankWhoLabel.textColor = UIColor.whiteColor;
            bankWhoLabel.font = [UIFont systemFontOfSize:15];
            bankWhoLabel.textAlignment = NSTextAlignmentCenter;
            bankWhoLabel.numberOfLines = 0;
            bankWhoLabel.translatesAutoresizingMaskIntoConstraints = NO;
            [self.audiogramMightView addSubview:bankWhoLabel];
            
            NSLayoutYAxisAnchor *topAnchor = unitSendView ? unitSendView.bottomAnchor : self.audiogramMightView.topAnchor;
            CGFloat bridgeDrop = unitSendView ? 10 : songAbortedRetAnyLoad;
            [NSLayoutConstraint activateConstraints:@[
                [bankWhoLabel.topAnchor constraintEqualToAnchor:topAnchor constant:bridgeDrop],
                [bankWhoLabel.leadingAnchor constraintEqualToAnchor:self.audiogramMightView.leadingAnchor constant:16],
                [bankWhoLabel.trailingAnchor constraintEqualToAnchor:self.audiogramMightView.trailingAnchor constant:-16]
            ]];
            unitSendView = bankWhoLabel;
        }
        
        
        self.sheGatherSixView = [[UIStackView alloc] init];
        self.sheGatherSixView.axis = UILayoutConstraintAxisVertical;
        self.sheGatherSixView.spacing = 1;  
        self.sheGatherSixView.distribution = UIStackViewDistributionFillEqually;
        self.sheGatherSixView.translatesAutoresizingMaskIntoConstraints = NO;
        [self.audiogramMightView addSubview:self.sheGatherSixView];
        
        
        NSLayoutYAxisAnchor *cursiveProducerEntityDayCoalesced = unitSendView ? unitSendView.bottomAnchor : self.audiogramMightView.topAnchor;
        CGFloat dissolvePlatformHockeySlavicExits = unitSendView ? songAbortedRetAnyLoad : songAbortedRetAnyLoad;
        
        [NSLayoutConstraint activateConstraints:@[
            [self.sheGatherSixView.topAnchor constraintEqualToAnchor:cursiveProducerEntityDayCoalesced constant:dissolvePlatformHockeySlavicExits],
            [self.sheGatherSixView.leadingAnchor constraintEqualToAnchor:self.audiogramMightView.leadingAnchor],
            [self.sheGatherSixView.trailingAnchor constraintEqualToAnchor:self.audiogramMightView.trailingAnchor],
            [self.sheGatherSixView.bottomAnchor constraintEqualToAnchor:self.audiogramMightView.bottomAnchor]
        ]];
        
        
       
       if (panButOutput.count == 2) {
           
           self.sheGatherSixView = [[UIStackView alloc] init];
           self.sheGatherSixView.axis = UILayoutConstraintAxisHorizontal;
           self.sheGatherSixView.distribution = UIStackViewDistributionFillEqually;
           self.sheGatherSixView.spacing = 1;  
           self.sheGatherSixView.translatesAutoresizingMaskIntoConstraints = NO;
           [self.audiogramMightView addSubview:self.sheGatherSixView];
           
           NSLayoutYAxisAnchor *cursiveProducerEntityDayCoalesced = unitSendView ? unitSendView.bottomAnchor : self.audiogramMightView.topAnchor;
           [NSLayoutConstraint activateConstraints:@[
               [self.sheGatherSixView.topAnchor constraintEqualToAnchor:cursiveProducerEntityDayCoalesced constant:songAbortedRetAnyLoad],
               [self.sheGatherSixView.leadingAnchor constraintEqualToAnchor:self.audiogramMightView.leadingAnchor],
               [self.sheGatherSixView.trailingAnchor constraintEqualToAnchor:self.audiogramMightView.trailingAnchor],
               [self.sheGatherSixView.bottomAnchor constraintEqualToAnchor:self.audiogramMightView.bottomAnchor]
           ]];
           
           
           for (NSInteger i = 0; i < panButOutput.count; i++) {
               NSString *coercion = panButOutput[i];
               UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
               [button setTitle:coercion forState:UIControlStateNormal];
               button.titleLabel.font = [UIFont systemFontOfSize:17];
               [button setTitleColor:[ReceivedFor cubicSentColor] forState:UIControlStateNormal];
               [button setTitleColor:UIColor.lightGrayColor forState:UIControlStateHighlighted];
               button.backgroundColor = [UIColor whiteColor];
               button.tag = i;
               [button addTarget:self action:@selector(askPairScore:) forControlEvents:UIControlEventTouchUpInside];
               button.translatesAutoresizingMaskIntoConstraints = NO;
               [button.heightAnchor constraintEqualToConstant:40].active = YES;
               [self.sheGatherSixView addArrangedSubview:button];
           }
       } else {
           
           self.sheGatherSixView = [[UIStackView alloc] init];
           self.sheGatherSixView.axis = UILayoutConstraintAxisVertical;
           self.sheGatherSixView.spacing = 1;
           self.sheGatherSixView.distribution = UIStackViewDistributionFillEqually;
           self.sheGatherSixView.translatesAutoresizingMaskIntoConstraints = NO;
           [self.audiogramMightView addSubview:self.sheGatherSixView];
           
           NSLayoutYAxisAnchor *cursiveProducerEntityDayCoalesced = unitSendView ? unitSendView.bottomAnchor : self.audiogramMightView.topAnchor;
           [NSLayoutConstraint activateConstraints:@[
               [self.sheGatherSixView.topAnchor constraintEqualToAnchor:cursiveProducerEntityDayCoalesced constant:songAbortedRetAnyLoad],
               [self.sheGatherSixView.leadingAnchor constraintEqualToAnchor:self.audiogramMightView.leadingAnchor],
               [self.sheGatherSixView.trailingAnchor constraintEqualToAnchor:self.audiogramMightView.trailingAnchor],
               [self.sheGatherSixView.bottomAnchor constraintEqualToAnchor:self.audiogramMightView.bottomAnchor]
           ]];
           
           for (NSInteger i = 0; i < panButOutput.count; i++) {
               NSString *coercion = panButOutput[i];
               UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
               [button setTitle:coercion forState:UIControlStateNormal];
               button.titleLabel.font = [UIFont systemFontOfSize:17];
               [button setTitleColor:[ReceivedFor cubicSentColor] forState:UIControlStateNormal];
               [button setTitleColor:UIColor.lightGrayColor forState:UIControlStateHighlighted];
               button.backgroundColor = [UIColor whiteColor];
               button.tag = i;
               [button addTarget:self action:@selector(askPairScore:) forControlEvents:UIControlEventTouchUpInside];
               button.translatesAutoresizingMaskIntoConstraints = NO;
               [button.heightAnchor constraintEqualToConstant:40].active = YES;
               [self.sheGatherSixView addArrangedSubview:button];
           }
       }
    }
    return self;
}

- (void)askPairScore:(UIButton *)sender {
    
    [UIView animateWithDuration:0.25 animations:^{
        self.alpha = 0;
    } completion:^(BOOL finished) {
        [DryPortalManager.shared meteringPeerWindow];
        
        if (self.completion) {
            self.completion(sender.tag);
        }
    }];
}

+ (void)failureBiotinGivenRedSpecifierChecked:(NSString *)title
                        message:(NSString *)message
                   panButOutput:(NSArray<NSString *> *)panButOutput
                     completion:(ChestLeadRoutePairEncodingsMomentary)completion {
    
    EyeAlertView *welsh = [[EyeAlertView alloc] initWithFrame:[UIScreen mainScreen].bounds
                                                 title:title
                                               message:message
                                          panButOutput:panButOutput
                                            completion:completion];
    
    
    [DryPortalManager.shared transitNowToggleBigFaxMacintoshView:welsh];
    
    
    welsh.alpha = 0.0;
    [UIView animateWithDuration:0.25 animations:^{
        welsh.alpha = 1.0;
    }];
}

+ (void)failureBiotinGivenRedSpecifierChecked:(NSString *)title message:(NSString *)message completion:(ChestLeadRoutePairEncodingsMomentary)completion {
    [self failureBiotinGivenRedSpecifierChecked:title message:message panButOutput:@[ReceivedFor.strokeMoveStep.panLoud] completion:completion];
}

@end
