






#import "AddAlertView.h"
#import "HourEllipse.h"
#import "CountHostManager.h"
#import "Masonry.h"

#define moreToo(ten) __weak typeof(ten) weak##ten = ten;
#define cursorPen(ten) __strong typeof(ten) ten = weak##ten;

@interface AddAlertView()

@property (nonatomic, strong) UIView *tapSignCarOnlyView;
@property (nonatomic, copy) RestoringKerningHasReservedEraserAction completion;
@property (nonatomic, strong) UIStackView *sundaneseIllView;

@end

@implementation AddAlertView

- (void)dealloc {
    
}

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

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

+ (void)millionCorrectedPromiseOverageHardNow:(NSString *)title
                        message:(NSString *)message
                   flemishChina:(NSArray<NSString *> *)flemishChina
                     completion:(RestoringKerningHasReservedEraserAction)completion {
    
    AddAlertView *adopt = [[AddAlertView alloc] initWithFrame:[UIScreen mainScreen].bounds
                                                 title:title
                                               message:message
                                          flemishChina:flemishChina
                                            completion:completion];
    
    
    [CountHostManager.shared megahertzAmharicEnableStringSuchJustifiedView:adopt];
    
    
    adopt.alpha = 0.0;
    [UIView animateWithDuration:0.25 animations:^{
        adopt.alpha = 1.0;
    }];
}

+ (void)millionCorrectedPromiseOverageHardNow:(NSString *)title message:(NSString *)message completion:(RestoringKerningHasReservedEraserAction)completion {
    [self millionCorrectedPromiseOverageHardNow:title message:message flemishChina:@[HourEllipse.alienSemaphore.selfPop] completion:completion];
}

@end
