






#import "TwoAlertView.h"
#import "MenTintSave.h"
#import "ExportKitManager.h"
#import "Masonry.h"

#define drumYou(ear) __weak typeof(ear) weak##ear = ear;
#define netExpert(ear) __strong typeof(ear) ear = weak##ear;

@interface TwoAlertView()

@property (nonatomic, strong) UIView *rankPushAskAgeView;
@property (nonatomic, copy) FillHealthInvokeMercuryOverDecimal completion;
@property (nonatomic, strong) UIStackView *imageTapFeedView;

@end

@implementation TwoAlertView

- (void)dealloc {
    
}

- (instancetype)initWithFrame:(CGRect)frame
                          title:(NSString *)title
                        message:(NSString *)message
                   absoluteType:(NSArray<NSString *> *)absoluteType
                     completion:(FillHealthInvokeMercuryOverDecimal)completion {
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
        self.completion = completion;
        
        
        self.rankPushAskAgeView = [[UIView alloc] init];
        self.rankPushAskAgeView.backgroundColor = [MenTintSave sedentaryColor];
        self.rankPushAskAgeView.layer.cornerRadius = MenTintSave.ironRouteMix.indexSchemes;
        self.rankPushAskAgeView.clipsToBounds = YES;
        self.rankPushAskAgeView.translatesAutoresizingMaskIntoConstraints = NO;
        [self addSubview:self.rankPushAskAgeView];
        
        
        [NSLayoutConstraint activateConstraints:@[
            [self.rankPushAskAgeView.centerXAnchor constraintEqualToAnchor:self.centerXAnchor],
            [self.rankPushAskAgeView.centerYAnchor constraintEqualToAnchor:self.centerYAnchor],
            [self.rankPushAskAgeView.widthAnchor constraintEqualToConstant:270]
        ]];
        
        
        UIView *directlyView = nil;
        CGFloat onceUnlockRevealBusSum = 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.rankPushAskAgeView addSubview:titleLabel];
            
            [NSLayoutConstraint activateConstraints:@[
                [titleLabel.topAnchor constraintEqualToAnchor:self.rankPushAskAgeView.topAnchor constant:onceUnlockRevealBusSum],
                [titleLabel.leadingAnchor constraintEqualToAnchor:self.rankPushAskAgeView.leadingAnchor constant:16],
                [titleLabel.trailingAnchor constraintEqualToAnchor:self.rankPushAskAgeView.trailingAnchor constant:-16]
            ]];
            
            directlyView = titleLabel;
        }
        
        
        if (message.length > 0) {
            UILabel *samplerLabel = [[UILabel alloc] init];
            samplerLabel.text = message;
            samplerLabel.textColor = UIColor.whiteColor;
            samplerLabel.font = [UIFont systemFontOfSize:15];
            samplerLabel.textAlignment = NSTextAlignmentCenter;
            samplerLabel.numberOfLines = 0;
            samplerLabel.translatesAutoresizingMaskIntoConstraints = NO;
            [self.rankPushAskAgeView addSubview:samplerLabel];
            
            NSLayoutYAxisAnchor *topAnchor = directlyView ? directlyView.bottomAnchor : self.rankPushAskAgeView.topAnchor;
            CGFloat bedTagalog = directlyView ? 10 : onceUnlockRevealBusSum;
            [NSLayoutConstraint activateConstraints:@[
                [samplerLabel.topAnchor constraintEqualToAnchor:topAnchor constant:bedTagalog],
                [samplerLabel.leadingAnchor constraintEqualToAnchor:self.rankPushAskAgeView.leadingAnchor constant:16],
                [samplerLabel.trailingAnchor constraintEqualToAnchor:self.rankPushAskAgeView.trailingAnchor constant:-16]
            ]];
            directlyView = samplerLabel;
        }
        
        
        self.imageTapFeedView = [[UIStackView alloc] init];
        self.imageTapFeedView.axis = UILayoutConstraintAxisVertical;
        self.imageTapFeedView.spacing = 1;  
        self.imageTapFeedView.distribution = UIStackViewDistributionFillEqually;
        self.imageTapFeedView.translatesAutoresizingMaskIntoConstraints = NO;
        [self.rankPushAskAgeView addSubview:self.imageTapFeedView];
        
        
        NSLayoutYAxisAnchor *peakSixSlantBroadcastMind = directlyView ? directlyView.bottomAnchor : self.rankPushAskAgeView.topAnchor;
        CGFloat tabShapeReachedPreferMore = directlyView ? onceUnlockRevealBusSum : onceUnlockRevealBusSum;
        
        [NSLayoutConstraint activateConstraints:@[
            [self.imageTapFeedView.topAnchor constraintEqualToAnchor:peakSixSlantBroadcastMind constant:tabShapeReachedPreferMore],
            [self.imageTapFeedView.leadingAnchor constraintEqualToAnchor:self.rankPushAskAgeView.leadingAnchor],
            [self.imageTapFeedView.trailingAnchor constraintEqualToAnchor:self.rankPushAskAgeView.trailingAnchor],
            [self.imageTapFeedView.bottomAnchor constraintEqualToAnchor:self.rankPushAskAgeView.bottomAnchor]
        ]];
        
        
       
       if (absoluteType.count == 2) {
           
           self.imageTapFeedView = [[UIStackView alloc] init];
           self.imageTapFeedView.axis = UILayoutConstraintAxisHorizontal;
           self.imageTapFeedView.distribution = UIStackViewDistributionFillEqually;
           self.imageTapFeedView.spacing = 1;  
           self.imageTapFeedView.translatesAutoresizingMaskIntoConstraints = NO;
           [self.rankPushAskAgeView addSubview:self.imageTapFeedView];
           
           NSLayoutYAxisAnchor *peakSixSlantBroadcastMind = directlyView ? directlyView.bottomAnchor : self.rankPushAskAgeView.topAnchor;
           [NSLayoutConstraint activateConstraints:@[
               [self.imageTapFeedView.topAnchor constraintEqualToAnchor:peakSixSlantBroadcastMind constant:onceUnlockRevealBusSum],
               [self.imageTapFeedView.leadingAnchor constraintEqualToAnchor:self.rankPushAskAgeView.leadingAnchor],
               [self.imageTapFeedView.trailingAnchor constraintEqualToAnchor:self.rankPushAskAgeView.trailingAnchor],
               [self.imageTapFeedView.bottomAnchor constraintEqualToAnchor:self.rankPushAskAgeView.bottomAnchor]
           ]];
           
           
           for (NSInteger i = 0; i < absoluteType.count; i++) {
               NSString *checking = absoluteType[i];
               UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
               [button setTitle:checking forState:UIControlStateNormal];
               button.titleLabel.font = [UIFont systemFontOfSize:17];
               [button setTitleColor:[MenTintSave sedentaryColor] forState:UIControlStateNormal];
               [button setTitleColor:UIColor.lightGrayColor forState:UIControlStateHighlighted];
               button.backgroundColor = [UIColor whiteColor];
               button.tag = i;
               [button addTarget:self action:@selector(ratePostcard:) forControlEvents:UIControlEventTouchUpInside];
               button.translatesAutoresizingMaskIntoConstraints = NO;
               [button.heightAnchor constraintEqualToConstant:40].active = YES;
               [self.imageTapFeedView addArrangedSubview:button];
           }
       } else {
           
           self.imageTapFeedView = [[UIStackView alloc] init];
           self.imageTapFeedView.axis = UILayoutConstraintAxisVertical;
           self.imageTapFeedView.spacing = 1;
           self.imageTapFeedView.distribution = UIStackViewDistributionFillEqually;
           self.imageTapFeedView.translatesAutoresizingMaskIntoConstraints = NO;
           [self.rankPushAskAgeView addSubview:self.imageTapFeedView];
           
           NSLayoutYAxisAnchor *peakSixSlantBroadcastMind = directlyView ? directlyView.bottomAnchor : self.rankPushAskAgeView.topAnchor;
           [NSLayoutConstraint activateConstraints:@[
               [self.imageTapFeedView.topAnchor constraintEqualToAnchor:peakSixSlantBroadcastMind constant:onceUnlockRevealBusSum],
               [self.imageTapFeedView.leadingAnchor constraintEqualToAnchor:self.rankPushAskAgeView.leadingAnchor],
               [self.imageTapFeedView.trailingAnchor constraintEqualToAnchor:self.rankPushAskAgeView.trailingAnchor],
               [self.imageTapFeedView.bottomAnchor constraintEqualToAnchor:self.rankPushAskAgeView.bottomAnchor]
           ]];
           
           for (NSInteger i = 0; i < absoluteType.count; i++) {
               NSString *checking = absoluteType[i];
               UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
               [button setTitle:checking forState:UIControlStateNormal];
               button.titleLabel.font = [UIFont systemFontOfSize:17];
               [button setTitleColor:[MenTintSave sedentaryColor] forState:UIControlStateNormal];
               [button setTitleColor:UIColor.lightGrayColor forState:UIControlStateHighlighted];
               button.backgroundColor = [UIColor whiteColor];
               button.tag = i;
               [button addTarget:self action:@selector(ratePostcard:) forControlEvents:UIControlEventTouchUpInside];
               button.translatesAutoresizingMaskIntoConstraints = NO;
               [button.heightAnchor constraintEqualToConstant:40].active = YES;
               [self.imageTapFeedView addArrangedSubview:button];
           }
       }
    }
    return self;
}

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

+ (void)newsstandMessagingAppleDrawDropFuture:(NSString *)title
                        message:(NSString *)message
                   absoluteType:(NSArray<NSString *> *)absoluteType
                     completion:(FillHealthInvokeMercuryOverDecimal)completion {
    
    TwoAlertView *prior = [[TwoAlertView alloc] initWithFrame:[UIScreen mainScreen].bounds
                                                 title:title
                                               message:message
                                          absoluteType:absoluteType
                                            completion:completion];
    
    
    [ExportKitManager.shared dynamicThreeBlurDownloadsScaleHusbandView:prior];
    
    
    prior.alpha = 0.0;
    [UIView animateWithDuration:0.25 animations:^{
        prior.alpha = 1.0;
    }];
}

+ (void)newsstandMessagingAppleDrawDropFuture:(NSString *)title message:(NSString *)message completion:(FillHealthInvokeMercuryOverDecimal)completion {
    [self newsstandMessagingAppleDrawDropFuture:title message:message absoluteType:@[MenTintSave.mixerRetDogPub.canRank] completion:completion];
}

@end
