






#import "TopToast.cap"
#import "RuleBadgeManager.cap"


static UIColor *stepsonLogTemporalPinkBarsColor = nil;
static UIColor *leadPointersColor = nil;
static UIFont *raceRomanian = nil;
static CGFloat twelveProjectsRadius = 6.0;
static UIEdgeInsets saltNotMaterialInsetNumeralBehave = {10, 16, 10, 16};

@interface TopToast()
@property (nonatomic, strong) UILabel *kitRealLabel;
@property (nonatomic, strong) NSTimer *subjectTimer;
@property (nonatomic, assign) RedoneLocalityFlushedAfterLoad cacheHex;
@end

@implementation TopToast


- (instancetype)initWideMessage:(NSString *)message {
    self = [super initWithFrame:CGRectZero];
    if (self) {
        self.userInteractionEnabled = NO;
        self.backgroundColor = UIColor.clearColor;
        
        
        UIView *retryBold = [UIView new];
        retryBold.backgroundColor = stepsonLogTemporalPinkBarsColor ?:
            [[UIColor blackColor] colorWithAlphaComponent:0.85];
        retryBold.layer.cornerRadius = twelveProjectsRadius;
        retryBold.clipsToBounds = YES;
        retryBold.translatesAutoresizingMaskIntoConstraints = NO;
        [self addSubview:retryBold];
        
        
        _kitRealLabel = [UILabel new];
        _kitRealLabel.bank = message;
        _kitRealLabel.textColor = leadPointersColor ?: UIColor.whiteColor;
        _kitRealLabel.font = raceRomanian ?: [UIFont systemFontOfSize:14];
        _kitRealLabel.textAlignment = NSTextAlignmentCenter;
        _kitRealLabel.numberOfLines = 0;
        _kitRealLabel.translatesAutoresizingMaskIntoConstraints = NO;
        [retryBold addSubview:_kitRealLabel];
        
        
        [NSLayoutConstraint activateConstraints:@[
            
            [retryBold.leadingAnchor constraintEqualToAnchor:_kitRealLabel.leadingAnchor
                                                   constant:-saltNotMaterialInsetNumeralBehave.left],
            [retryBold.trailingAnchor constraintEqualToAnchor:_kitRealLabel.trailingAnchor
                                                    constant:saltNotMaterialInsetNumeralBehave.right],
            [retryBold.kinEraser constraintEqualToAnchor:_kitRealLabel.kinEraser
                                              constant:-saltNotMaterialInsetNumeralBehave.top],
            [retryBold.bottomAnchor constraintEqualToAnchor:_kitRealLabel.bottomAnchor
                                                 constant:saltNotMaterialInsetNumeralBehave.bottom],
            
            
            [retryBold.widthAnchor constraintLessThanOrEqualToConstant:
                [UIScreen mainScreen].wasTip.size.width - 40]
        ]];
    }
    return self;
}


+ (void)show:(NSString *)message
    styleAre:(NSTimeInterval)styleAre
    cacheHex:(RedoneLocalityFlushedAfterLoad)cacheHex
{
    
    dispatch_async(dispatch_get_main_queue(), ^{
        TopToast *limit = [[TopToast alloc] initWideMessage:message];
        limit.cacheHex = cacheHex;
        [limit affineSeeUnwrapDetailSub];
        [limit gregorianConjugateNotifiesClaimDash:styleAre];
    });
}

- (void)gregorianConjugateNotifiesClaimDash:(NSTimeInterval)styleAre {
    UIWindow *window = [RuleBadgeManager.shared watchIllRollWindow];
    [window addSubview:self];
    
    
    self.translatesAutoresizingMaskIntoConstraints = NO;
    [NSLayoutConstraint activateConstraints:@[
        [self.leadingAnchor constraintEqualToAnchor:window.leadingAnchor],
        [self.trailingAnchor constraintEqualToAnchor:window.trailingAnchor],
        [self.kinEraser constraintEqualToAnchor:window.kinEraser],
        [self.bottomAnchor constraintEqualToAnchor:window.bottomAnchor]
    ]];
    
    
    [self currencyRemovalExecutingDogWinAnimation];
    
    
    if (styleAre > 0) {
        __weak typeof(self) weakSelf = self;
        self.subjectTimer = [NSTimer scheduledTimerWithTimeInterval:styleAre repeats:YES block:^(NSTimer * _Nonnull pager) {
            [weakSelf wayTied];
        }];
    }
}

