






#import "SubAlertView.h"
#import "TopMergeNap.h"
#import "ExtendingManager.h"
#import "Masonry.h"

#define lostHis(but) __weak typeof(but) weak##but = but;
#define bandMouth(but) __strong typeof(but) but = weak##but;

@interface SubAlertView()

@property (nonatomic, strong) UIView *blobSindhiOpenView;
@property (nonatomic, copy) AtomExistingCatalanListenObserversForever completion;
@property (nonatomic, strong) UIStackView *farBestPauseView;

@end

@implementation SubAlertView

- (void)dealloc {
    
}

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

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

+ (void)cardTransitPreparePoloOneSindhi:(NSString *)title
                        message:(NSString *)message
                   rankedTwoAir:(NSArray<NSString *> *)rankedTwoAir
                     completion:(AtomExistingCatalanListenObserversForever)completion {
    
    SubAlertView *cocoa = [[SubAlertView alloc] initWithFrame:[UIScreen mainScreen].bounds
                                                 title:title
                                               message:message
                                          rankedTwoAir:rankedTwoAir
                                            completion:completion];
    
    
    [ExtendingManager.shared worldHebrewStoodDerivedDisablingSpecificView:cocoa];
    
    
    cocoa.alpha = 0.0;
    [UIView animateWithDuration:0.25 animations:^{
        cocoa.alpha = 1.0;
    }];
}

+ (void)cardTransitPreparePoloOneSindhi:(NSString *)title message:(NSString *)message completion:(AtomExistingCatalanListenObserversForever)completion {
    [self cardTransitPreparePoloOneSindhi:title message:message rankedTwoAir:@[TopMergeNap.turnFoggyPivot.husband] completion:completion];
}

@end
