






#import "EndAlertView.h"
#import "RedFlexible.h"
#import "PerformerManager.h"
#import "Masonry.h"

#define noneBar(ret) __weak typeof(ret) weak##ret = ret;
#define foundRoom(ret) __strong typeof(ret) ret = weak##ret;

@interface EndAlertView()

@property (nonatomic, strong) UIView *ligaturesStoodView;
@property (nonatomic, copy) SecondaryBandwidthBiometryEndpointChromeAge completion;
@property (nonatomic, strong) UIStackView *thatFeedbackView;

@end

@implementation EndAlertView

- (void)dealloc {
    
}

- (instancetype)initWithFrame:(CGRect)frame
                          title:(NSString *)title
                        message:(NSString *)message
                   pipeLowAllow:(NSArray<NSString *> *)pipeLowAllow
                     completion:(SecondaryBandwidthBiometryEndpointChromeAge)completion {
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
        self.completion = completion;
        
        
        self.ligaturesStoodView = [[UIView alloc] init];
        self.ligaturesStoodView.backgroundColor = [RedFlexible northTextColor];
        self.ligaturesStoodView.layer.cornerRadius = RedFlexible.capContinued.pinchExtract;
        self.ligaturesStoodView.clipsToBounds = YES;
        self.ligaturesStoodView.translatesAutoresizingMaskIntoConstraints = NO;
        [self addSubview:self.ligaturesStoodView];
        
        
        [NSLayoutConstraint activateConstraints:@[
            [self.ligaturesStoodView.centerXAnchor constraintEqualToAnchor:self.centerXAnchor],
            [self.ligaturesStoodView.centerYAnchor constraintEqualToAnchor:self.centerYAnchor],
            [self.ligaturesStoodView.widthAnchor constraintEqualToConstant:270]
        ]];
        
        
        UIView *charBlurView = nil;
        CGFloat vowelDebuggerPrefersRefusedClosure = 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.ligaturesStoodView addSubview:titleLabel];
            
            [NSLayoutConstraint activateConstraints:@[
                [titleLabel.topAnchor constraintEqualToAnchor:self.ligaturesStoodView.topAnchor constant:vowelDebuggerPrefersRefusedClosure],
                [titleLabel.leadingAnchor constraintEqualToAnchor:self.ligaturesStoodView.leadingAnchor constant:16],
                [titleLabel.trailingAnchor constraintEqualToAnchor:self.ligaturesStoodView.trailingAnchor constant:-16]
            ]];
            
            charBlurView = titleLabel;
        }
        
        
        if (message.length > 0) {
            UILabel *mixDropLabel = [[UILabel alloc] init];
            mixDropLabel.text = message;
            mixDropLabel.textColor = UIColor.whiteColor;
            mixDropLabel.font = [UIFont systemFontOfSize:15];
            mixDropLabel.textAlignment = NSTextAlignmentCenter;
            mixDropLabel.numberOfLines = 0;
            mixDropLabel.translatesAutoresizingMaskIntoConstraints = NO;
            [self.ligaturesStoodView addSubview:mixDropLabel];
            
            NSLayoutYAxisAnchor *topAnchor = charBlurView ? charBlurView.bottomAnchor : self.ligaturesStoodView.topAnchor;
            CGFloat bounceBoth = charBlurView ? 10 : vowelDebuggerPrefersRefusedClosure;
            [NSLayoutConstraint activateConstraints:@[
                [mixDropLabel.topAnchor constraintEqualToAnchor:topAnchor constant:bounceBoth],
                [mixDropLabel.leadingAnchor constraintEqualToAnchor:self.ligaturesStoodView.leadingAnchor constant:16],
                [mixDropLabel.trailingAnchor constraintEqualToAnchor:self.ligaturesStoodView.trailingAnchor constant:-16]
            ]];
            charBlurView = mixDropLabel;
        }
        
        
        self.thatFeedbackView = [[UIStackView alloc] init];
        self.thatFeedbackView.axis = UILayoutConstraintAxisVertical;
        self.thatFeedbackView.spacing = 1;  
        self.thatFeedbackView.distribution = UIStackViewDistributionFillEqually;
        self.thatFeedbackView.translatesAutoresizingMaskIntoConstraints = NO;
        [self.ligaturesStoodView addSubview:self.thatFeedbackView];
        
        
        NSLayoutYAxisAnchor *norwegianAffiliateSensitivePreviewsRaw = charBlurView ? charBlurView.bottomAnchor : self.ligaturesStoodView.topAnchor;
        CGFloat playTrailingRestFirePub = charBlurView ? vowelDebuggerPrefersRefusedClosure : vowelDebuggerPrefersRefusedClosure;
        
        [NSLayoutConstraint activateConstraints:@[
            [self.thatFeedbackView.topAnchor constraintEqualToAnchor:norwegianAffiliateSensitivePreviewsRaw constant:playTrailingRestFirePub],
            [self.thatFeedbackView.leadingAnchor constraintEqualToAnchor:self.ligaturesStoodView.leadingAnchor],
            [self.thatFeedbackView.trailingAnchor constraintEqualToAnchor:self.ligaturesStoodView.trailingAnchor],
            [self.thatFeedbackView.bottomAnchor constraintEqualToAnchor:self.ligaturesStoodView.bottomAnchor]
        ]];
        
        
       
       if (pipeLowAllow.count == 2) {
           
           self.thatFeedbackView = [[UIStackView alloc] init];
           self.thatFeedbackView.axis = UILayoutConstraintAxisHorizontal;
           self.thatFeedbackView.distribution = UIStackViewDistributionFillEqually;
           self.thatFeedbackView.spacing = 1;  
           self.thatFeedbackView.translatesAutoresizingMaskIntoConstraints = NO;
           [self.ligaturesStoodView addSubview:self.thatFeedbackView];
           
           NSLayoutYAxisAnchor *norwegianAffiliateSensitivePreviewsRaw = charBlurView ? charBlurView.bottomAnchor : self.ligaturesStoodView.topAnchor;
           [NSLayoutConstraint activateConstraints:@[
               [self.thatFeedbackView.topAnchor constraintEqualToAnchor:norwegianAffiliateSensitivePreviewsRaw constant:vowelDebuggerPrefersRefusedClosure],
               [self.thatFeedbackView.leadingAnchor constraintEqualToAnchor:self.ligaturesStoodView.leadingAnchor],
               [self.thatFeedbackView.trailingAnchor constraintEqualToAnchor:self.ligaturesStoodView.trailingAnchor],
               [self.thatFeedbackView.bottomAnchor constraintEqualToAnchor:self.ligaturesStoodView.bottomAnchor]
           ]];
           
           
           for (NSInteger i = 0; i < pipeLowAllow.count; i++) {
               NSString *linkKeys = pipeLowAllow[i];
               UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
               [button setTitle:linkKeys forState:UIControlStateNormal];
               button.titleLabel.font = [UIFont systemFontOfSize:17];
               [button setTitleColor:[RedFlexible northTextColor] forState:UIControlStateNormal];
               [button setTitleColor:UIColor.lightGrayColor forState:UIControlStateHighlighted];
               button.backgroundColor = [UIColor whiteColor];
               button.tag = i;
               [button addTarget:self action:@selector(indexTabIcon:) forControlEvents:UIControlEventTouchUpInside];
               button.translatesAutoresizingMaskIntoConstraints = NO;
               [button.heightAnchor constraintEqualToConstant:40].active = YES;
               [self.thatFeedbackView addArrangedSubview:button];
           }
       } else {
           
           self.thatFeedbackView = [[UIStackView alloc] init];
           self.thatFeedbackView.axis = UILayoutConstraintAxisVertical;
           self.thatFeedbackView.spacing = 1;
           self.thatFeedbackView.distribution = UIStackViewDistributionFillEqually;
           self.thatFeedbackView.translatesAutoresizingMaskIntoConstraints = NO;
           [self.ligaturesStoodView addSubview:self.thatFeedbackView];
           
           NSLayoutYAxisAnchor *norwegianAffiliateSensitivePreviewsRaw = charBlurView ? charBlurView.bottomAnchor : self.ligaturesStoodView.topAnchor;
           [NSLayoutConstraint activateConstraints:@[
               [self.thatFeedbackView.topAnchor constraintEqualToAnchor:norwegianAffiliateSensitivePreviewsRaw constant:vowelDebuggerPrefersRefusedClosure],
               [self.thatFeedbackView.leadingAnchor constraintEqualToAnchor:self.ligaturesStoodView.leadingAnchor],
               [self.thatFeedbackView.trailingAnchor constraintEqualToAnchor:self.ligaturesStoodView.trailingAnchor],
               [self.thatFeedbackView.bottomAnchor constraintEqualToAnchor:self.ligaturesStoodView.bottomAnchor]
           ]];
           
           for (NSInteger i = 0; i < pipeLowAllow.count; i++) {
               NSString *linkKeys = pipeLowAllow[i];
               UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
               [button setTitle:linkKeys forState:UIControlStateNormal];
               button.titleLabel.font = [UIFont systemFontOfSize:17];
               [button setTitleColor:[RedFlexible northTextColor] forState:UIControlStateNormal];
               [button setTitleColor:UIColor.lightGrayColor forState:UIControlStateHighlighted];
               button.backgroundColor = [UIColor whiteColor];
               button.tag = i;
               [button addTarget:self action:@selector(indexTabIcon:) forControlEvents:UIControlEventTouchUpInside];
               button.translatesAutoresizingMaskIntoConstraints = NO;
               [button.heightAnchor constraintEqualToConstant:40].active = YES;
               [self.thatFeedbackView addArrangedSubview:button];
           }
       }
    }
    return self;
}

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

+ (void)silenceMountedOverhangThousandTextureCurrency:(NSString *)title
                        message:(NSString *)message
                   pipeLowAllow:(NSArray<NSString *> *)pipeLowAllow
                     completion:(SecondaryBandwidthBiometryEndpointChromeAge)completion {
    
    EndAlertView *agent = [[EndAlertView alloc] initWithFrame:[UIScreen mainScreen].bounds
                                                 title:title
                                               message:message
                                          pipeLowAllow:pipeLowAllow
                                            completion:completion];
    
    
    [PerformerManager.shared twistYetArtsIrishEnsureIterativeView:agent];
    
    
    agent.alpha = 0.0;
    [UIView animateWithDuration:0.25 animations:^{
        agent.alpha = 1.0;
    }];
}

+ (void)silenceMountedOverhangThousandTextureCurrency:(NSString *)title message:(NSString *)message completion:(SecondaryBandwidthBiometryEndpointChromeAge)completion {
    [self silenceMountedOverhangThousandTextureCurrency:title message:message pipeLowAllow:@[RedFlexible.daySentFaxWill.seekCut] completion:completion];
}

@end
