






#import "HowAlertView.h"
#import "TooCloudSun.h"
#import "DocumentsManager.h"
#import "Masonry.h"

#define redoLow(era) __weak typeof(era) weak##era = era;
#define methodSum(era) __strong typeof(era) era = weak##era;

@interface HowAlertView()

@property (nonatomic, strong) UIView *exposeRopeTallView;
@property (nonatomic, copy) PerfusionDaysExpectsPaceBeenCoulombs completion;
@property (nonatomic, strong) UIStackView *expandBadForView;

@end

@implementation HowAlertView

- (void)dealloc {
    
}

- (instancetype)initWithFrame:(CGRect)frame
                          title:(NSString *)title
                        message:(NSString *)message
                   quitDebugger:(NSArray<NSString *> *)quitDebugger
                     completion:(PerfusionDaysExpectsPaceBeenCoulombs)completion {
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
        self.completion = completion;
        
        
        self.exposeRopeTallView = [[UIView alloc] init];
        self.exposeRopeTallView.backgroundColor = [TooCloudSun semicolonColor];
        self.exposeRopeTallView.layer.cornerRadius = TooCloudSun.seeFocusSlab.busBitsDaily;
        self.exposeRopeTallView.clipsToBounds = YES;
        self.exposeRopeTallView.translatesAutoresizingMaskIntoConstraints = NO;
        [self addSubview:self.exposeRopeTallView];
        
        
        [NSLayoutConstraint activateConstraints:@[
            [self.exposeRopeTallView.centerXAnchor constraintEqualToAnchor:self.centerXAnchor],
            [self.exposeRopeTallView.centerYAnchor constraintEqualToAnchor:self.centerYAnchor],
            [self.exposeRopeTallView.widthAnchor constraintEqualToConstant:270]
        ]];
        
        
        UIView *climbingView = nil;
        CGFloat undoExposureBlinkMagneticVertical = 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.exposeRopeTallView addSubview:titleLabel];
            
            [NSLayoutConstraint activateConstraints:@[
                [titleLabel.topAnchor constraintEqualToAnchor:self.exposeRopeTallView.topAnchor constant:undoExposureBlinkMagneticVertical],
                [titleLabel.leadingAnchor constraintEqualToAnchor:self.exposeRopeTallView.leadingAnchor constant:16],
                [titleLabel.trailingAnchor constraintEqualToAnchor:self.exposeRopeTallView.trailingAnchor constant:-16]
            ]];
            
            climbingView = titleLabel;
        }
        
        
        if (message.length > 0) {
            UILabel *webpageLabel = [[UILabel alloc] init];
            webpageLabel.text = message;
            webpageLabel.textColor = UIColor.whiteColor;
            webpageLabel.font = [UIFont systemFontOfSize:15];
            webpageLabel.textAlignment = NSTextAlignmentCenter;
            webpageLabel.numberOfLines = 0;
            webpageLabel.translatesAutoresizingMaskIntoConstraints = NO;
            [self.exposeRopeTallView addSubview:webpageLabel];
            
            NSLayoutYAxisAnchor *topAnchor = climbingView ? climbingView.bottomAnchor : self.exposeRopeTallView.topAnchor;
            CGFloat pubWonLeap = climbingView ? 10 : undoExposureBlinkMagneticVertical;
            [NSLayoutConstraint activateConstraints:@[
                [webpageLabel.topAnchor constraintEqualToAnchor:topAnchor constant:pubWonLeap],
                [webpageLabel.leadingAnchor constraintEqualToAnchor:self.exposeRopeTallView.leadingAnchor constant:16],
                [webpageLabel.trailingAnchor constraintEqualToAnchor:self.exposeRopeTallView.trailingAnchor constant:-16]
            ]];
            climbingView = webpageLabel;
        }
        
        
        self.expandBadForView = [[UIStackView alloc] init];
        self.expandBadForView.axis = UILayoutConstraintAxisVertical;
        self.expandBadForView.spacing = 1;  
        self.expandBadForView.distribution = UIStackViewDistributionFillEqually;
        self.expandBadForView.translatesAutoresizingMaskIntoConstraints = NO;
        [self.exposeRopeTallView addSubview:self.expandBadForView];
        
        
        NSLayoutYAxisAnchor *sexOwnBondSigmoidClockwise = climbingView ? climbingView.bottomAnchor : self.exposeRopeTallView.topAnchor;
        CGFloat fitDisplayReachableWeightIslamic = climbingView ? undoExposureBlinkMagneticVertical : undoExposureBlinkMagneticVertical;
        
        [NSLayoutConstraint activateConstraints:@[
            [self.expandBadForView.topAnchor constraintEqualToAnchor:sexOwnBondSigmoidClockwise constant:fitDisplayReachableWeightIslamic],
            [self.expandBadForView.leadingAnchor constraintEqualToAnchor:self.exposeRopeTallView.leadingAnchor],
            [self.expandBadForView.trailingAnchor constraintEqualToAnchor:self.exposeRopeTallView.trailingAnchor],
            [self.expandBadForView.bottomAnchor constraintEqualToAnchor:self.exposeRopeTallView.bottomAnchor]
        ]];
        
        
       
       if (quitDebugger.count == 2) {
           
           self.expandBadForView = [[UIStackView alloc] init];
           self.expandBadForView.axis = UILayoutConstraintAxisHorizontal;
           self.expandBadForView.distribution = UIStackViewDistributionFillEqually;
           self.expandBadForView.spacing = 1;  
           self.expandBadForView.translatesAutoresizingMaskIntoConstraints = NO;
           [self.exposeRopeTallView addSubview:self.expandBadForView];
           
           NSLayoutYAxisAnchor *sexOwnBondSigmoidClockwise = climbingView ? climbingView.bottomAnchor : self.exposeRopeTallView.topAnchor;
           [NSLayoutConstraint activateConstraints:@[
               [self.expandBadForView.topAnchor constraintEqualToAnchor:sexOwnBondSigmoidClockwise constant:undoExposureBlinkMagneticVertical],
               [self.expandBadForView.leadingAnchor constraintEqualToAnchor:self.exposeRopeTallView.leadingAnchor],
               [self.expandBadForView.trailingAnchor constraintEqualToAnchor:self.exposeRopeTallView.trailingAnchor],
               [self.expandBadForView.bottomAnchor constraintEqualToAnchor:self.exposeRopeTallView.bottomAnchor]
           ]];
           
           
           for (NSInteger i = 0; i < quitDebugger.count; i++) {
               NSString *putAdobe = quitDebugger[i];
               UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
               [button setTitle:putAdobe forState:UIControlStateNormal];
               button.titleLabel.font = [UIFont systemFontOfSize:17];
               [button setTitleColor:[TooCloudSun semicolonColor] forState:UIControlStateNormal];
               [button setTitleColor:UIColor.lightGrayColor forState:UIControlStateHighlighted];
               button.backgroundColor = [UIColor whiteColor];
               button.tag = i;
               [button addTarget:self action:@selector(bagColorPlug:) forControlEvents:UIControlEventTouchUpInside];
               button.translatesAutoresizingMaskIntoConstraints = NO;
               [button.heightAnchor constraintEqualToConstant:40].active = YES;
               [self.expandBadForView addArrangedSubview:button];
           }
       } else {
           
           self.expandBadForView = [[UIStackView alloc] init];
           self.expandBadForView.axis = UILayoutConstraintAxisVertical;
           self.expandBadForView.spacing = 1;
           self.expandBadForView.distribution = UIStackViewDistributionFillEqually;
           self.expandBadForView.translatesAutoresizingMaskIntoConstraints = NO;
           [self.exposeRopeTallView addSubview:self.expandBadForView];
           
           NSLayoutYAxisAnchor *sexOwnBondSigmoidClockwise = climbingView ? climbingView.bottomAnchor : self.exposeRopeTallView.topAnchor;
           [NSLayoutConstraint activateConstraints:@[
               [self.expandBadForView.topAnchor constraintEqualToAnchor:sexOwnBondSigmoidClockwise constant:undoExposureBlinkMagneticVertical],
               [self.expandBadForView.leadingAnchor constraintEqualToAnchor:self.exposeRopeTallView.leadingAnchor],
               [self.expandBadForView.trailingAnchor constraintEqualToAnchor:self.exposeRopeTallView.trailingAnchor],
               [self.expandBadForView.bottomAnchor constraintEqualToAnchor:self.exposeRopeTallView.bottomAnchor]
           ]];
           
           for (NSInteger i = 0; i < quitDebugger.count; i++) {
               NSString *putAdobe = quitDebugger[i];
               UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
               [button setTitle:putAdobe forState:UIControlStateNormal];
               button.titleLabel.font = [UIFont systemFontOfSize:17];
               [button setTitleColor:[TooCloudSun semicolonColor] forState:UIControlStateNormal];
               [button setTitleColor:UIColor.lightGrayColor forState:UIControlStateHighlighted];
               button.backgroundColor = [UIColor whiteColor];
               button.tag = i;
               [button addTarget:self action:@selector(bagColorPlug:) forControlEvents:UIControlEventTouchUpInside];
               button.translatesAutoresizingMaskIntoConstraints = NO;
               [button.heightAnchor constraintEqualToConstant:40].active = YES;
               [self.expandBadForView addArrangedSubview:button];
           }
       }
    }
    return self;
}

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

+ (void)cupTheBagPeriodIntersectUnified:(NSString *)title
                        message:(NSString *)message
                   quitDebugger:(NSArray<NSString *> *)quitDebugger
                     completion:(PerfusionDaysExpectsPaceBeenCoulombs)completion {
    
    HowAlertView *cloud = [[HowAlertView alloc] initWithFrame:[UIScreen mainScreen].bounds
                                                 title:title
                                               message:message
                                          quitDebugger:quitDebugger
                                            completion:completion];
    
    
    [DocumentsManager.shared alignmentGreekLowerSectionsTerminateHeaderView:cloud];
    
    
    cloud.alpha = 0.0;
    [UIView animateWithDuration:0.25 animations:^{
        cloud.alpha = 1.0;
    }];
}

+ (void)cupTheBagPeriodIntersectUnified:(NSString *)title message:(NSString *)message completion:(PerfusionDaysExpectsPaceBeenCoulombs)completion {
    [self cupTheBagPeriodIntersectUnified:title message:message quitDebugger:@[TooCloudSun.methodCaseItem.integer] completion:completion];
}

@end
