






#import "PutAlertView.h"
#import "AffectedBus.h"
#import "FutureDryManager.h"
#import "Masonry.h"

#define clipSin(pub) __weak typeof(pub) weak##pub = pub;
#define rootFinal(pub) __strong typeof(pub) pub = weak##pub;

@interface PutAlertView()

@property (nonatomic, strong) UIView *whoAddFunkPlugView;
@property (nonatomic, copy) DecigramsCompressDirtyMisplacedOptTracking completion;
@property (nonatomic, strong) UIStackView *sendThickMaxView;

@end

@implementation PutAlertView

- (void)dealloc {
    
}

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

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

+ (void)chromaticFlashSubsetRealmAndAre:(NSString *)title
                        message:(NSString *)message
                   poloAllSegue:(NSArray<NSString *> *)poloAllSegue
                     completion:(DecigramsCompressDirtyMisplacedOptTracking)completion {
    
    PutAlertView *dolby = [[PutAlertView alloc] initWithFrame:[UIScreen mainScreen].bounds
                                                 title:title
                                               message:message
                                          poloAllSegue:poloAllSegue
                                            completion:completion];
    
    
    [FutureDryManager.shared cubeHavePenTwoJapaneseAllView:dolby];
    
    
    dolby.alpha = 0.0;
    [UIView animateWithDuration:0.25 animations:^{
        dolby.alpha = 1.0;
    }];
}

+ (void)chromaticFlashSubsetRealmAndAre:(NSString *)title message:(NSString *)message completion:(DecigramsCompressDirtyMisplacedOptTracking)completion {
    [self chromaticFlashSubsetRealmAndAre:title message:message poloAllSegue:@[AffectedBus.delayOceanMale.allPink] completion:completion];
}

@end
