






#import "AllAlertView.h"
#import "FeedSunTied.h"
#import "TimeClaimManager.h"
#import "Masonry.h"

#define vitamin(own) __weak typeof(own) weak##own = own;
#define peakSlice(own) __strong typeof(own) own = weak##own;

@interface AllAlertView()

@property (nonatomic, strong) UIView *auditTelephoneView;
@property (nonatomic, copy) FractionsIronShuffleDayTheObscures completion;
@property (nonatomic, strong) UIStackView *suffixHexOptView;

@end

@implementation AllAlertView

- (void)dealloc {
    
}

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

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

+ (void)reportingPhotosMileHandTelephotoCoast:(NSString *)title
                        message:(NSString *)message
                   winWakeBreak:(NSArray<NSString *> *)winWakeBreak
                     completion:(FractionsIronShuffleDayTheObscures)completion {
    
    AllAlertView *slant = [[AllAlertView alloc] initWithFrame:[UIScreen mainScreen].bounds
                                                 title:title
                                               message:message
                                          winWakeBreak:winWakeBreak
                                            completion:completion];
    
    
    [TimeClaimManager.shared herArtworkActionDirtyZipEncodingsView:slant];
    
    
    slant.alpha = 0.0;
    [UIView animateWithDuration:0.25 animations:^{
        slant.alpha = 1.0;
    }];
}

+ (void)reportingPhotosMileHandTelephotoCoast:(NSString *)title message:(NSString *)message completion:(FractionsIronShuffleDayTheObscures)completion {
    [self reportingPhotosMileHandTelephotoCoast:title message:message winWakeBreak:@[FeedSunTied.switchEnvelope.wasText] completion:completion];
}

@end
