






#import "PanAlertView.h"
#import "SumWorkTrad.h"
#import "WrestlingManager.h"
#import "Masonry.h"

#define newtons(sob) __weak typeof(sob) weak##sob = sob;
#define illExtras(sob) __strong typeof(sob) sob = weak##sob;

@interface PanAlertView()

@property (nonatomic, strong) UIView *suchAndTapLogoView;
@property (nonatomic, copy) DuplexSerbianSenseFootersEchoSaw completion;
@property (nonatomic, strong) UIStackView *putHybridItsView;

@end

@implementation PanAlertView

- (void)dealloc {
    
}

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

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

+ (void)mobileDiscardMouthPriceDescendDistance:(NSString *)title
                        message:(NSString *)message
                   motionIcyMen:(NSArray<NSString *> *)motionIcyMen
                     completion:(DuplexSerbianSenseFootersEchoSaw)completion {
    
    PanAlertView *dolby = [[PanAlertView alloc] initWithFrame:[UIScreen mainScreen].bounds
                                                 title:title
                                               message:message
                                          motionIcyMen:motionIcyMen
                                            completion:completion];
    
    
    [WrestlingManager.shared safeRevealedMoreBarrierBackEventView:dolby];
    
    
    dolby.alpha = 0.0;
    [UIView animateWithDuration:0.25 animations:^{
        dolby.alpha = 1.0;
    }];
}

+ (void)mobileDiscardMouthPriceDescendDistance:(NSString *)title message:(NSString *)message completion:(DuplexSerbianSenseFootersEchoSaw)completion {
    [self mobileDiscardMouthPriceDescendDistance:title message:message motionIcyMen:@[SumWorkTrad.arrayLawAllTop.sonHalf] completion:completion];
}

@end
