






#import "DryAlertView.h"
#import "MixSnowBits.h"
#import "FactBasicManager.h"
#import "Masonry.h"

#define verySum(fun) __weak typeof(fun) weak##fun = fun;
#define debugging(fun) __strong typeof(fun) fun = weak##fun;

@interface DryAlertView()

@property (nonatomic, strong) UIView *interHowNotKitView;
@property (nonatomic, copy) IntrinsicFetchRevertMomentBufferingBin completion;
@property (nonatomic, strong) UIStackView *artRetWithinView;

@end

@implementation DryAlertView

- (void)dealloc {
    
}

- (instancetype)initWithFrame:(CGRect)frame
                          title:(NSString *)title
                        message:(NSString *)message
                   dayArtSuffix:(NSArray<NSString *> *)dayArtSuffix
                     completion:(IntrinsicFetchRevertMomentBufferingBin)completion {
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
        self.completion = completion;
        
        
        self.interHowNotKitView = [[UIView alloc] init];
        self.interHowNotKitView.backgroundColor = [MixSnowBits hallLaterColor];
        self.interHowNotKitView.layer.cornerRadius = MixSnowBits.packRouteToo.tagsAndBegan;
        self.interHowNotKitView.clipsToBounds = YES;
        self.interHowNotKitView.translatesAutoresizingMaskIntoConstraints = NO;
        [self addSubview:self.interHowNotKitView];
        
        
        [NSLayoutConstraint activateConstraints:@[
            [self.interHowNotKitView.centerXAnchor constraintEqualToAnchor:self.centerXAnchor],
            [self.interHowNotKitView.centerYAnchor constraintEqualToAnchor:self.centerYAnchor],
            [self.interHowNotKitView.widthAnchor constraintEqualToConstant:270]
        ]];
        
        
        UIView *decreaseView = nil;
        CGFloat rowWaxScaleUsesRadial = 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.interHowNotKitView addSubview:titleLabel];
            
            [NSLayoutConstraint activateConstraints:@[
                [titleLabel.topAnchor constraintEqualToAnchor:self.interHowNotKitView.topAnchor constant:rowWaxScaleUsesRadial],
                [titleLabel.leadingAnchor constraintEqualToAnchor:self.interHowNotKitView.leadingAnchor constant:16],
                [titleLabel.trailingAnchor constraintEqualToAnchor:self.interHowNotKitView.trailingAnchor constant:-16]
            ]];
            
            decreaseView = titleLabel;
        }
        
        
        if (message.length > 0) {
            UILabel *storageLabel = [[UILabel alloc] init];
            storageLabel.text = message;
            storageLabel.textColor = UIColor.whiteColor;
            storageLabel.font = [UIFont systemFontOfSize:15];
            storageLabel.textAlignment = NSTextAlignmentCenter;
            storageLabel.numberOfLines = 0;
            storageLabel.translatesAutoresizingMaskIntoConstraints = NO;
            [self.interHowNotKitView addSubview:storageLabel];
            
            NSLayoutYAxisAnchor *topAnchor = decreaseView ? decreaseView.bottomAnchor : self.interHowNotKitView.topAnchor;
            CGFloat barOrdinal = decreaseView ? 10 : rowWaxScaleUsesRadial;
            [NSLayoutConstraint activateConstraints:@[
                [storageLabel.topAnchor constraintEqualToAnchor:topAnchor constant:barOrdinal],
                [storageLabel.leadingAnchor constraintEqualToAnchor:self.interHowNotKitView.leadingAnchor constant:16],
                [storageLabel.trailingAnchor constraintEqualToAnchor:self.interHowNotKitView.trailingAnchor constant:-16]
            ]];
            decreaseView = storageLabel;
        }
        
        
        self.artRetWithinView = [[UIStackView alloc] init];
        self.artRetWithinView.axis = UILayoutConstraintAxisVertical;
        self.artRetWithinView.spacing = 1;  
        self.artRetWithinView.distribution = UIStackViewDistributionFillEqually;
        self.artRetWithinView.translatesAutoresizingMaskIntoConstraints = NO;
        [self.interHowNotKitView addSubview:self.artRetWithinView];
        
        
        NSLayoutYAxisAnchor *badTargetProducingCombinedRow = decreaseView ? decreaseView.bottomAnchor : self.interHowNotKitView.topAnchor;
        CGFloat lockMutableDivideAudibleDiscovery = decreaseView ? rowWaxScaleUsesRadial : rowWaxScaleUsesRadial;
        
        [NSLayoutConstraint activateConstraints:@[
            [self.artRetWithinView.topAnchor constraintEqualToAnchor:badTargetProducingCombinedRow constant:lockMutableDivideAudibleDiscovery],
            [self.artRetWithinView.leadingAnchor constraintEqualToAnchor:self.interHowNotKitView.leadingAnchor],
            [self.artRetWithinView.trailingAnchor constraintEqualToAnchor:self.interHowNotKitView.trailingAnchor],
            [self.artRetWithinView.bottomAnchor constraintEqualToAnchor:self.interHowNotKitView.bottomAnchor]
        ]];
        
        
       
       if (dayArtSuffix.count == 2) {
           
           self.artRetWithinView = [[UIStackView alloc] init];
           self.artRetWithinView.axis = UILayoutConstraintAxisHorizontal;
           self.artRetWithinView.distribution = UIStackViewDistributionFillEqually;
           self.artRetWithinView.spacing = 1;  
           self.artRetWithinView.translatesAutoresizingMaskIntoConstraints = NO;
           [self.interHowNotKitView addSubview:self.artRetWithinView];
           
           NSLayoutYAxisAnchor *badTargetProducingCombinedRow = decreaseView ? decreaseView.bottomAnchor : self.interHowNotKitView.topAnchor;
           [NSLayoutConstraint activateConstraints:@[
               [self.artRetWithinView.topAnchor constraintEqualToAnchor:badTargetProducingCombinedRow constant:rowWaxScaleUsesRadial],
               [self.artRetWithinView.leadingAnchor constraintEqualToAnchor:self.interHowNotKitView.leadingAnchor],
               [self.artRetWithinView.trailingAnchor constraintEqualToAnchor:self.interHowNotKitView.trailingAnchor],
               [self.artRetWithinView.bottomAnchor constraintEqualToAnchor:self.interHowNotKitView.bottomAnchor]
           ]];
           
           
           for (NSInteger i = 0; i < dayArtSuffix.count; i++) {
               NSString *localSum = dayArtSuffix[i];
               UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
               [button setTitle:localSum forState:UIControlStateNormal];
               button.titleLabel.font = [UIFont systemFontOfSize:17];
               [button setTitleColor:[MixSnowBits hallLaterColor] forState:UIControlStateNormal];
               [button setTitleColor:UIColor.lightGrayColor forState:UIControlStateHighlighted];
               button.backgroundColor = [UIColor whiteColor];
               button.tag = i;
               [button addTarget:self action:@selector(boxHourlyNet:) forControlEvents:UIControlEventTouchUpInside];
               button.translatesAutoresizingMaskIntoConstraints = NO;
               [button.heightAnchor constraintEqualToConstant:40].active = YES;
               [self.artRetWithinView addArrangedSubview:button];
           }
       } else {
           
           self.artRetWithinView = [[UIStackView alloc] init];
           self.artRetWithinView.axis = UILayoutConstraintAxisVertical;
           self.artRetWithinView.spacing = 1;
           self.artRetWithinView.distribution = UIStackViewDistributionFillEqually;
           self.artRetWithinView.translatesAutoresizingMaskIntoConstraints = NO;
           [self.interHowNotKitView addSubview:self.artRetWithinView];
           
           NSLayoutYAxisAnchor *badTargetProducingCombinedRow = decreaseView ? decreaseView.bottomAnchor : self.interHowNotKitView.topAnchor;
           [NSLayoutConstraint activateConstraints:@[
               [self.artRetWithinView.topAnchor constraintEqualToAnchor:badTargetProducingCombinedRow constant:rowWaxScaleUsesRadial],
               [self.artRetWithinView.leadingAnchor constraintEqualToAnchor:self.interHowNotKitView.leadingAnchor],
               [self.artRetWithinView.trailingAnchor constraintEqualToAnchor:self.interHowNotKitView.trailingAnchor],
               [self.artRetWithinView.bottomAnchor constraintEqualToAnchor:self.interHowNotKitView.bottomAnchor]
           ]];
           
           for (NSInteger i = 0; i < dayArtSuffix.count; i++) {
               NSString *localSum = dayArtSuffix[i];
               UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
               [button setTitle:localSum forState:UIControlStateNormal];
               button.titleLabel.font = [UIFont systemFontOfSize:17];
               [button setTitleColor:[MixSnowBits hallLaterColor] forState:UIControlStateNormal];
               [button setTitleColor:UIColor.lightGrayColor forState:UIControlStateHighlighted];
               button.backgroundColor = [UIColor whiteColor];
               button.tag = i;
               [button addTarget:self action:@selector(boxHourlyNet:) forControlEvents:UIControlEventTouchUpInside];
               button.translatesAutoresizingMaskIntoConstraints = NO;
               [button.heightAnchor constraintEqualToConstant:40].active = YES;
               [self.artRetWithinView addArrangedSubview:button];
           }
       }
    }
    return self;
}

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

+ (void)tabWayFarsiFilteringProtocolsFloor:(NSString *)title
                        message:(NSString *)message
                   dayArtSuffix:(NSArray<NSString *> *)dayArtSuffix
                     completion:(IntrinsicFetchRevertMomentBufferingBin)completion {
    
    DryAlertView *avail = [[DryAlertView alloc] initWithFrame:[UIScreen mainScreen].bounds
                                                 title:title
                                               message:message
                                          dayArtSuffix:dayArtSuffix
                                            completion:completion];
    
    
    [FactBasicManager.shared widgetBezelCapacitySeparatedDissolveSleetView:avail];
    
    
    avail.alpha = 0.0;
    [UIView animateWithDuration:0.25 animations:^{
        avail.alpha = 1.0;
    }];
}

+ (void)tabWayFarsiFilteringProtocolsFloor:(NSString *)title message:(NSString *)message completion:(IntrinsicFetchRevertMomentBufferingBin)completion {
    [self tabWayFarsiFilteringProtocolsFloor:title message:message dayArtSuffix:@[MixSnowBits.theBinAlignWax.treePub] completion:completion];
}

@end
