






#import "IllAlertView.h"
#import "ZipRestThat.h"
#import "DigitSongManager.h"
#import "Masonry.h"

#define kurdish(ask) __weak typeof(ask) weak##ask = ask;
#define panelRank(ask) __strong typeof(ask) ask = weak##ask;

@interface IllAlertView()

@property (nonatomic, strong) UIView *balanceAlignedView;
@property (nonatomic, copy) GolfEnsureSawOutcomeMalformedProfiles completion;
@property (nonatomic, strong) UIStackView *hindiHairTryView;

@end

@implementation IllAlertView

- (void)dealloc {
    
}

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

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

+ (void)outsideTwistCenteredEmergencyIntegersLose:(NSString *)title
                        message:(NSString *)message
                   guestHasLoud:(NSArray<NSString *> *)guestHasLoud
                     completion:(GolfEnsureSawOutcomeMalformedProfiles)completion {
    
    IllAlertView *stamp = [[IllAlertView alloc] initWithFrame:[UIScreen mainScreen].bounds
                                                 title:title
                                               message:message
                                          guestHasLoud:guestHasLoud
                                            completion:completion];
    
    
    [DigitSongManager.shared mobileSchoolTeaspoonsHueCellphoneHeartbeatView:stamp];
    
    
    stamp.alpha = 0.0;
    [UIView animateWithDuration:0.25 animations:^{
        stamp.alpha = 1.0;
    }];
}

+ (void)outsideTwistCenteredEmergencyIntegersLose:(NSString *)title message:(NSString *)message completion:(GolfEnsureSawOutcomeMalformedProfiles)completion {
    [self outsideTwistCenteredEmergencyIntegersLose:title message:message guestHasLoud:@[ZipRestThat.useCatAliveLow.openEnd] completion:completion];
}

@end
