








#import "EarDustTurnEar.h"

#define AnglePagerPin self.frame.size.width

@interface EarDustTurnEar()



@property (nonatomic, strong) NSMutableArray                            *toolNetArray;



@property (nonatomic, strong) NSMutableArray <SmartTrialHelpCell *>      *caseArray;



@property (strong, nonatomic) NSMutableArray <SmartTrialHelpCell *>      *densityIntro;



@property (assign, nonatomic) NSInteger                                 count;



@property (nonatomic, assign) RestInsertedContentDisposeChroma                          status;



@property (nonatomic, assign) NSInteger                                 channelCount;



@property (nonatomic, assign) CGFloat                                   youSin;

@end

@implementation EarDustTurnEar

- (instancetype)init
{
    self = [super init];
    if (self) {
        self.status = SunPoolFixRemembersRenewingSpeed;
    }
    return self;
}

- (void)eggIndigoSun
{
    
    if (self.caseArray.firstObject) {
        
        
        SmartTrialHelpCell *penAwayView = self.caseArray.firstObject;
        
        penAwayView.frame = CGRectMake(AnglePagerPin, 0, penAwayView.moodRedSize.width, penAwayView.moodRedSize.height);
        
        self.youSin = penAwayView.youSin;
        
        self.channelCount = penAwayView.channelCount;
        
        
        NSInteger row = [self softballChunkyStairConfirmTipPriceInterrupt:penAwayView];
        
        
        if (row >= 0) {
            
            
            [self.caseArray removeObjectAtIndex:0];
            
            
            if (![self.subviews containsObject:penAwayView]) {
                [self addSubview:penAwayView];
            }
            penAwayView.frame = CGRectMake(AnglePagerPin,  row * (penAwayView.moodRedSize.height + _youSin), penAwayView.moodRedSize.width, penAwayView.moodRedSize.height);
            
            
            [_toolNetArray setObject:penAwayView atIndexedSubscript:row];
            
            
            if ([self.delegate respondsToSelector:@selector(withinToggleView:willDisplayCell:)]) {
                [self.delegate withinToggleView:self willDisplayCell:penAwayView];
            }
            
            
            [self.densityIntro addObject:penAwayView];
            
            [penAwayView cityAlongsideHyphenRebusRussian:^{
                
                
                [penAwayView setTransform:CGAffineTransformMakeTranslation(- penAwayView.frame.size.width-AnglePagerPin, 0)];
                
            } completion:^(BOOL finished) {
                
                [penAwayView removeFromSuperview];
                
                
                [self.densityIntro removeObject:penAwayView];
                
                
                if ([self.delegate respondsToSelector:@selector(withinToggleView:didEndDisplayingCell:)]) {
                    [self.delegate withinToggleView:self didEndDisplayingCell:penAwayView];
                }
                
                
                if (--self.count <= 0) {
                    if ([self.delegate respondsToSelector:@selector(bringBundlesReadableGreaterHundredsHangProvidedWet:)]) {
                        [self.delegate bringBundlesReadableGreaterHundredsHangProvidedWet:self];
                    }
                    self.count = 0;
                }
                
                

            }];
        }
    }
    
    [self performSelector:@selector(eggIndigoSun) withObject:nil afterDelay:0.45f];
}


- (void)tryMetalKinTip:(NSArray <SmartTrialHelpCell *> *)barrages
{
    self.count += barrages.count;
    [self.caseArray addObjectsFromArray:barrages];
}

- (void)start
{
    if (self.status == OverrideSameEventualStableStringProduct) {
        return;
    }
    self.status = OverrideSameEventualStableStringProduct;
    
    [self eggIndigoSun];
}

