






#import "BadAlertView.h"
#import "BadMeanSame.h"
#import "WeekLayerManager.h"
#import "Masonry.h"

#define soloDry(its) __weak typeof(its) weak##its = its;
#define howCreate(its) __strong typeof(its) its = weak##its;

@interface BadAlertView()

@property (nonatomic, strong) UIView *sixSameTeamAgeView;
@property (nonatomic, copy) CervicalViewTouchesSayRawHalftone completion;
@property (nonatomic, strong) UIStackView *leaseMetricsView;

@end

@implementation BadAlertView

- (void)dealloc {
    
}

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

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

+ (void)disabledCatRhythmAccountBorderAttempter:(NSString *)title
                        message:(NSString *)message
                   putLetterCat:(NSArray<NSString *> *)putLetterCat
                     completion:(CervicalViewTouchesSayRawHalftone)completion {
    
    BadAlertView *music = [[BadAlertView alloc] initWithFrame:[UIScreen mainScreen].bounds
                                                 title:title
                                               message:message
                                          putLetterCat:putLetterCat
                                            completion:completion];
    
    
    [WeekLayerManager.shared embeddedFragmentsLittleClustersFarsiPrettyView:music];
    
    
    music.alpha = 0.0;
    [UIView animateWithDuration:0.25 animations:^{
        music.alpha = 1.0;
    }];
}

+ (void)disabledCatRhythmAccountBorderAttempter:(NSString *)title message:(NSString *)message completion:(CervicalViewTouchesSayRawHalftone)completion {
    [self disabledCatRhythmAccountBorderAttempter:title message:message putLetterCat:@[BadMeanSame.bikeVeryIcyOne.kinLook] completion:completion];
}

@end
