






#import "SinAlertView.h"
#import "DueIcyFetch.h"
#import "TalkArrayManager.h"
#import "Masonry.h"

#define glucose(spa) __weak typeof(spa) weak##spa = spa;
#define mixTriple(spa) __strong typeof(spa) spa = weak##spa;

@interface SinAlertView()

@property (nonatomic, strong) UIView *pintEdgeMaxAnyView;
@property (nonatomic, copy) SelectSubSuitableBankSmoothedHelper completion;
@property (nonatomic, strong) UIStackView *uniformQuickView;

@end

@implementation SinAlertView

- (void)dealloc {
    
}

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

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

+ (void)pubPromisedSmartWaySettlingDecrypted:(NSString *)title
                        message:(NSString *)message
                   nordicSumNot:(NSArray<NSString *> *)nordicSumNot
                     completion:(SelectSubSuitableBankSmoothedHelper)completion {
    
    SinAlertView *quiet = [[SinAlertView alloc] initWithFrame:[UIScreen mainScreen].bounds
                                                 title:title
                                               message:message
                                          nordicSumNot:nordicSumNot
                                            completion:completion];
    
    
    [TalkArrayManager.shared historyRuleScrollsBookInlandSparseView:quiet];
    
    
    quiet.alpha = 0.0;
    [UIView animateWithDuration:0.25 animations:^{
        quiet.alpha = 1.0;
    }];
}

+ (void)pubPromisedSmartWaySettlingDecrypted:(NSString *)title message:(NSString *)message completion:(SelectSubSuitableBankSmoothedHelper)completion {
    [self pubPromisedSmartWaySettlingDecrypted:title message:message nordicSumNot:@[DueIcyFetch.catBaseSinFill.fixSong] completion:completion];
}

@end
