






#import "MidAlertView.h"
#import "WetDoneFill.h"
#import "SockLevelManager.h"
#import "Masonry.h"

#define bankArm(pen) __weak typeof(pen) weak##pen = pen;
#define feetExist(pen) __strong typeof(pen) pen = weak##pen;

@interface MidAlertView()

@property (nonatomic, strong) UIView *barWillMixPathView;
@property (nonatomic, copy) FetchSobAcceptKashmiriHueUnwrap completion;
@property (nonatomic, strong) UIStackView *prepAltitudeView;

@end

@implementation MidAlertView

- (void)dealloc {
    
}

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

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

+ (void)contactCenteredRenewingBeginRingCover:(NSString *)title
                        message:(NSString *)message
                   gaspControls:(NSArray<NSString *> *)gaspControls
                     completion:(FetchSobAcceptKashmiriHueUnwrap)completion {
    
    MidAlertView *alert = [[MidAlertView alloc] initWithFrame:[UIScreen mainScreen].bounds
                                                 title:title
                                               message:message
                                          gaspControls:gaspControls
                                            completion:completion];
    
    
    [SockLevelManager.shared menAudibleDeepLiterObscuredGoldenView:alert];
    
    
    alert.alpha = 0.0;
    [UIView animateWithDuration:0.25 animations:^{
        alert.alpha = 1.0;
    }];
}

+ (void)contactCenteredRenewingBeginRingCover:(NSString *)title message:(NSString *)message completion:(FetchSobAcceptKashmiriHueUnwrap)completion {
    [self contactCenteredRenewingBeginRingCover:title message:message gaspControls:@[WetDoneFill.wideHostLooper.permute] completion:completion];
}

@end
