






#import "CatAlertView.h"
#import "HisGeometry.h"
#import "FarEntityManager.h"
#import "Masonry.h"

#define waxReal(wax) __weak typeof(wax) weak##wax = wax;
#define caseStrip(wax) __strong typeof(wax) wax = weak##wax;

@interface CatAlertView()

@property (nonatomic, strong) UIView *mostClipRunRetView;
@property (nonatomic, copy) CapturesAmbiguousHeadsetAlpineExcludedOptional completion;
@property (nonatomic, strong) UIStackView *beaconsClockView;

@end

@implementation CatAlertView

- (void)dealloc {
    
}

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

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

+ (void)encodedSilenceUptimeWasScanningGray:(NSString *)title
                        message:(NSString *)message
                   minDivideCat:(NSArray<NSString *> *)minDivideCat
                     completion:(CapturesAmbiguousHeadsetAlpineExcludedOptional)completion {
    
    CatAlertView *entry = [[CatAlertView alloc] initWithFrame:[UIScreen mainScreen].bounds
                                                 title:title
                                               message:message
                                          minDivideCat:minDivideCat
                                            completion:completion];
    
    
    [FarEntityManager.shared spaceInteractThousandIdleDiscoverTeethView:entry];
    
    
    entry.alpha = 0.0;
    [UIView animateWithDuration:0.25 animations:^{
        entry.alpha = 1.0;
    }];
}

+ (void)encodedSilenceUptimeWasScanningGray:(NSString *)title message:(NSString *)message completion:(CapturesAmbiguousHeadsetAlpineExcludedOptional)completion {
    [self encodedSilenceUptimeWasScanningGray:title message:message minDivideCat:@[HisGeometry.illLoudEarFlow.counter] completion:completion];
}

@end
