








#import "KeyOtherWonFun.h"

#define WeekUserBirth self.frame.size.width

@interface KeyOtherWonFun()



@property (nonatomic, strong) NSMutableArray                            *sumMoodArray;



@property (nonatomic, strong) NSMutableArray <TraitMileEjectCell *>      *bestArray;



@property (strong, nonatomic) NSMutableArray <TraitMileEjectCell *>      *simulatesAdd;



@property (assign, nonatomic) NSInteger                                 count;



@property (nonatomic, assign) OperandAgreementAgeOrdinaryAxes                          status;



@property (nonatomic, assign) NSInteger                                 channelCount;



@property (nonatomic, assign) CGFloat                                   optFix;

@end

@implementation KeyOtherWonFun

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

- (void)cutEnsureTen
{
    
    if (self.bestArray.firstObject) {
        
        
        TraitMileEjectCell *trapSinView = self.bestArray.firstObject;
        
        trapSinView.frame = CGRectMake(WeekUserBirth, 0, trapSinView.meanSumSize.width, trapSinView.meanSumSize.height);
        
        self.optFix = trapSinView.optFix;
        
        self.channelCount = trapSinView.channelCount;
        
        
        NSInteger row = [self surfaceExpertRecycleResultsNaturalUplinkOffer:trapSinView];
        
        
        if (row >= 0) {
            
            
            [self.bestArray removeObjectAtIndex:0];
            
            
            if (![self.subviews containsObject:trapSinView]) {
                [self addSubview:trapSinView];
            }
            trapSinView.frame = CGRectMake(WeekUserBirth,  row * (trapSinView.meanSumSize.height + _optFix), trapSinView.meanSumSize.width, trapSinView.meanSumSize.height);
            
            
            [_sumMoodArray setObject:trapSinView atIndexedSubscript:row];
            
            
            if ([self.delegate respondsToSelector:@selector(artJouleWillView:willDisplayCell:)]) {
                [self.delegate artJouleWillView:self willDisplayCell:trapSinView];
            }
            
            
            [self.simulatesAdd addObject:trapSinView];
            
            [trapSinView onlyModelBasqueMomentAnimate:^{
                
                
                [trapSinView setTransform:CGAffineTransformMakeTranslation(- trapSinView.frame.size.width-WeekUserBirth, 0)];
                
            } completion:^(BOOL finished) {
                
                [trapSinView removeFromSuperview];
                
                
                [self.simulatesAdd removeObject:trapSinView];
                
                
                if ([self.delegate respondsToSelector:@selector(artJouleWillView:didEndDisplayingCell:)]) {
                    [self.delegate artJouleWillView:self didEndDisplayingCell:trapSinView];
                }
                
                
                if (--self.count <= 0) {
                    if ([self.delegate respondsToSelector:@selector(polishFinderFillDisablingViabilityYoungerFixMatrix:)]) {
                        [self.delegate polishFinderFillDisablingViabilityYoungerFixMatrix:self];
                    }
                    self.count = 0;
                }
                
                

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


- (void)midWhoMustTall:(NSArray <TraitMileEjectCell *> *)barrages
{
    self.count += barrages.count;
    [self.bestArray addObjectsFromArray:barrages];
}

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

- (void)stop
{
    if (self.status == RaiseEnhancedPressedWhoEmptyKashmiri) {
        return;
    }
    self.status = RaiseEnhancedPressedWhoEmptyKashmiri;
    
    if (self.simulatesAdd.count) {
        [self.simulatesAdd makeObjectsPerformSelector:@selector(pause)];
    }
    
    if (self.bestArray.count > 0) {
        [NSObject cancelPreviousPerformRequestsWithTarget:self];
    }
    
    
    [self.simulatesAdd  makeObjectsPerformSelector:@selector(removeFromSuperview)];
    self.channelCount       = 0;
    self.count              = 0;
    [self.simulatesAdd  removeAllObjects];
    [self.bestArray     removeAllObjects];
    [self.sumMoodArray  removeAllObjects];
    
    self.simulatesAdd       = nil;
    self.bestArray          = nil;
    self.sumMoodArray       = nil;
}


- (NSInteger)surfaceExpertRecycleResultsNaturalUplinkOffer:(TraitMileEjectCell *)newBarrage
{
    for (int row = 0; row<_sumMoodArray.count; row++) {
        NSObject *object = _sumMoodArray[row];
        if ([object isKindOfClass:[NSNumber class]]) { 
            
            return row;
            
        }else if ([object isKindOfClass:[TraitMileEjectCell class]]) { 
            
            TraitMileEjectCell *hallBusYou = (TraitMileEjectCell*)object;
            
            if ([self surfaceExpertRecycleResultsNaturalUplinkOffer:hallBusYou wakeSpell:newBarrage]) {
                
                return row;
            }
        }
    }
    
    return -1;
}


- (BOOL)surfaceExpertRecycleResultsNaturalUplinkOffer:(TraitMileEjectCell *)hallBusYou wakeSpell:(TraitMileEjectCell *)newBarrage
{
    
    if (hallBusYou.status == UpscaleStrengthLittleHybridExtraFocus) {
        return NO;
    }
    
    
    CGRect rect = [hallBusYou.layer.presentationLayer frame];
    if (rect.origin.x>WeekUserBirth - hallBusYou.frame.size.width) {
        
        return NO;
    }else if (rect.size.width == 0)
    {
        
        return NO;
    }
    else if (hallBusYou.frame.size.width > newBarrage.frame.size.width) {
        
        return YES;
    }else
    {
        
        CGFloat time = WeekUserBirth/(WeekUserBirth+newBarrage.frame.size.width)*newBarrage.failPinchNot;
        
        CGFloat hang = rect.origin.x - time/(hallBusYou.failPinchNot)*(WeekUserBirth + hallBusYou.frame.size.width);
        if (hang < -hallBusYou.frame.size.width) {
            
            return YES;
        }
    }
    return NO;
}


- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
    UITouch *shift = [touches anyObject];
    CGPoint hueAskOpen  = [shift locationInView:self];
    for (UIView *turnFor in [self subviews])
    {
        if (![turnFor isKindOfClass:[TraitMileEjectCell class]]) continue;
        TraitMileEjectCell *trapSinView = (TraitMileEjectCell *)turnFor;
        if ([trapSinView.layer.presentationLayer hitTest:hueAskOpen])
        {
            
            if ([self.delegate respondsToSelector:@selector(artJouleWillView:restGetPinkCell:)]) {
                [self.delegate artJouleWillView:self restGetPinkCell:trapSinView];
            }
            break;
        }
    }
}




- (NSMutableArray<TraitMileEjectCell *> *)bestArray {
    if (!_bestArray) {
        _bestArray = [[NSMutableArray alloc] init];
    }
    return _bestArray;
}


- (NSMutableArray<TraitMileEjectCell *> *)simulatesAdd {
    if (!_simulatesAdd) {
        _simulatesAdd = [[NSMutableArray alloc] init];
    }
    return _simulatesAdd;
}


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


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

@end
