






#import "DogAlertView.h"
#import "CupDenyLeap.h"
#import "CutStringManager.h"
#import "Masonry.h"

#define justWay(fun) __weak typeof(fun) weak##fun = fun;
#define uploadCan(fun) __strong typeof(fun) fun = weak##fun;

@interface DogAlertView()

@property (nonatomic, strong) UIView *installOutsideView;
@property (nonatomic, copy) StayWristPersistGatewaysOurNatural completion;
@property (nonatomic, strong) UIStackView *anyHisBypassView;

@end

@implementation DogAlertView

- (void)dealloc {
    
}

- (instancetype)initWithFrame:(CGRect)frame
                          title:(NSString *)title
                        message:(NSString *)message
                   restoringFax:(NSArray<NSString *> *)restoringFax
                     completion:(StayWristPersistGatewaysOurNatural)completion {
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
        self.completion = completion;
        
        
        self.installOutsideView = [[UIView alloc] init];
        self.installOutsideView.backgroundColor = [CupDenyLeap ringMatchColor];
        self.installOutsideView.layer.cornerRadius = CupDenyLeap.rarePutOther.runCondensed;
        self.installOutsideView.clipsToBounds = YES;
        self.installOutsideView.translatesAutoresizingMaskIntoConstraints = NO;
        [self addSubview:self.installOutsideView];
        
        
        [NSLayoutConstraint activateConstraints:@[
            [self.installOutsideView.centerXAnchor constraintEqualToAnchor:self.centerXAnchor],
            [self.installOutsideView.centerYAnchor constraintEqualToAnchor:self.centerYAnchor],
            [self.installOutsideView.widthAnchor constraintEqualToConstant:270]
        ]];
        
        
        UIView *selectedView = nil;
        CGFloat rateConditionPastServiceEight = 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.installOutsideView addSubview:titleLabel];
            
            [NSLayoutConstraint activateConstraints:@[
                [titleLabel.topAnchor constraintEqualToAnchor:self.installOutsideView.topAnchor constant:rateConditionPastServiceEight],
                [titleLabel.leadingAnchor constraintEqualToAnchor:self.installOutsideView.leadingAnchor constant:16],
                [titleLabel.trailingAnchor constraintEqualToAnchor:self.installOutsideView.trailingAnchor constant:-16]
            ]];
            
            selectedView = titleLabel;
        }
        
        
        if (message.length > 0) {
            UILabel *wayLastLabel = [[UILabel alloc] init];
            wayLastLabel.text = message;
            wayLastLabel.textColor = UIColor.whiteColor;
            wayLastLabel.font = [UIFont systemFontOfSize:15];
            wayLastLabel.textAlignment = NSTextAlignmentCenter;
            wayLastLabel.numberOfLines = 0;
            wayLastLabel.translatesAutoresizingMaskIntoConstraints = NO;
            [self.installOutsideView addSubview:wayLastLabel];
            
            NSLayoutYAxisAnchor *topAnchor = selectedView ? selectedView.bottomAnchor : self.installOutsideView.topAnchor;
            CGFloat barProcess = selectedView ? 10 : rateConditionPastServiceEight;
            [NSLayoutConstraint activateConstraints:@[
                [wayLastLabel.topAnchor constraintEqualToAnchor:topAnchor constant:barProcess],
                [wayLastLabel.leadingAnchor constraintEqualToAnchor:self.installOutsideView.leadingAnchor constant:16],
                [wayLastLabel.trailingAnchor constraintEqualToAnchor:self.installOutsideView.trailingAnchor constant:-16]
            ]];
            selectedView = wayLastLabel;
        }
        
        
        self.anyHisBypassView = [[UIStackView alloc] init];
        self.anyHisBypassView.axis = UILayoutConstraintAxisVertical;
        self.anyHisBypassView.spacing = 1;  
        self.anyHisBypassView.distribution = UIStackViewDistributionFillEqually;
        self.anyHisBypassView.translatesAutoresizingMaskIntoConstraints = NO;
        [self.installOutsideView addSubview:self.anyHisBypassView];
        
        
        NSLayoutYAxisAnchor *rearrangeWetEraserWonDust = selectedView ? selectedView.bottomAnchor : self.installOutsideView.topAnchor;
        CGFloat meanAddressDisparityBorderedSupport = selectedView ? rateConditionPastServiceEight : rateConditionPastServiceEight;
        
        [NSLayoutConstraint activateConstraints:@[
            [self.anyHisBypassView.topAnchor constraintEqualToAnchor:rearrangeWetEraserWonDust constant:meanAddressDisparityBorderedSupport],
            [self.anyHisBypassView.leadingAnchor constraintEqualToAnchor:self.installOutsideView.leadingAnchor],
            [self.anyHisBypassView.trailingAnchor constraintEqualToAnchor:self.installOutsideView.trailingAnchor],
            [self.anyHisBypassView.bottomAnchor constraintEqualToAnchor:self.installOutsideView.bottomAnchor]
        ]];
        
        
       
       if (restoringFax.count == 2) {
           
           self.anyHisBypassView = [[UIStackView alloc] init];
           self.anyHisBypassView.axis = UILayoutConstraintAxisHorizontal;
           self.anyHisBypassView.distribution = UIStackViewDistributionFillEqually;
           self.anyHisBypassView.spacing = 1;  
           self.anyHisBypassView.translatesAutoresizingMaskIntoConstraints = NO;
           [self.installOutsideView addSubview:self.anyHisBypassView];
           
           NSLayoutYAxisAnchor *rearrangeWetEraserWonDust = selectedView ? selectedView.bottomAnchor : self.installOutsideView.topAnchor;
           [NSLayoutConstraint activateConstraints:@[
               [self.anyHisBypassView.topAnchor constraintEqualToAnchor:rearrangeWetEraserWonDust constant:rateConditionPastServiceEight],
               [self.anyHisBypassView.leadingAnchor constraintEqualToAnchor:self.installOutsideView.leadingAnchor],
               [self.anyHisBypassView.trailingAnchor constraintEqualToAnchor:self.installOutsideView.trailingAnchor],
               [self.anyHisBypassView.bottomAnchor constraintEqualToAnchor:self.installOutsideView.bottomAnchor]
           ]];
           
           
           for (NSInteger i = 0; i < restoringFax.count; i++) {
               NSString *official = restoringFax[i];
               UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
               [button setTitle:official forState:UIControlStateNormal];
               button.titleLabel.font = [UIFont systemFontOfSize:17];
               [button setTitleColor:[CupDenyLeap ringMatchColor] forState:UIControlStateNormal];
               [button setTitleColor:UIColor.lightGrayColor forState:UIControlStateHighlighted];
               button.backgroundColor = [UIColor whiteColor];
               button.tag = i;
               [button addTarget:self action:@selector(vowelCatHome:) forControlEvents:UIControlEventTouchUpInside];
               button.translatesAutoresizingMaskIntoConstraints = NO;
               [button.heightAnchor constraintEqualToConstant:40].active = YES;
               [self.anyHisBypassView addArrangedSubview:button];
           }
       } else {
           
           self.anyHisBypassView = [[UIStackView alloc] init];
           self.anyHisBypassView.axis = UILayoutConstraintAxisVertical;
           self.anyHisBypassView.spacing = 1;
           self.anyHisBypassView.distribution = UIStackViewDistributionFillEqually;
           self.anyHisBypassView.translatesAutoresizingMaskIntoConstraints = NO;
           [self.installOutsideView addSubview:self.anyHisBypassView];
           
           NSLayoutYAxisAnchor *rearrangeWetEraserWonDust = selectedView ? selectedView.bottomAnchor : self.installOutsideView.topAnchor;
           [NSLayoutConstraint activateConstraints:@[
               [self.anyHisBypassView.topAnchor constraintEqualToAnchor:rearrangeWetEraserWonDust constant:rateConditionPastServiceEight],
               [self.anyHisBypassView.leadingAnchor constraintEqualToAnchor:self.installOutsideView.leadingAnchor],
               [self.anyHisBypassView.trailingAnchor constraintEqualToAnchor:self.installOutsideView.trailingAnchor],
               [self.anyHisBypassView.bottomAnchor constraintEqualToAnchor:self.installOutsideView.bottomAnchor]
           ]];
           
           for (NSInteger i = 0; i < restoringFax.count; i++) {
               NSString *official = restoringFax[i];
               UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
               [button setTitle:official forState:UIControlStateNormal];
               button.titleLabel.font = [UIFont systemFontOfSize:17];
               [button setTitleColor:[CupDenyLeap ringMatchColor] forState:UIControlStateNormal];
               [button setTitleColor:UIColor.lightGrayColor forState:UIControlStateHighlighted];
               button.backgroundColor = [UIColor whiteColor];
               button.tag = i;
               [button addTarget:self action:@selector(vowelCatHome:) forControlEvents:UIControlEventTouchUpInside];
               button.translatesAutoresizingMaskIntoConstraints = NO;
               [button.heightAnchor constraintEqualToConstant:40].active = YES;
               [self.anyHisBypassView addArrangedSubview:button];
           }
       }
    }
    return self;
}

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

+ (void)issuerIdenticalClangPeriodicPartiallySegue:(NSString *)title
                        message:(NSString *)message
                   restoringFax:(NSArray<NSString *> *)restoringFax
                     completion:(StayWristPersistGatewaysOurNatural)completion {
    
    DogAlertView *boost = [[DogAlertView alloc] initWithFrame:[UIScreen mainScreen].bounds
                                                 title:title
                                               message:message
                                          restoringFax:restoringFax
                                            completion:completion];
    
    
    [CutStringManager.shared systemShipmentUnpluggedGivenRawCircularView:boost];
    
    
    boost.alpha = 0.0;
    [UIView animateWithDuration:0.25 animations:^{
        boost.alpha = 1.0;
    }];
}

+ (void)issuerIdenticalClangPeriodicPartiallySegue:(NSString *)title message:(NSString *)message completion:(StayWristPersistGatewaysOurNatural)completion {
    [self issuerIdenticalClangPeriodicPartiallySegue:title message:message restoringFax:@[CupDenyLeap.cutReuseIcyOur.textKin] completion:completion];
}

@end