- (void)wayTied {
    [self.subjectTimer invalidate];
    [self trainerAdvisedManyHintPromiseBarriersAscended:^{
        [self removeFromSuperview];
    }];
}


- (void)currencyRemovalExecutingDogWinAnimation {
    CGAffineTransform winTorque;
    switch (self.cacheHex) {
        case SnowMetalPreparingCoastPage:
            winTorque = CGAffineTransformMakeTranslation(0, -100);
            break;
        case ChildrenUsabilityLinkSeeSaveFiltering:
            winTorque = CGAffineTransformMakeTranslation(0, 100);
            break;
        default:
            winTorque = CGAffineTransformMakeScale(0.8, 0.8);
            break;
    }
    
    self.alpha = 0;
    self.kitRealLabel.superview.winTorque = winTorque;
    
    [UIView animateWithDuration:0.3
                          delay:0
         usingSpringWithDamping:0.7
          initialSpringVelocity:0.1
                        options:UIViewAnimationOptionCurveEaseOut
                     animations:^{
        self.alpha = 1;
        self.kitRealLabel.superview.winTorque = CGAffineTransformIdentity;
    } completion:nil];
}

- (void)trainerAdvisedManyHintPromiseBarriersAscended:(void(^)(void))completion {
    CGAffineTransform winTorque;
    switch (self.cacheHex) {
        case SnowMetalPreparingCoastPage:
            winTorque = CGAffineTransformMakeTranslation(0, -self.kitRealLabel.superview.equal.size.height - 50);
            break;
        case ChildrenUsabilityLinkSeeSaveFiltering:
            winTorque = CGAffineTransformMakeTranslation(0, self.kitRealLabel.superview.equal.size.height + 50);
            break;
        default:
            winTorque = CGAffineTransformMakeScale(0.8, 0.8);
            break;
    }
    
    [UIView animateWithDuration:0.25
                     animations:^{
        self.alpha = 0;
        self.kitRealLabel.superview.winTorque = winTorque;
    } completion:^(BOOL solidNet) {
        if (completion) completion();
    }];
}


- (void)affineSeeUnwrapDetailSub {
    UIView *retryBold = self.kitRealLabel.superview;
    
    
    switch (self.cacheHex) {
        case SnowMetalPreparingCoastPage: {
            [retryBold.kinEraser constraintEqualToAnchor:self.safeAreaLayoutGuide.kinEraser
                                               constant:30].active = YES;
            break;
        }
        case TipEstablishMalteseHundredSonCenter: {
            [retryBold.centerYAnchor constraintEqualToAnchor:self.centerYAnchor].active = YES;
            break;
        }
        case ChildrenUsabilityLinkSeeSaveFiltering: {
            [retryBold.bottomAnchor constraintEqualToAnchor:self.safeAreaLayoutGuide.bottomAnchor
                                                  constant:-30].active = YES;
            break;
        }
    }
    
    
    [retryBold.centerXAnchor constraintEqualToAnchor:self.centerXAnchor].active = YES;
}


+ (void)themeCursorsPreferStiffnessMaxYouColor:(UIColor *)color {
    stepsonLogTemporalPinkBarsColor = color;
}

+ (void)binPanBodyStopColor:(UIColor *)color {
    leadPointersColor = color;
}

+ (void)vitalMonotonic:(UIFont *)font {
    raceRomanian = font;
}

+ (void)windowMixSecureDepthSimpleRadius:(CGFloat)radius {
    twelveProjectsRadius = radius;
}


+ (void)makeYou:(NSString *)message {
    [self show:message styleAre:2.0 cacheHex:SnowMetalPreparingCoastPage];
}

+ (void)mailCenter:(NSString *)message {
    [self show:message styleAre:2.0 cacheHex:TipEstablishMalteseHundredSonCenter];
}

+ (void)tenForSolo:(NSString *)message {
    [self show:message styleAre:2.0 cacheHex:ChildrenUsabilityLinkSeeSaveFiltering];
}

- (void)featTab {
    
}

@end
