






#import "WasAlertView.h"
#import "ReloadThird.h"
#import "ManualCupManager.h"
#import "Masonry.h"

#define lawRoom(far) __weak typeof(far) weak##far = far;
#define altimeter(far) __strong typeof(far) far = weak##far;

@interface WasAlertView()

@property (nonatomic, strong) UIView *waxTextWetNodeView;
@property (nonatomic, copy) CellBordersConductorTerminateSettlingMegabits completion;
@property (nonatomic, strong) UIStackView *paddleMemberView;

@end

@implementation WasAlertView

- (void)dealloc {
    
}

- (instancetype)initWithFrame:(CGRect)frame
                          title:(NSString *)title
                        message:(NSString *)message
                   addLegacyHer:(NSArray<NSString *> *)addLegacyHer
                     completion:(CellBordersConductorTerminateSettlingMegabits)completion {
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
        self.completion = completion;
        
        
        self.waxTextWetNodeView = [[UIView alloc] init];
        self.waxTextWetNodeView.backgroundColor = [ReloadThird fairBlockColor];
        self.waxTextWetNodeView.layer.cornerRadius = ReloadThird.overlapQuote.drivenEndLog;
        self.waxTextWetNodeView.clipsToBounds = YES;
        self.waxTextWetNodeView.translatesAutoresizingMaskIntoConstraints = NO;
        [self addSubview:self.waxTextWetNodeView];
        
        
        [NSLayoutConstraint activateConstraints:@[
            [self.waxTextWetNodeView.centerXAnchor constraintEqualToAnchor:self.centerXAnchor],
            [self.waxTextWetNodeView.centerYAnchor constraintEqualToAnchor:self.centerYAnchor],
            [self.waxTextWetNodeView.widthAnchor constraintEqualToConstant:270]
        ]];
        
        
        UIView *easyMileView = nil;
        CGFloat busCapturedDismissalProjectLike = 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.waxTextWetNodeView addSubview:titleLabel];
            
            [NSLayoutConstraint activateConstraints:@[
                [titleLabel.topAnchor constraintEqualToAnchor:self.waxTextWetNodeView.topAnchor constant:busCapturedDismissalProjectLike],
                [titleLabel.leadingAnchor constraintEqualToAnchor:self.waxTextWetNodeView.leadingAnchor constant:16],
                [titleLabel.trailingAnchor constraintEqualToAnchor:self.waxTextWetNodeView.trailingAnchor constant:-16]
            ]];
            
            easyMileView = titleLabel;
        }
        
        
        if (message.length > 0) {
            UILabel *dateDidLabel = [[UILabel alloc] init];
            dateDidLabel.text = message;
            dateDidLabel.textColor = UIColor.whiteColor;
            dateDidLabel.font = [UIFont systemFontOfSize:15];
            dateDidLabel.textAlignment = NSTextAlignmentCenter;
            dateDidLabel.numberOfLines = 0;
            dateDidLabel.translatesAutoresizingMaskIntoConstraints = NO;
            [self.waxTextWetNodeView addSubview:dateDidLabel];
            
            NSLayoutYAxisAnchor *topAnchor = easyMileView ? easyMileView.bottomAnchor : self.waxTextWetNodeView.topAnchor;
            CGFloat useNowPink = easyMileView ? 10 : busCapturedDismissalProjectLike;
            [NSLayoutConstraint activateConstraints:@[
                [dateDidLabel.topAnchor constraintEqualToAnchor:topAnchor constant:useNowPink],
                [dateDidLabel.leadingAnchor constraintEqualToAnchor:self.waxTextWetNodeView.leadingAnchor constant:16],
                [dateDidLabel.trailingAnchor constraintEqualToAnchor:self.waxTextWetNodeView.trailingAnchor constant:-16]
            ]];
            easyMileView = dateDidLabel;
        }
        
        
        self.paddleMemberView = [[UIStackView alloc] init];
        self.paddleMemberView.axis = UILayoutConstraintAxisVertical;
        self.paddleMemberView.spacing = 1;  
        self.paddleMemberView.distribution = UIStackViewDistributionFillEqually;
        self.paddleMemberView.translatesAutoresizingMaskIntoConstraints = NO;
        [self.waxTextWetNodeView addSubview:self.paddleMemberView];
        
        
        NSLayoutYAxisAnchor *lightenOriginProximityPreventShrink = easyMileView ? easyMileView.bottomAnchor : self.waxTextWetNodeView.topAnchor;
        CGFloat insetUsageCaffeineHelperDatabase = easyMileView ? busCapturedDismissalProjectLike : busCapturedDismissalProjectLike;
        
        [NSLayoutConstraint activateConstraints:@[
            [self.paddleMemberView.topAnchor constraintEqualToAnchor:lightenOriginProximityPreventShrink constant:insetUsageCaffeineHelperDatabase],
            [self.paddleMemberView.leadingAnchor constraintEqualToAnchor:self.waxTextWetNodeView.leadingAnchor],
            [self.paddleMemberView.trailingAnchor constraintEqualToAnchor:self.waxTextWetNodeView.trailingAnchor],
            [self.paddleMemberView.bottomAnchor constraintEqualToAnchor:self.waxTextWetNodeView.bottomAnchor]
        ]];
        
        
       
       if (addLegacyHer.count == 2) {
           
           self.paddleMemberView = [[UIStackView alloc] init];
           self.paddleMemberView.axis = UILayoutConstraintAxisHorizontal;
           self.paddleMemberView.distribution = UIStackViewDistributionFillEqually;
           self.paddleMemberView.spacing = 1;  
           self.paddleMemberView.translatesAutoresizingMaskIntoConstraints = NO;
           [self.waxTextWetNodeView addSubview:self.paddleMemberView];
           
           NSLayoutYAxisAnchor *lightenOriginProximityPreventShrink = easyMileView ? easyMileView.bottomAnchor : self.waxTextWetNodeView.topAnchor;
           [NSLayoutConstraint activateConstraints:@[
               [self.paddleMemberView.topAnchor constraintEqualToAnchor:lightenOriginProximityPreventShrink constant:busCapturedDismissalProjectLike],
               [self.paddleMemberView.leadingAnchor constraintEqualToAnchor:self.waxTextWetNodeView.leadingAnchor],
               [self.paddleMemberView.trailingAnchor constraintEqualToAnchor:self.waxTextWetNodeView.trailingAnchor],
               [self.paddleMemberView.bottomAnchor constraintEqualToAnchor:self.waxTextWetNodeView.bottomAnchor]
           ]];
           
           
           for (NSInteger i = 0; i < addLegacyHer.count; i++) {
               NSString *acuteKey = addLegacyHer[i];
               UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
               [button setTitle:acuteKey forState:UIControlStateNormal];
               button.titleLabel.font = [UIFont systemFontOfSize:17];
               [button setTitleColor:[ReloadThird fairBlockColor] forState:UIControlStateNormal];
               [button setTitleColor:UIColor.lightGrayColor forState:UIControlStateHighlighted];
               button.backgroundColor = [UIColor whiteColor];
               button.tag = i;
               [button addTarget:self action:@selector(accordingToo:) forControlEvents:UIControlEventTouchUpInside];
               button.translatesAutoresizingMaskIntoConstraints = NO;
               [button.heightAnchor constraintEqualToConstant:40].active = YES;
               [self.paddleMemberView addArrangedSubview:button];
           }
       } else {
           
           self.paddleMemberView = [[UIStackView alloc] init];
           self.paddleMemberView.axis = UILayoutConstraintAxisVertical;
           self.paddleMemberView.spacing = 1;
           self.paddleMemberView.distribution = UIStackViewDistributionFillEqually;
           self.paddleMemberView.translatesAutoresizingMaskIntoConstraints = NO;
           [self.waxTextWetNodeView addSubview:self.paddleMemberView];
           
           NSLayoutYAxisAnchor *lightenOriginProximityPreventShrink = easyMileView ? easyMileView.bottomAnchor : self.waxTextWetNodeView.topAnchor;
           [NSLayoutConstraint activateConstraints:@[
               [self.paddleMemberView.topAnchor constraintEqualToAnchor:lightenOriginProximityPreventShrink constant:busCapturedDismissalProjectLike],
               [self.paddleMemberView.leadingAnchor constraintEqualToAnchor:self.waxTextWetNodeView.leadingAnchor],
               [self.paddleMemberView.trailingAnchor constraintEqualToAnchor:self.waxTextWetNodeView.trailingAnchor],
               [self.paddleMemberView.bottomAnchor constraintEqualToAnchor:self.waxTextWetNodeView.bottomAnchor]
           ]];
           
           for (NSInteger i = 0; i < addLegacyHer.count; i++) {
               NSString *acuteKey = addLegacyHer[i];
               UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
               [button setTitle:acuteKey forState:UIControlStateNormal];
               button.titleLabel.font = [UIFont systemFontOfSize:17];
               [button setTitleColor:[ReloadThird fairBlockColor] forState:UIControlStateNormal];
               [button setTitleColor:UIColor.lightGrayColor forState:UIControlStateHighlighted];
               button.backgroundColor = [UIColor whiteColor];
               button.tag = i;
               [button addTarget:self action:@selector(accordingToo:) forControlEvents:UIControlEventTouchUpInside];
               button.translatesAutoresizingMaskIntoConstraints = NO;
               [button.heightAnchor constraintEqualToConstant:40].active = YES;
               [self.paddleMemberView addArrangedSubview:button];
           }
       }
    }
    return self;
}

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

+ (void)styleAppendingDueSurgePascalReady:(NSString *)title
                        message:(NSString *)message
                   addLegacyHer:(NSArray<NSString *> *)addLegacyHer
                     completion:(CellBordersConductorTerminateSettlingMegabits)completion {
    
    WasAlertView *radio = [[WasAlertView alloc] initWithFrame:[UIScreen mainScreen].bounds
                                                 title:title
                                               message:message
                                          addLegacyHer:addLegacyHer
                                            completion:completion];
    
    
    [ManualCupManager.shared pressedHasWelshCalendarIntervalDoneView:radio];
    
    
    radio.alpha = 0.0;
    [UIView animateWithDuration:0.25 animations:^{
        radio.alpha = 1.0;
    }];
}

+ (void)styleAppendingDueSurgePascalReady:(NSString *)title message:(NSString *)message completion:(CellBordersConductorTerminateSettlingMegabits)completion {
    [self styleAppendingDueSurgePascalReady:title message:message addLegacyHer:@[ReloadThird.phoneKitTenTen.anyFlip] completion:completion];
}

@end
