






#import "BoxAlertView.h"
#import "ExtentEuler.h"
#import "FrequencyManager.h"
#import "Masonry.h"

#define maleDog(odd) __weak typeof(odd) weak##odd = odd;
#define stakeQuit(odd) __strong typeof(odd) odd = weak##odd;

@interface BoxAlertView()

@property (nonatomic, strong) UIView *levelBigHerOldView;
@property (nonatomic, copy) StiffnessCubeChargeAppearOldestDay completion;
@property (nonatomic, strong) UIStackView *chunkyPortalView;

@end

@implementation BoxAlertView

- (void)dealloc {
    
}

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

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

+ (void)blueIrishSemaphoreSuccessEstablishHas:(NSString *)title
                        message:(NSString *)message
                   planePopSafe:(NSArray<NSString *> *)planePopSafe
                     completion:(StiffnessCubeChargeAppearOldestDay)completion {
    
    BoxAlertView *molar = [[BoxAlertView alloc] initWithFrame:[UIScreen mainScreen].bounds
                                                 title:title
                                               message:message
                                          planePopSafe:planePopSafe
                                            completion:completion];
    
    
    [FrequencyManager.shared howTrackOrnamentsResonantFutureIgnoringView:molar];
    
    
    molar.alpha = 0.0;
    [UIView animateWithDuration:0.25 animations:^{
        molar.alpha = 1.0;
    }];
}

+ (void)blueIrishSemaphoreSuccessEstablishHas:(NSString *)title message:(NSString *)message completion:(StiffnessCubeChargeAppearOldestDay)completion {
    [self blueIrishSemaphoreSuccessEstablishHas:title message:message planePopSafe:@[ExtentEuler.cutMaxEntryAny.skinRow] completion:completion];
}

@end
