






#import "BinAlertView.h"
#import "FixMaterial.h"
#import "NextBeganManager.h"
#import "Masonry.h"

#define sheLess(ill) __weak typeof(ill) weak##ill = ill;
#define condensed(ill) __strong typeof(ill) ill = weak##ill;

@interface BinAlertView()

@property (nonatomic, strong) UIView *cocoaYardQueueView;
@property (nonatomic, copy) TrainerImplicitWorkJustifiedFirstQuit completion;
@property (nonatomic, strong) UIStackView *syntaxSeeRetView;

@end

@implementation BinAlertView

- (void)dealloc {
    
}

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

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

+ (void)bigUnboundedMaintainUnpluggedTargetGrouped:(NSString *)title
                        message:(NSString *)message
                   sixPerformed:(NSArray<NSString *> *)sixPerformed
                     completion:(TrainerImplicitWorkJustifiedFirstQuit)completion {
    
    BinAlertView *splat = [[BinAlertView alloc] initWithFrame:[UIScreen mainScreen].bounds
                                                 title:title
                                               message:message
                                          sixPerformed:sixPerformed
                                            completion:completion];
    
    
    [NextBeganManager.shared poloStaticGatheringPhraseOwnerCheckoutView:splat];
    
    
    splat.alpha = 0.0;
    [UIView animateWithDuration:0.25 animations:^{
        splat.alpha = 1.0;
    }];
}

+ (void)bigUnboundedMaintainUnpluggedTargetGrouped:(NSString *)title message:(NSString *)message completion:(TrainerImplicitWorkJustifiedFirstQuit)completion {
    [self bigUnboundedMaintainUnpluggedTargetGrouped:title message:message sixPerformed:@[FixMaterial.dryMicroCapTag.working] completion:completion];
}

@end
