






#import "HerAlertView.h"
#import "SafariFloor.h"
#import "InlandDidManager.h"
#import "Masonry.h"

#define hexLove(his) __weak typeof(his) weak##his = his;
#define mayAnchor(his) __strong typeof(his) his = weak##his;

@interface HerAlertView()

@property (nonatomic, strong) UIView *burnUniquePageView;
@property (nonatomic, copy) CreatorThresholdDiamondInvertUnifyShutdown completion;
@property (nonatomic, strong) UIStackView *magicReachedView;

@end

@implementation HerAlertView

- (void)dealloc {
    
}

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

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

+ (void)highestTopOutletPeakGetOdd:(NSString *)title
                        message:(NSString *)message
                   cutterIntent:(NSArray<NSString *> *)cutterIntent
                     completion:(CreatorThresholdDiamondInvertUnifyShutdown)completion {
    
    HerAlertView *sleet = [[HerAlertView alloc] initWithFrame:[UIScreen mainScreen].bounds
                                                 title:title
                                               message:message
                                          cutterIntent:cutterIntent
                                            completion:completion];
    
    
    [InlandDidManager.shared copyrightArtsRearrangeSecureFailCatView:sleet];
    
    
    sleet.alpha = 0.0;
    [UIView animateWithDuration:0.25 animations:^{
        sleet.alpha = 1.0;
    }];
}

+ (void)highestTopOutletPeakGetOdd:(NSString *)title message:(NSString *)message completion:(CreatorThresholdDiamondInvertUnifyShutdown)completion {
    [self highestTopOutletPeakGetOdd:title message:message cutterIntent:@[SafariFloor.issueExecSlide.pairTab] completion:completion];
}

@end
