








#import "OpenWhoDuePlan.h"

#define FaxBundlesSin self.frame.size.width

@interface OpenWhoDuePlan()



@property (nonatomic, strong) NSMutableArray                            *sumPingArray;



@property (nonatomic, strong) NSMutableArray <ResizingCookieCell *>      *gramArray;



@property (strong, nonatomic) NSMutableArray <ResizingCookieCell *>      *preserveMain;



@property (assign, nonatomic) NSInteger                                 count;



@property (nonatomic, assign) ProcessorLimitedDegreeBarsBattery                          status;



@property (nonatomic, assign) NSInteger                                 channelCount;



@property (nonatomic, assign) CGFloat                                   trySaw;

@end

@implementation OpenWhoDuePlan

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

- (void)lowDirectory
{
    
    if (self.gramArray.firstObject) {
        
        
        ResizingCookieCell *spanRunView = self.gramArray.firstObject;
        
        spanRunView.frame = CGRectMake(FaxBundlesSin, 0, spanRunView.anchorsSize.width, spanRunView.anchorsSize.height);
        
        self.trySaw = spanRunView.trySaw;
        
        self.channelCount = spanRunView.channelCount;
        
        
        NSInteger row = [self desktopFactorSinSplitFarPlaySize:spanRunView];
        
        
        if (row >= 0) {
            
            
            [self.gramArray removeObjectAtIndex:0];
            
            
            if (![self.subviews containsObject:spanRunView]) {
                [self addSubview:spanRunView];
            }
            spanRunView.frame = CGRectMake(FaxBundlesSin,  row * (spanRunView.anchorsSize.height + _trySaw), spanRunView.anchorsSize.width, spanRunView.anchorsSize.height);
            
            
            [_sumPingArray setObject:spanRunView atIndexedSubscript:row];
            
            
            if ([self.delegate respondsToSelector:@selector(signerSenderView:willDisplayCell:)]) {
                [self.delegate signerSenderView:self willDisplayCell:spanRunView];
            }
            
            
            [self.preserveMain addObject:spanRunView];
            
            [spanRunView roleNominallyAssetCommonEncode:^{
                
                
                [spanRunView setTransform:CGAffineTransformMakeTranslation(- spanRunView.frame.size.width-FaxBundlesSin, 0)];
                
            } completion:^(BOOL finished) {
                
                [spanRunView removeFromSuperview];
                
                
                [self.preserveMain removeObject:spanRunView];
                
                
                if ([self.delegate respondsToSelector:@selector(signerSenderView:didEndDisplayingCell:)]) {
                    [self.delegate signerSenderView:self didEndDisplayingCell:spanRunView];
                }
                
                
                if (--self.count <= 0) {
                    if ([self.delegate respondsToSelector:@selector(detailedMovieCollationThousandsHoldNowShowersFold:)]) {
                        [self.delegate detailedMovieCollationThousandsHoldNowShowersFold:self];
                    }
                    self.count = 0;
                }
                
                

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


- (void)retainedSomali:(NSArray <ResizingCookieCell *> *)barrages
{
    self.count += barrages.count;
    [self.gramArray addObjectsFromArray:barrages];
}

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

- (void)stop
{
    if (self.status == SolveReverseMismatchPasswordsWhoWon) {
        return;
    }
    self.status = SolveReverseMismatchPasswordsWhoWon;
    
    if (self.preserveMain.count) {
        [self.preserveMain makeObjectsPerformSelector:@selector(pause)];
    }
    
    if (self.gramArray.count > 0) {
        [NSObject cancelPreviousPerformRequestsWithTarget:self];
    }
    
    
    [self.preserveMain  makeObjectsPerformSelector:@selector(removeFromSuperview)];
    self.channelCount       = 0;
    self.count              = 0;
    [self.preserveMain  removeAllObjects];
    [self.gramArray     removeAllObjects];
    [self.sumPingArray  removeAllObjects];
    
    self.preserveMain       = nil;
    self.gramArray          = nil;
    self.sumPingArray       = nil;
}


- (NSInteger)desktopFactorSinSplitFarPlaySize:(ResizingCookieCell *)newBarrage
{
    for (int row = 0; row<_sumPingArray.count; row++) {
        NSObject *object = _sumPingArray[row];
        if ([object isKindOfClass:[NSNumber class]]) { 
            
            return row;
            
        }else if ([object isKindOfClass:[ResizingCookieCell class]]) { 
            
            ResizingCookieCell *calciumBus = (ResizingCookieCell*)object;
            
            if ([self desktopFactorSinSplitFarPlaySize:calciumBus vowelArea:newBarrage]) {
                
                return row;
            }
        }
    }
    
    return -1;
}


- (BOOL)desktopFactorSinSplitFarPlaySize:(ResizingCookieCell *)calciumBus vowelArea:(ResizingCookieCell *)newBarrage
{
    
    if (calciumBus.status == RedRefusedOddPopFocusRematch) {
        return NO;
    }
    
    
    CGRect rect = [calciumBus.layer.presentationLayer frame];
    if (rect.origin.x>FaxBundlesSin - calciumBus.frame.size.width) {
        
        return NO;
    }else if (rect.size.width == 0)
    {
        
        return NO;
    }
    else if (calciumBus.frame.size.width > newBarrage.frame.size.width) {
        
        return YES;
    }else
    {
        
        CGFloat time = FaxBundlesSin/(FaxBundlesSin+newBarrage.frame.size.width)*newBarrage.optStreetToo;
        
        CGFloat fair = rect.origin.x - time/(calciumBus.optStreetToo)*(FaxBundlesSin + calciumBus.frame.size.width);
        if (fair < -calciumBus.frame.size.width) {
            
            return YES;
        }
    }
    return NO;
}


- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
    UITouch *bayer = [touches anyObject];
    CGPoint passiveBit  = [bayer locationInView:self];
    for (ResizingCookieCell *spanRunView in [self subviews])
    {
        if ([spanRunView.layer.presentationLayer hitTest:passiveBit])
        {
            
            if ([self.delegate respondsToSelector:@selector(signerSenderView:backSaltSinCell:)]) {
                [self.delegate signerSenderView:self backSaltSinCell:spanRunView];
            }
            break;
        }
    }
}




- (NSMutableArray<ResizingCookieCell *> *)gramArray {
    if (!_gramArray) {
        _gramArray = [[NSMutableArray alloc] init];
    }
    return _gramArray;
}


- (NSMutableArray<ResizingCookieCell *> *)preserveMain {
    if (!_preserveMain) {
        _preserveMain = [[NSMutableArray alloc] init];
    }
    return _preserveMain;
}


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


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

@end
