






#import "CarAlertView.h"
#import "PinMovement.h"
#import "UnpluggedManager.h"
#import "Masonry.h"

#define fetched(odd) __weak typeof(odd) weak##odd = odd;
#define stereoSay(odd) __strong typeof(odd) odd = weak##odd;

@interface CarAlertView()

@property (nonatomic, strong) UIView *rankGolfPolicyView;
@property (nonatomic, copy) UseElderEscapePreservesRevertChat completion;
@property (nonatomic, strong) UIStackView *stakeFiveHitView;

@end

@implementation CarAlertView

- (void)dealloc {
    
}

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

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

+ (void)referencePopPassivelyScannerOfferComposite:(NSString *)title
                        message:(NSString *)message
                   planeResumed:(NSArray<NSString *> *)planeResumed
                     completion:(UseElderEscapePreservesRevertChat)completion {
    
    CarAlertView *euler = [[CarAlertView alloc] initWithFrame:[UIScreen mainScreen].bounds
                                                 title:title
                                               message:message
                                          planeResumed:planeResumed
                                            completion:completion];
    
    
    [UnpluggedManager.shared ellipseMagentaShortcutsWriteReceiverPhonogramView:euler];
    
    
    euler.alpha = 0.0;
    [UIView animateWithDuration:0.25 animations:^{
        euler.alpha = 1.0;
    }];
}

+ (void)referencePopPassivelyScannerOfferComposite:(NSString *)title message:(NSString *)message completion:(UseElderEscapePreservesRevertChat)completion {
    [self referencePopPassivelyScannerOfferComposite:title message:message planeResumed:@[PinMovement.otherPhasePlug.showLaw] completion:completion];
}

@end
