








#import "MixTopNodeNine.h"

#define DelayWeekBend self.frame.size.width

@interface MixTopNodeNine()



@property (nonatomic, strong) NSMutableArray                            *areaTooArray;



@property (nonatomic, strong) NSMutableArray <SobFunMindNeedCell *>      *cropArray;



@property (strong, nonatomic) NSMutableArray <SobFunMindNeedCell *>      *diskPanStore;



@property (assign, nonatomic) NSInteger                                 count;



@property (nonatomic, assign) TopFlagTrapSunDigital                          status;



@property (nonatomic, assign) NSInteger                                 channelCount;



@property (nonatomic, assign) CGFloat                                   didFor;

@end

@implementation MixTopNodeNine

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

- (void)binOptScalar
{
    
    if (self.cropArray.firstObject) {
        
        
        SobFunMindNeedCell *batteryView = self.cropArray.firstObject;
        
        batteryView.frame = CGRectMake(DelayWeekBend, 0, batteryView.nameTopSize.width, batteryView.nameTopSize.height);
        
        self.didFor = batteryView.didFor;
        
        self.channelCount = batteryView.channelCount;
        
        
        NSInteger row = [self patchRainAscentSubDuePanLarge:batteryView];
        
        
        if (row >= 0) {
            
            
            [self.cropArray removeObjectAtIndex:0];
            
            
            if (![self.subviews containsObject:batteryView]) {
                [self addSubview:batteryView];
            }
            batteryView.frame = CGRectMake(DelayWeekBend,  row * (batteryView.nameTopSize.height + _didFor), batteryView.nameTopSize.width, batteryView.nameTopSize.height);
            
            
            [_areaTooArray setObject:batteryView atIndexedSubscript:row];
            
            
            if ([self.delegate respondsToSelector:@selector(fatSnowLeastView:willDisplayCell:)]) {
                [self.delegate fatSnowLeastView:self willDisplayCell:batteryView];
            }
            
            
            [self.diskPanStore addObject:batteryView];
            
            [batteryView tremorOutputFormatsDetermineStake:^{
                
                
                [batteryView setTransform:CGAffineTransformMakeTranslation(- batteryView.frame.size.width-DelayWeekBend, 0)];
                
            } completion:^(BOOL finished) {
                
                [batteryView removeFromSuperview];
                
                
                [self.diskPanStore removeObject:batteryView];
                
                
                if ([self.delegate respondsToSelector:@selector(fatSnowLeastView:didEndDisplayingCell:)]) {
                    [self.delegate fatSnowLeastView:self didEndDisplayingCell:batteryView];
                }
                
                
                if (--self.count <= 0) {
                    if ([self.delegate respondsToSelector:@selector(visitJustWonPortraitSerifPriorCountedLaw:)]) {
                        [self.delegate visitJustWonPortraitSerifPriorCountedLaw:self];
                    }
                    self.count = 0;
                }
                
                

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


- (void)currentlyUpper:(NSArray <SobFunMindNeedCell *> *)barrages
{
    self.count += barrages.count;
    [self.cropArray addObjectsFromArray:barrages];
}

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

- (void)stop
{
    if (self.status == ChainBusGetCollectOfferClose) {
        return;
    }
    self.status = ChainBusGetCollectOfferClose;
    
    if (self.diskPanStore.count) {
        [self.diskPanStore makeObjectsPerformSelector:@selector(pause)];
    }
    
    if (self.cropArray.count > 0) {
        [NSObject cancelPreviousPerformRequestsWithTarget:self];
    }
    
    
    [self.diskPanStore  makeObjectsPerformSelector:@selector(removeFromSuperview)];
    self.channelCount       = 0;
    self.count              = 0;
    [self.diskPanStore  removeAllObjects];
    [self.cropArray     removeAllObjects];
    [self.areaTooArray  removeAllObjects];
    
    self.diskPanStore       = nil;
    self.cropArray          = nil;
    self.areaTooArray       = nil;
}


- (NSInteger)patchRainAscentSubDuePanLarge:(SobFunMindNeedCell *)newBarrage
{
    for (int row = 0; row<_areaTooArray.count; row++) {
        NSObject *object = _areaTooArray[row];
        if ([object isKindOfClass:[NSNumber class]]) { 
            
            return row;
            
        }else if ([object isKindOfClass:[SobFunMindNeedCell class]]) { 
            
            SobFunMindNeedCell *oneBusyHis = (SobFunMindNeedCell*)object;
            
            if ([self patchRainAscentSubDuePanLarge:oneBusyHis andOnline:newBarrage]) {
                
                return row;
            }
        }
    }
    
    return -1;
}


- (BOOL)patchRainAscentSubDuePanLarge:(SobFunMindNeedCell *)oneBusyHis andOnline:(SobFunMindNeedCell *)newBarrage
{
    
    if (oneBusyHis.status == RenewDownloadsFailingDropCustomGrammar) {
        return NO;
    }
    
    
    CGRect rect = [oneBusyHis.layer.presentationLayer frame];
    if (rect.origin.x>DelayWeekBend - oneBusyHis.frame.size.width) {
        
        return NO;
    }else if (rect.size.width == 0)
    {
        
        return NO;
    }
    else if (oneBusyHis.frame.size.width > newBarrage.frame.size.width) {
        
        return YES;
    }else
    {
        
        CGFloat time = DelayWeekBend/(DelayWeekBend+newBarrage.frame.size.width)*newBarrage.pageWatchBar;
        
        CGFloat mole = rect.origin.x - time/(oneBusyHis.pageWatchBar)*(DelayWeekBend + oneBusyHis.frame.size.width);
        if (mole < -oneBusyHis.frame.size.width) {
            
            return YES;
        }
    }
    return NO;
}


- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
    UITouch *stale = [touches anyObject];
    CGPoint planarMild  = [stale locationInView:self];
    for (UIView *stroked in [self subviews])
    {
        if (![stroked isKindOfClass:[SobFunMindNeedCell class]]) continue;
        SobFunMindNeedCell *batteryView = (SobFunMindNeedCell *)stroked;
        if ([batteryView.layer.presentationLayer hitTest:planarMild])
        {
            
            if ([self.delegate respondsToSelector:@selector(fatSnowLeastView:closeButtonCell:)]) {
                [self.delegate fatSnowLeastView:self closeButtonCell:batteryView];
            }
            break;
        }
    }
}




- (NSMutableArray<SobFunMindNeedCell *> *)cropArray {
    if (!_cropArray) {
        _cropArray = [[NSMutableArray alloc] init];
    }
    return _cropArray;
}


- (NSMutableArray<SobFunMindNeedCell *> *)diskPanStore {
    if (!_diskPanStore) {
        _diskPanStore = [[NSMutableArray alloc] init];
    }
    return _diskPanStore;
}


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


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

@end
