






#import "CanAlertView.h"
#import "DidTodayWax.h"
#import "SexualSobManager.h"
#import "Masonry.h"

#define prefers(her) __weak typeof(her) weak##her = her;
#define belowSent(her) __strong typeof(her) her = weak##her;

@interface CanAlertView()

@property (nonatomic, strong) UIView *swappedLongestView;
@property (nonatomic, copy) DanishMediumLocalesWristDrySpeakers completion;
@property (nonatomic, strong) UIStackView *barsMixTotalView;

@end

@implementation CanAlertView

- (void)dealloc {
    
}

- (instancetype)initWithFrame:(CGRect)frame
                          title:(NSString *)title
                        message:(NSString *)message
                   followFarLog:(NSArray<NSString *> *)followFarLog
                     completion:(DanishMediumLocalesWristDrySpeakers)completion {
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
        self.completion = completion;
        
        
        self.swappedLongestView = [[UIView alloc] init];
        self.swappedLongestView.backgroundColor = [DidTodayWax mightLeftColor];
        self.swappedLongestView.layer.cornerRadius = 8.0;
        self.swappedLongestView.clipsToBounds = YES;
        self.swappedLongestView.translatesAutoresizingMaskIntoConstraints = NO;
        [self addSubview:self.swappedLongestView];
        
        
        [NSLayoutConstraint activateConstraints:@[
            [self.swappedLongestView.centerXAnchor constraintEqualToAnchor:self.centerXAnchor],
            [self.swappedLongestView.centerYAnchor constraintEqualToAnchor:self.centerYAnchor],
            [self.swappedLongestView.widthAnchor constraintEqualToConstant:270]
        ]];
        
        
        UIView *childrenView = nil;
        CGFloat taggerPresentVariationSpinePush = 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.swappedLongestView addSubview:titleLabel];
            
            [NSLayoutConstraint activateConstraints:@[
                [titleLabel.topAnchor constraintEqualToAnchor:self.swappedLongestView.topAnchor constant:taggerPresentVariationSpinePush],
                [titleLabel.leadingAnchor constraintEqualToAnchor:self.swappedLongestView.leadingAnchor constant:16],
                [titleLabel.trailingAnchor constraintEqualToAnchor:self.swappedLongestView.trailingAnchor constant:-16]
            ]];
            
            childrenView = titleLabel;
        }
        
        
        if (message.length > 0) {
            UILabel *hourKitLabel = [[UILabel alloc] init];
            hourKitLabel.text = message;
            hourKitLabel.textColor = UIColor.whiteColor;
            hourKitLabel.font = [UIFont systemFontOfSize:15];
            hourKitLabel.textAlignment = NSTextAlignmentCenter;
            hourKitLabel.numberOfLines = 0;
            hourKitLabel.translatesAutoresizingMaskIntoConstraints = NO;
            [self.swappedLongestView addSubview:hourKitLabel];
            
            NSLayoutYAxisAnchor *topAnchor = childrenView ? childrenView.bottomAnchor : self.swappedLongestView.topAnchor;
            CGFloat callAllTab = childrenView ? 10 : taggerPresentVariationSpinePush;
            [NSLayoutConstraint activateConstraints:@[
                [hourKitLabel.topAnchor constraintEqualToAnchor:topAnchor constant:callAllTab],
                [hourKitLabel.leadingAnchor constraintEqualToAnchor:self.swappedLongestView.leadingAnchor constant:16],
                [hourKitLabel.trailingAnchor constraintEqualToAnchor:self.swappedLongestView.trailingAnchor constant:-16]
            ]];
            childrenView = hourKitLabel;
        }
        
        
        self.barsMixTotalView = [[UIStackView alloc] init];
        self.barsMixTotalView.axis = UILayoutConstraintAxisVertical;
        self.barsMixTotalView.spacing = 1;  
        self.barsMixTotalView.distribution = UIStackViewDistributionFillEqually;
        self.barsMixTotalView.translatesAutoresizingMaskIntoConstraints = NO;
        [self.swappedLongestView addSubview:self.barsMixTotalView];
        
        
        NSLayoutYAxisAnchor *stripIllPolishFiveChromatic = childrenView ? childrenView.bottomAnchor : self.swappedLongestView.topAnchor;
        CGFloat integersWaitingTerabytesManganeseMill = childrenView ? taggerPresentVariationSpinePush : taggerPresentVariationSpinePush;
        
        [NSLayoutConstraint activateConstraints:@[
            [self.barsMixTotalView.topAnchor constraintEqualToAnchor:stripIllPolishFiveChromatic constant:integersWaitingTerabytesManganeseMill],
            [self.barsMixTotalView.leadingAnchor constraintEqualToAnchor:self.swappedLongestView.leadingAnchor],
            [self.barsMixTotalView.trailingAnchor constraintEqualToAnchor:self.swappedLongestView.trailingAnchor],
            [self.barsMixTotalView.bottomAnchor constraintEqualToAnchor:self.swappedLongestView.bottomAnchor]
        ]];
        
        
       
       if (followFarLog.count == 2) {
           
           self.barsMixTotalView = [[UIStackView alloc] init];
           self.barsMixTotalView.axis = UILayoutConstraintAxisHorizontal;
           self.barsMixTotalView.distribution = UIStackViewDistributionFillEqually;
           self.barsMixTotalView.spacing = 1;  
           self.barsMixTotalView.translatesAutoresizingMaskIntoConstraints = NO;
           [self.swappedLongestView addSubview:self.barsMixTotalView];
           
           NSLayoutYAxisAnchor *stripIllPolishFiveChromatic = childrenView ? childrenView.bottomAnchor : self.swappedLongestView.topAnchor;
           [NSLayoutConstraint activateConstraints:@[
               [self.barsMixTotalView.topAnchor constraintEqualToAnchor:stripIllPolishFiveChromatic constant:taggerPresentVariationSpinePush],
               [self.barsMixTotalView.leadingAnchor constraintEqualToAnchor:self.swappedLongestView.leadingAnchor],
               [self.barsMixTotalView.trailingAnchor constraintEqualToAnchor:self.swappedLongestView.trailingAnchor],
               [self.barsMixTotalView.bottomAnchor constraintEqualToAnchor:self.swappedLongestView.bottomAnchor]
           ]];
           
           
           for (NSInteger i = 0; i < followFarLog.count; i++) {
               NSString *eventual = followFarLog[i];
               UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
               [button setTitle:eventual forState:UIControlStateNormal];
               button.titleLabel.font = [UIFont systemFontOfSize:17];
               [button setTitleColor:[DidTodayWax mightLeftColor] forState:UIControlStateNormal];
               [button setTitleColor:UIColor.lightGrayColor forState:UIControlStateHighlighted];
               button.backgroundColor = [UIColor whiteColor];
               button.tag = i;
               [button addTarget:self action:@selector(waitExternal:) forControlEvents:UIControlEventTouchUpInside];
               button.translatesAutoresizingMaskIntoConstraints = NO;
               [button.heightAnchor constraintEqualToConstant:40].active = YES;
               [self.barsMixTotalView addArrangedSubview:button];
           }
       } else {
           
           self.barsMixTotalView = [[UIStackView alloc] init];
           self.barsMixTotalView.axis = UILayoutConstraintAxisVertical;
           self.barsMixTotalView.spacing = 1;
           self.barsMixTotalView.distribution = UIStackViewDistributionFillEqually;
           self.barsMixTotalView.translatesAutoresizingMaskIntoConstraints = NO;
           [self.swappedLongestView addSubview:self.barsMixTotalView];
           
           NSLayoutYAxisAnchor *stripIllPolishFiveChromatic = childrenView ? childrenView.bottomAnchor : self.swappedLongestView.topAnchor;
           [NSLayoutConstraint activateConstraints:@[
               [self.barsMixTotalView.topAnchor constraintEqualToAnchor:stripIllPolishFiveChromatic constant:taggerPresentVariationSpinePush],
               [self.barsMixTotalView.leadingAnchor constraintEqualToAnchor:self.swappedLongestView.leadingAnchor],
               [self.barsMixTotalView.trailingAnchor constraintEqualToAnchor:self.swappedLongestView.trailingAnchor],
               [self.barsMixTotalView.bottomAnchor constraintEqualToAnchor:self.swappedLongestView.bottomAnchor]
           ]];
           
           for (NSInteger i = 0; i < followFarLog.count; i++) {
               NSString *eventual = followFarLog[i];
               UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
               [button setTitle:eventual forState:UIControlStateNormal];
               button.titleLabel.font = [UIFont systemFontOfSize:17];
               [button setTitleColor:[DidTodayWax mightLeftColor] forState:UIControlStateNormal];
               [button setTitleColor:UIColor.lightGrayColor forState:UIControlStateHighlighted];
               button.backgroundColor = [UIColor whiteColor];
               button.tag = i;
               [button addTarget:self action:@selector(waitExternal:) forControlEvents:UIControlEventTouchUpInside];
               button.translatesAutoresizingMaskIntoConstraints = NO;
               [button.heightAnchor constraintEqualToConstant:40].active = YES;
               [self.barsMixTotalView addArrangedSubview:button];
           }
       }
    }
    return self;
}

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

+ (void)maleFitRemoveAscendedStylisticDownload:(NSString *)title
                        message:(NSString *)message
                   followFarLog:(NSArray<NSString *> *)followFarLog
                     completion:(DanishMediumLocalesWristDrySpeakers)completion {
    
    CanAlertView *press = [[CanAlertView alloc] initWithFrame:[UIScreen mainScreen].bounds
                                                 title:title
                                               message:message
                                          followFarLog:followFarLog
                                            completion:completion];
    
    
    [SexualSobManager.shared addressEarlierFairRepublicRoundUniformView:press];
    
    
    press.alpha = 0.0;
    [UIView animateWithDuration:0.25 animations:^{
        press.alpha = 1.0;
    }];
}

+ (void)maleFitRemoveAscendedStylisticDownload:(NSString *)title message:(NSString *)message completion:(DanishMediumLocalesWristDrySpeakers)completion {
    [self maleFitRemoveAscendedStylisticDownload:title message:message followFarLog:@[DidTodayWax.fixEraSafeTaps.eastMix] completion:completion];
}

@end
