








#import "NetButTraitMax.h"

#define BedTiedAnyLaw self.frame.size.width

@interface NetButTraitMax()



@property (nonatomic, strong) NSMutableArray                            *talkLawArray;



@property (nonatomic, strong) NSMutableArray <GoalItalicThatCell *>      *shotArray;



@property (strong, nonatomic) NSMutableArray <GoalItalicThatCell *>      *defineCancel;



@property (assign, nonatomic) NSInteger                                 count;



@property (nonatomic, assign) ShowSkinTabSlovakBit                          status;



@property (nonatomic, assign) NSInteger                                 channelCount;



@property (nonatomic, assign) CGFloat                                   busWay;

@end

@implementation NetButTraitMax

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

- (void)theGatherMax
{
    
    if (self.shotArray.firstObject) {
        
        
        GoalItalicThatCell *dashOurView = self.shotArray.firstObject;
        
        dashOurView.frame = CGRectMake(BedTiedAnyLaw, 0, dashOurView.gainTenSize.width, dashOurView.gainTenSize.height);
        
        self.busWay = dashOurView.busWay;
        
        self.channelCount = dashOurView.channelCount;
        
        
        NSInteger row = [self mouthKinSchoolNorwegianListenerPermittedSpa:dashOurView];
        
        
        if (row >= 0) {
            
            
            [self.shotArray removeObjectAtIndex:0];
            
            
            if (![self.subviews containsObject:dashOurView]) {
                [self addSubview:dashOurView];
            }
            dashOurView.frame = CGRectMake(BedTiedAnyLaw,  row * (dashOurView.gainTenSize.height + _busWay), dashOurView.gainTenSize.width, dashOurView.gainTenSize.height);
            
            
            [_talkLawArray setObject:dashOurView atIndexedSubscript:row];
            
            
            if ([self.delegate respondsToSelector:@selector(boxAnyChangeView:willDisplayCell:)]) {
                [self.delegate boxAnyChangeView:self willDisplayCell:dashOurView];
            }
            
            
            [self.defineCancel addObject:dashOurView];
            
            [dashOurView delayedSinhaleseLogExternalNecessary:^{
                
                
                [dashOurView setTransform:CGAffineTransformMakeTranslation(- dashOurView.frame.size.width-BedTiedAnyLaw, 0)];
                
            } completion:^(BOOL finished) {
                
                [dashOurView removeFromSuperview];
                
                
                [self.defineCancel removeObject:dashOurView];
                
                
                if ([self.delegate respondsToSelector:@selector(boxAnyChangeView:didEndDisplayingCell:)]) {
                    [self.delegate boxAnyChangeView:self didEndDisplayingCell:dashOurView];
                }
                
                
                if (--self.count <= 0) {
                    if ([self.delegate respondsToSelector:@selector(oldDecoderUnlikelyMemberHertzAuthorsCalendarLongest:)]) {
                        [self.delegate oldDecoderUnlikelyMemberHertzAuthorsCalendarLongest:self];
                    }
                    self.count = 0;
                }
                
                

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


- (void)penMinorWaxBin:(NSArray <GoalItalicThatCell *> *)barrages
{
    self.count += barrages.count;
    [self.shotArray addObjectsFromArray:barrages];
}

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

- (void)stop
{
    if (self.status == ObscuresLingerDiamondSelectGlobalExactness) {
        return;
    }
    self.status = ObscuresLingerDiamondSelectGlobalExactness;
    
    if (self.defineCancel.count) {
        [self.defineCancel makeObjectsPerformSelector:@selector(pause)];
    }
    
    if (self.shotArray.count > 0) {
        [NSObject cancelPreviousPerformRequestsWithTarget:self];
    }
    
    
    [self.defineCancel  makeObjectsPerformSelector:@selector(removeFromSuperview)];
    self.channelCount       = 0;
    self.count              = 0;
    [self.defineCancel  removeAllObjects];
    [self.shotArray     removeAllObjects];
    [self.talkLawArray  removeAllObjects];
    
    self.defineCancel       = nil;
    self.shotArray          = nil;
    self.talkLawArray       = nil;
}


- (NSInteger)mouthKinSchoolNorwegianListenerPermittedSpa:(GoalItalicThatCell *)newBarrage
{
    for (int row = 0; row<_talkLawArray.count; row++) {
        NSObject *object = _talkLawArray[row];
        if ([object isKindOfClass:[NSNumber class]]) { 
            
            return row;
            
        }else if ([object isKindOfClass:[GoalItalicThatCell class]]) { 
            
            GoalItalicThatCell *spaceLabel = (GoalItalicThatCell*)object;
            
            if ([self mouthKinSchoolNorwegianListenerPermittedSpa:spaceLabel logoHertz:newBarrage]) {
                
                return row;
            }
        }
    }
    
    return -1;
}


- (BOOL)mouthKinSchoolNorwegianListenerPermittedSpa:(GoalItalicThatCell *)spaceLabel logoHertz:(GoalItalicThatCell *)newBarrage
{
    
    if (spaceLabel.status == ConvertOptimizedChinaMayBiometryCampaign) {
        return NO;
    }
    
    
    CGRect rect = [spaceLabel.layer.presentationLayer frame];
    if (rect.origin.x>BedTiedAnyLaw - spaceLabel.frame.size.width) {
        
        return NO;
    }else if (rect.size.width == 0)
    {
        
        return NO;
    }
    else if (spaceLabel.frame.size.width > newBarrage.frame.size.width) {
        
        return YES;
    }else
    {
        
        CGFloat time = BedTiedAnyLaw/(BedTiedAnyLaw+newBarrage.frame.size.width)*newBarrage.boundCadence;
        
        CGFloat math = rect.origin.x - time/(spaceLabel.boundCadence)*(BedTiedAnyLaw + spaceLabel.frame.size.width);
        if (math < -spaceLabel.frame.size.width) {
            
            return YES;
        }
    }
    return NO;
}


- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
    UITouch *stone = [touches anyObject];
    CGPoint minorPause  = [stone locationInView:self];
    for (UIView *counted in [self subviews])
    {
        if (![counted isKindOfClass:[GoalItalicThatCell class]]) continue;
        GoalItalicThatCell *dashOurView = (GoalItalicThatCell *)counted;
        if ([dashOurView.layer.presentationLayer hitTest:minorPause])
        {
            
            if ([self.delegate respondsToSelector:@selector(boxAnyChangeView:daysOffNameCell:)]) {
                [self.delegate boxAnyChangeView:self daysOffNameCell:dashOurView];
            }
            break;
        }
    }
}




- (NSMutableArray<GoalItalicThatCell *> *)shotArray {
    if (!_shotArray) {
        _shotArray = [[NSMutableArray alloc] init];
    }
    return _shotArray;
}


- (NSMutableArray<GoalItalicThatCell *> *)defineCancel {
    if (!_defineCancel) {
        _defineCancel = [[NSMutableArray alloc] init];
    }
    return _defineCancel;
}


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


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

@end
