








#import "FormWillSubTry.h"

#define TransientGray self.frame.size.width

@interface FormWillSubTry()



@property (nonatomic, strong) NSMutableArray                            *repliesArray;



@property (nonatomic, strong) NSMutableArray <SumHisHasDigitCell *>      *lineArray;



@property (strong, nonatomic) NSMutableArray <SumHisHasDigitCell *>      *loopsFitMove;



@property (assign, nonatomic) NSInteger                                 count;



@property (nonatomic, assign) KilowattStoneInviteeDiscoverArabic                          status;



@property (nonatomic, assign) NSInteger                                 channelCount;



@property (nonatomic, assign) CGFloat                                   howFor;

@end

@implementation FormWillSubTry

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

- (void)unlikelyMind
{
    
    if (self.lineArray.firstObject) {
        
        
        SumHisHasDigitCell *artClipView = self.lineArray.firstObject;
        
        artClipView.frame = CGRectMake(TransientGray, 0, artClipView.penPoolSize.width, artClipView.penPoolSize.height);
        
        self.howFor = artClipView.howFor;
        
        self.channelCount = artClipView.channelCount;
        
        
        NSInteger row = [self generatesBaseLawStrategyUniversalWetExec:artClipView];
        
        
        if (row >= 0) {
            
            
            [self.lineArray removeObjectAtIndex:0];
            
            
            if (![self.subviews containsObject:artClipView]) {
                [self addSubview:artClipView];
            }
            artClipView.frame = CGRectMake(TransientGray,  row * (artClipView.penPoolSize.height + _howFor), artClipView.penPoolSize.width, artClipView.penPoolSize.height);
            
            
            [_repliesArray setObject:artClipView atIndexedSubscript:row];
            
            
            if ([self.delegate respondsToSelector:@selector(firstFisheyeView:willDisplayCell:)]) {
                [self.delegate firstFisheyeView:self willDisplayCell:artClipView];
            }
            
            
            [self.loopsFitMove addObject:artClipView];
            
            [artClipView strongMetalEarLongerPointer:^{
                
                
                [artClipView setTransform:CGAffineTransformMakeTranslation(- artClipView.frame.size.width-TransientGray, 0)];
                
            } completion:^(BOOL finished) {
                
                [artClipView removeFromSuperview];
                
                
                [self.loopsFitMove removeObject:artClipView];
                
                
                if ([self.delegate respondsToSelector:@selector(firstFisheyeView:didEndDisplayingCell:)]) {
                    [self.delegate firstFisheyeView:self didEndDisplayingCell:artClipView];
                }
                
                
                if (--self.count <= 0) {
                    if ([self.delegate respondsToSelector:@selector(lossyDogConstructSunRawMixDidEncoding:)]) {
                        [self.delegate lossyDogConstructSunRawMixDidEncoding:self];
                    }
                    self.count = 0;
                }
                
                

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


- (void)scalePreferred:(NSArray <SumHisHasDigitCell *> *)barrages
{
    self.count += barrages.count;
    [self.lineArray addObjectsFromArray:barrages];
}

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

- (void)stop
{
    if (self.status == SpectralSampleMileIncreaseBehaveCase) {
        return;
    }
    self.status = SpectralSampleMileIncreaseBehaveCase;
    
    if (self.loopsFitMove.count) {
        [self.loopsFitMove makeObjectsPerformSelector:@selector(pause)];
    }
    
    if (self.lineArray.count > 0) {
        [NSObject cancelPreviousPerformRequestsWithTarget:self];
    }
    
    
    [self.loopsFitMove  makeObjectsPerformSelector:@selector(removeFromSuperview)];
    self.channelCount       = 0;
    self.count              = 0;
    [self.loopsFitMove  removeAllObjects];
    [self.lineArray     removeAllObjects];
    [self.repliesArray  removeAllObjects];
    
    self.loopsFitMove       = nil;
    self.lineArray          = nil;
    self.repliesArray       = nil;
}


- (NSInteger)generatesBaseLawStrategyUniversalWetExec:(SumHisHasDigitCell *)newBarrage
{
    for (int row = 0; row<_repliesArray.count; row++) {
        NSObject *object = _repliesArray[row];
        if ([object isKindOfClass:[NSNumber class]]) { 
            
            return row;
            
        }else if ([object isKindOfClass:[SumHisHasDigitCell class]]) { 
            
            SumHisHasDigitCell *episodeHex = (SumHisHasDigitCell*)object;
            
            if ([self generatesBaseLawStrategyUniversalWetExec:episodeHex linerSong:newBarrage]) {
                
                return row;
            }
        }
    }
    
    return -1;
}


- (BOOL)generatesBaseLawStrategyUniversalWetExec:(SumHisHasDigitCell *)episodeHex linerSong:(SumHisHasDigitCell *)newBarrage
{
    
    if (episodeHex.status == CorrectedHeapSecurityArchiveBaselineStopped) {
        return NO;
    }
    
    
    CGRect rect = [episodeHex.layer.presentationLayer frame];
    if (rect.origin.x>TransientGray - episodeHex.frame.size.width) {
        
        return NO;
    }else if (rect.size.width == 0)
    {
        
        return NO;
    }
    else if (episodeHex.frame.size.width > newBarrage.frame.size.width) {
        
        return YES;
    }else
    {
        
        CGFloat time = TransientGray/(TransientGray+newBarrage.frame.size.width)*newBarrage.tabDolbyMood;
        
        CGFloat idle = rect.origin.x - time/(episodeHex.tabDolbyMood)*(TransientGray + episodeHex.frame.size.width);
        if (idle < -episodeHex.frame.size.width) {
            
            return YES;
        }
    }
    return NO;
}


- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
    UITouch *split = [touches anyObject];
    CGPoint outputsAll  = [split locationInView:self];
    for (SumHisHasDigitCell *artClipView in [self subviews])
    {
        if ([artClipView.layer.presentationLayer hitTest:outputsAll])
        {
            
            if ([self.delegate respondsToSelector:@selector(firstFisheyeView:sheActivityCell:)]) {
                [self.delegate firstFisheyeView:self sheActivityCell:artClipView];
            }
            break;
        }
    }
}




- (NSMutableArray<SumHisHasDigitCell *> *)lineArray {
    if (!_lineArray) {
        _lineArray = [[NSMutableArray alloc] init];
    }
    return _lineArray;
}


- (NSMutableArray<SumHisHasDigitCell *> *)loopsFitMove {
    if (!_loopsFitMove) {
        _loopsFitMove = [[NSMutableArray alloc] init];
    }
    return _loopsFitMove;
}


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


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

@end
