








#import "HuePhotoNetMap.h"

#define AirInsetGenre self.frame.size.width

@interface HuePhotoNetMap()



@property (nonatomic, strong) NSMutableArray                            *loopWayArray;



@property (nonatomic, strong) NSMutableArray <VectorPintKindCell *>      *backArray;



@property (strong, nonatomic) NSMutableArray <VectorPintKindCell *>      *drivenPoster;



@property (assign, nonatomic) NSInteger                                 count;



@property (nonatomic, assign) ResultingLossySameEggCursive                          status;



@property (nonatomic, assign) NSInteger                                 channelCount;



@property (nonatomic, assign) CGFloat                                   ampere;

@end

@implementation HuePhotoNetMap

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

- (void)shelfEscapes
{
    
    if (self.backArray.firstObject) {
        
        
        VectorPintKindCell *rowEachView = self.backArray.firstObject;
        
        rowEachView.frame = CGRectMake(AirInsetGenre, 0, rowEachView.descendSize.width, rowEachView.descendSize.height);
        
        self.ampere = rowEachView.ampere;
        
        self.channelCount = rowEachView.channelCount;
        
        
        NSInteger row = [self tipAssistantDefinesSinProcedureStateCompare:rowEachView];
        
        
        if (row >= 0) {
            
            
            [self.backArray removeObjectAtIndex:0];
            
            
            if (![self.subviews containsObject:rowEachView]) {
                [self addSubview:rowEachView];
            }
            rowEachView.frame = CGRectMake(AirInsetGenre,  row * (rowEachView.descendSize.height + _ampere), rowEachView.descendSize.width, rowEachView.descendSize.height);
            
            
            [_loopWayArray setObject:rowEachView atIndexedSubscript:row];
            
            
            if ([self.delegate respondsToSelector:@selector(stackedBevelView:willDisplayCell:)]) {
                [self.delegate stackedBevelView:self willDisplayCell:rowEachView];
            }
            
            
            [self.drivenPoster addObject:rowEachView];
            
            [rowEachView desiredMountDuplexPatchLocally:^{
                
                
                [rowEachView setTransform:CGAffineTransformMakeTranslation(- rowEachView.frame.size.width-AirInsetGenre, 0)];
                
            } completion:^(BOOL finished) {
                
                [rowEachView removeFromSuperview];
                
                
                [self.drivenPoster removeObject:rowEachView];
                
                
                if ([self.delegate respondsToSelector:@selector(stackedBevelView:didEndDisplayingCell:)]) {
                    [self.delegate stackedBevelView:self didEndDisplayingCell:rowEachView];
                }
                
                
                if (--self.count <= 0) {
                    if ([self.delegate respondsToSelector:@selector(fallbackContainerTryOldHomeOutputGraphicsWait:)]) {
                        [self.delegate fallbackContainerTryOldHomeOutputGraphicsWait:self];
                    }
                    self.count = 0;
                }
                
                

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


- (void)stampYetRetWin:(NSArray <VectorPintKindCell *> *)barrages
{
    self.count += barrages.count;
    [self.backArray addObjectsFromArray:barrages];
}

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

- (void)stop
{
    if (self.status == ChromiumClickedOverallWaxZipYear) {
        return;
    }
    self.status = ChromiumClickedOverallWaxZipYear;
    
    if (self.drivenPoster.count) {
        [self.drivenPoster makeObjectsPerformSelector:@selector(pause)];
    }
    
    if (self.backArray.count > 0) {
        [NSObject cancelPreviousPerformRequestsWithTarget:self];
    }
    
    
    [self.drivenPoster  makeObjectsPerformSelector:@selector(removeFromSuperview)];
    self.channelCount       = 0;
    self.count              = 0;
    [self.drivenPoster  removeAllObjects];
    [self.backArray     removeAllObjects];
    [self.loopWayArray  removeAllObjects];
    
    self.drivenPoster       = nil;
    self.backArray          = nil;
    self.loopWayArray       = nil;
}


- (NSInteger)tipAssistantDefinesSinProcedureStateCompare:(VectorPintKindCell *)newBarrage
{
    for (int row = 0; row<_loopWayArray.count; row++) {
        NSObject *object = _loopWayArray[row];
        if ([object isKindOfClass:[NSNumber class]]) { 
            
            return row;
            
        }else if ([object isKindOfClass:[VectorPintKindCell class]]) { 
            
            VectorPintKindCell *optFatWord = (VectorPintKindCell*)object;
            
            if ([self tipAssistantDefinesSinProcedureStateCompare:optFatWord stepScore:newBarrage]) {
                
                return row;
            }
        }
    }
    
    return -1;
}


- (BOOL)tipAssistantDefinesSinProcedureStateCompare:(VectorPintKindCell *)optFatWord stepScore:(VectorPintKindCell *)newBarrage
{
    
    if (optFatWord.status == FalloffCheckedNotifyPurposeArrivalNotifies) {
        return NO;
    }
    
    
    CGRect rect = [optFatWord.layer.presentationLayer frame];
    if (rect.origin.x>AirInsetGenre - optFatWord.frame.size.width) {
        
        return NO;
    }else if (rect.size.width == 0)
    {
        
        return NO;
    }
    else if (optFatWord.frame.size.width > newBarrage.frame.size.width) {
        
        return YES;
    }else
    {
        
        CGFloat time = AirInsetGenre/(AirInsetGenre+newBarrage.frame.size.width)*newBarrage.rareSingular;
        
        CGFloat polo = rect.origin.x - time/(optFatWord.rareSingular)*(AirInsetGenre + optFatWord.frame.size.width);
        if (polo < -optFatWord.frame.size.width) {
            
            return YES;
        }
    }
    return NO;
}


- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
    UITouch *shake = [touches anyObject];
    CGPoint ratioHindi  = [shake locationInView:self];
    for (VectorPintKindCell *rowEachView in [self subviews])
    {
        if ([rowEachView.layer.presentationLayer hitTest:ratioHindi])
        {
            
            if ([self.delegate respondsToSelector:@selector(stackedBevelView:yahooRetFitCell:)]) {
                [self.delegate stackedBevelView:self yahooRetFitCell:rowEachView];
            }
            break;
        }
    }
}




- (NSMutableArray<VectorPintKindCell *> *)backArray {
    if (!_backArray) {
        _backArray = [[NSMutableArray alloc] init];
    }
    return _backArray;
}


- (NSMutableArray<VectorPintKindCell *> *)drivenPoster {
    if (!_drivenPoster) {
        _drivenPoster = [[NSMutableArray alloc] init];
    }
    return _drivenPoster;
}


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


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

@end
