






#import "EggAlertView.h"
#import "CutEightLow.h"
#import "UplinkDryManager.h"
#import "Masonry.h"

#define friends(law) __weak typeof(law) weak##law = law;
#define telephoto(law) __strong typeof(law) law = weak##law;

@interface EggAlertView()

@property (nonatomic, strong) UIView *destroySharingView;
@property (nonatomic, copy) ComparePotentialConsoleRotatingDecoderModified completion;
@property (nonatomic, strong) UIStackView *recycleLayerView;

@end

@implementation EggAlertView

- (void)dealloc {
    
}

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

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

+ (void)formThemeBoostChunkyShowersQueue:(NSString *)title
                        message:(NSString *)message
                   carFatStrict:(NSArray<NSString *> *)carFatStrict
                     completion:(ComparePotentialConsoleRotatingDecoderModified)completion {
    
    EggAlertView *exist = [[EggAlertView alloc] initWithFrame:[UIScreen mainScreen].bounds
                                                 title:title
                                               message:message
                                          carFatStrict:carFatStrict
                                            completion:completion];
    
    
    [UplinkDryManager.shared exposeShortcutsRowImplicitOccurredOperateView:exist];
    
    
    exist.alpha = 0.0;
    [UIView animateWithDuration:0.25 animations:^{
        exist.alpha = 1.0;
    }];
}

+ (void)formThemeBoostChunkyShowersQueue:(NSString *)title message:(NSString *)message completion:(ComparePotentialConsoleRotatingDecoderModified)completion {
    [self formThemeBoostChunkyShowersQueue:title message:message carFatStrict:@[CutEightLow.mailRetDropSee.fatSize] completion:completion];
}

@end
