








#import "SheetDaySpaArm.h"

#define SamplingEight self.frame.size.width

@interface SheetDaySpaArm()



@property (nonatomic, strong) NSMutableArray                            *herFeetArray;



@property (nonatomic, strong) NSMutableArray <DryEndNowMolarCell *>      *cubeArray;



@property (strong, nonatomic) NSMutableArray <DryEndNowMolarCell *>      *hostModelDid;



@property (assign, nonatomic) NSInteger                                 count;



@property (nonatomic, assign) ClickedTryPreferFailFilters                          status;



@property (nonatomic, assign) NSInteger                                 channelCount;



@property (nonatomic, assign) CGFloat                                   larger;

@end

@implementation SheetDaySpaArm

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

- (void)postFiltered
{
    
    if (self.cubeArray.firstObject) {
        
        
        DryEndNowMolarCell *quitAnyView = self.cubeArray.firstObject;
        
        quitAnyView.frame = CGRectMake(SamplingEight, 0, quitAnyView.rebuildSize.width, quitAnyView.rebuildSize.height);
        
        self.larger = quitAnyView.larger;
        
        self.channelCount = quitAnyView.channelCount;
        
        
        NSInteger row = [self evaluateConvergedSidebarAlbumMenuExportEffective:quitAnyView];
        
        
        if (row >= 0) {
            
            
            [self.cubeArray removeObjectAtIndex:0];
            
            
            if (![self.subviews containsObject:quitAnyView]) {
                [self addSubview:quitAnyView];
            }
            quitAnyView.frame = CGRectMake(SamplingEight,  row * (quitAnyView.rebuildSize.height + _larger), quitAnyView.rebuildSize.width, quitAnyView.rebuildSize.height);
            
            
            [_herFeetArray setObject:quitAnyView atIndexedSubscript:row];
            
            
            if ([self.delegate respondsToSelector:@selector(logoAnyBoundView:willDisplayCell:)]) {
                [self.delegate logoAnyBoundView:self willDisplayCell:quitAnyView];
            }
            
            
            [self.hostModelDid addObject:quitAnyView];
            
            [quitAnyView hourEulerNotifiesFixLink:^{
                
                
                [quitAnyView setTransform:CGAffineTransformMakeTranslation(- quitAnyView.frame.size.width-SamplingEight, 0)];
                
            } completion:^(BOOL finished) {
                
                [quitAnyView removeFromSuperview];
                
                
                [self.hostModelDid removeObject:quitAnyView];
                
                
                if ([self.delegate respondsToSelector:@selector(logoAnyBoundView:didEndDisplayingCell:)]) {
                    [self.delegate logoAnyBoundView:self didEndDisplayingCell:quitAnyView];
                }
                
                
                if (--self.count <= 0) {
                    if ([self.delegate respondsToSelector:@selector(thirteenJustGrowNodeSensorProductsArmStroke:)]) {
                        [self.delegate thirteenJustGrowNodeSensorProductsArmStroke:self];
                    }
                    self.count = 0;
                }
                
                

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


- (void)leadMediaStale:(NSArray <DryEndNowMolarCell *> *)barrages
{
    self.count += barrages.count;
    [self.cubeArray addObjectsFromArray:barrages];
}

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

- (void)stop
{
    if (self.status == TropicalVowelStairAlbanianWasKey) {
        return;
    }
    self.status = TropicalVowelStairAlbanianWasKey;
    
    if (self.hostModelDid.count) {
        [self.hostModelDid makeObjectsPerformSelector:@selector(pause)];
    }
    
    if (self.cubeArray.count > 0) {
        [NSObject cancelPreviousPerformRequestsWithTarget:self];
    }
    
    
    [self.hostModelDid  makeObjectsPerformSelector:@selector(removeFromSuperview)];
    self.channelCount       = 0;
    self.count              = 0;
    [self.hostModelDid  removeAllObjects];
    [self.cubeArray     removeAllObjects];
    [self.herFeetArray  removeAllObjects];
    
    self.hostModelDid       = nil;
    self.cubeArray          = nil;
    self.herFeetArray       = nil;
}


- (NSInteger)evaluateConvergedSidebarAlbumMenuExportEffective:(DryEndNowMolarCell *)newBarrage
{
    for (int row = 0; row<_herFeetArray.count; row++) {
        NSObject *object = _herFeetArray[row];
        if ([object isKindOfClass:[NSNumber class]]) { 
            
            return row;
            
        }else if ([object isKindOfClass:[DryEndNowMolarCell class]]) { 
            
            DryEndNowMolarCell *sheTeamSun = (DryEndNowMolarCell*)object;
            
            if ([self evaluateConvergedSidebarAlbumMenuExportEffective:sheTeamSun speechAnd:newBarrage]) {
                
                return row;
            }
        }
    }
    
    return -1;
}


- (BOOL)evaluateConvergedSidebarAlbumMenuExportEffective:(DryEndNowMolarCell *)sheTeamSun speechAnd:(DryEndNowMolarCell *)newBarrage
{
    
    if (sheTeamSun.status == BurstTwoRetrieveCathedralKelvinAbsent) {
        return NO;
    }
    
    
    CGRect rect = [sheTeamSun.layer.presentationLayer frame];
    if (rect.origin.x>SamplingEight - sheTeamSun.frame.size.width) {
        
        return NO;
    }else if (rect.size.width == 0)
    {
        
        return NO;
    }
    else if (sheTeamSun.frame.size.width > newBarrage.frame.size.width) {
        
        return YES;
    }else
    {
        
        CGFloat time = SamplingEight/(SamplingEight+newBarrage.frame.size.width)*newBarrage.sinLocalRest;
        
        CGFloat deny = rect.origin.x - time/(sheTeamSun.sinLocalRest)*(SamplingEight + sheTeamSun.frame.size.width);
        if (deny < -sheTeamSun.frame.size.width) {
            
            return YES;
        }
    }
    return NO;
}


- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
    UITouch *datum = [touches anyObject];
    CGPoint rankBounce  = [datum locationInView:self];
    for (UIView *fairLaw in [self subviews])
    {
        if (![fairLaw isKindOfClass:[DryEndNowMolarCell class]]) continue;
        DryEndNowMolarCell *quitAnyView = (DryEndNowMolarCell *)fairLaw;
        if ([quitAnyView.layer.presentationLayer hitTest:rankBounce])
        {
            
            if ([self.delegate respondsToSelector:@selector(logoAnyBoundView:shotRemovalCell:)]) {
                [self.delegate logoAnyBoundView:self shotRemovalCell:quitAnyView];
            }
            break;
        }
    }
}




- (NSMutableArray<DryEndNowMolarCell *> *)cubeArray {
    if (!_cubeArray) {
        _cubeArray = [[NSMutableArray alloc] init];
    }
    return _cubeArray;
}


- (NSMutableArray<DryEndNowMolarCell *> *)hostModelDid {
    if (!_hostModelDid) {
        _hostModelDid = [[NSMutableArray alloc] init];
    }
    return _hostModelDid;
}


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


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

@end