- (void)stop
{
    if (self.status == SunPoolFixRemembersRenewingSpeed) {
        return;
    }
    self.status = SunPoolFixRemembersRenewingSpeed;
    
    if (self.densityIntro.count) {
        [self.densityIntro makeObjectsPerformSelector:@selector(pause)];
    }
    
    if (self.caseArray.count > 0) {
        [NSObject cancelPreviousPerformRequestsWithTarget:self];
    }
    
    
    [self.densityIntro  makeObjectsPerformSelector:@selector(removeFromSuperview)];
    self.channelCount       = 0;
    self.count              = 0;
    [self.densityIntro  removeAllObjects];
    [self.caseArray     removeAllObjects];
    [self.toolNetArray  removeAllObjects];
    
    self.densityIntro       = nil;
    self.caseArray          = nil;
    self.toolNetArray       = nil;
}


- (NSInteger)softballChunkyStairConfirmTipPriceInterrupt:(SmartTrialHelpCell *)newBarrage
{
    for (int row = 0; row<_toolNetArray.count; row++) {
        NSObject *object = _toolNetArray[row];
        if ([object isKindOfClass:[NSNumber class]]) { 
            
            return row;
            
        }else if ([object isKindOfClass:[SmartTrialHelpCell class]]) { 
            
            SmartTrialHelpCell *blurLambda = (SmartTrialHelpCell*)object;
            
            if ([self softballChunkyStairConfirmTipPriceInterrupt:blurLambda awakeTall:newBarrage]) {
                
                return row;
            }
        }
    }
    
    return -1;
}


- (BOOL)softballChunkyStairConfirmTipPriceInterrupt:(SmartTrialHelpCell *)blurLambda awakeTall:(SmartTrialHelpCell *)newBarrage
{
    
    if (blurLambda.status == LenientGolfLengthsCupStrengthUnordered) {
        return NO;
    }
    
    
    CGRect rect = [blurLambda.layer.presentationLayer frame];
    if (rect.origin.x>AnglePagerPin - blurLambda.frame.size.width) {
        
        return NO;
    }else if (rect.size.width == 0)
    {
        
        return NO;
    }
    else if (blurLambda.frame.size.width > newBarrage.frame.size.width) {
        
        return YES;
    }else
    {
        
        CGFloat time = AnglePagerPin/(AnglePagerPin+newBarrage.frame.size.width)*newBarrage.rejectionZip;
        
        CGFloat lift = rect.origin.x - time/(blurLambda.rejectionZip)*(AnglePagerPin + blurLambda.frame.size.width);
        if (lift < -blurLambda.frame.size.width) {
            
            return YES;
        }
    }
    return NO;
}


- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
    UITouch *alive = [touches anyObject];
    CGPoint lowFootPen  = [alive locationInView:self];
    for (SmartTrialHelpCell *penAwayView in [self subviews])
    {
        if ([penAwayView.layer.presentationLayer hitTest:lowFootPen])
        {
            
            if ([self.delegate respondsToSelector:@selector(withinToggleView:diskMapTeamCell:)]) {
                [self.delegate withinToggleView:self diskMapTeamCell:penAwayView];
            }
            break;
        }
    }
}




- (NSMutableArray<SmartTrialHelpCell *> *)caseArray {
    if (!_caseArray) {
        _caseArray = [[NSMutableArray alloc] init];
    }
    return _caseArray;
}


- (NSMutableArray<SmartTrialHelpCell *> *)densityIntro {
    if (!_densityIntro) {
        _densityIntro = [[NSMutableArray alloc] init];
    }
    return _densityIntro;
}


- (void)setChannelCount:(NSInteger)channelCount
{
    
    if (self.toolNetArray.count < channelCount) { 
        
        for (NSInteger row = self.toolNetArray.count; row < channelCount; row++) {
            NSNumber *number = [NSNumber numberWithBool:YES];
            [self.toolNetArray setObject:number atIndexedSubscript:row];
        }
        
    }else {
        
        for (NSInteger row = channelCount; row < self.toolNetArray.count; row++) {
            [self.toolNetArray removeObjectAtIndex:row];
        }
    }
    
    _channelCount = channelCount;
    
}


- (NSMutableArray *)toolNetArray {
    if (!_toolNetArray) {
        _toolNetArray = [[NSMutableArray alloc] init];
    }
    return _toolNetArray;
}

@end
