








#import "BinFoundBadFar.h"

#define SaySixBlurPut self.frame.size.width

@interface BinFoundBadFar()



@property (nonatomic, strong) NSMutableArray                            *pingTipArray;



@property (nonatomic, strong) NSMutableArray <SoftSizeIcyAndCell *>      *usedArray;



@property (strong, nonatomic) NSMutableArray <SoftSizeIcyAndCell *>      *slashRedoUse;



@property (assign, nonatomic) NSInteger                                 count;



@property (nonatomic, assign) TrySatisfiedDecibelEligibleFade                          status;



@property (nonatomic, assign) NSInteger                                 channelCount;



@property (nonatomic, assign) CGFloat                                   watery;

@end

@implementation BinFoundBadFar

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

- (void)bleedWonSelf
{
    
    if (self.usedArray.firstObject) {
        
        
        SoftSizeIcyAndCell *prepOutView = self.usedArray.firstObject;
        
        prepOutView.frame = CGRectMake(SaySixBlurPut, 0, prepOutView.retriedSize.width, prepOutView.retriedSize.height);
        
        self.watery = prepOutView.watery;
        
        self.channelCount = prepOutView.channelCount;
        
        
        NSInteger row = [self descentRadiansFarObservingPlateRenderEarly:prepOutView];
        
        
        if (row >= 0) {
            
            
            [self.usedArray removeObjectAtIndex:0];
            
            
            if (![self.subviews containsObject:prepOutView]) {
                [self addSubview:prepOutView];
            }
            prepOutView.frame = CGRectMake(SaySixBlurPut,  row * (prepOutView.retriedSize.height + _watery), prepOutView.retriedSize.width, prepOutView.retriedSize.height);
            
            
            [_pingTipArray setObject:prepOutView atIndexedSubscript:row];
            
            
            if ([self.delegate respondsToSelector:@selector(tryUnchangedView:willDisplayCell:)]) {
                [self.delegate tryUnchangedView:self willDisplayCell:prepOutView];
            }
            
            
            [self.slashRedoUse addObject:prepOutView];
            
            [prepOutView entropyFlatPlaybackFutureSwipe:^{
                
                
                [prepOutView setTransform:CGAffineTransformMakeTranslation(- prepOutView.frame.size.width-SaySixBlurPut, 0)];
                
            } completion:^(BOOL finished) {
                
                [prepOutView removeFromSuperview];
                
                
                [self.slashRedoUse removeObject:prepOutView];
                
                
                if ([self.delegate respondsToSelector:@selector(tryUnchangedView:didEndDisplayingCell:)]) {
                    [self.delegate tryUnchangedView:self didEndDisplayingCell:prepOutView];
                }
                
                
                if (--self.count <= 0) {
                    if ([self.delegate respondsToSelector:@selector(coloredMetabolicClientsLossySignalInventoryCanGreater:)]) {
                        [self.delegate coloredMetabolicClientsLossySignalInventoryCanGreater:self];
                    }
                    self.count = 0;
                }
                
                

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


- (void)effectReverses:(NSArray <SoftSizeIcyAndCell *> *)barrages
{
    self.count += barrages.count;
    [self.usedArray addObjectsFromArray:barrages];
}

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

- (void)stop
{
    if (self.status == MayOriginsDisorderAdditionWatchedUrgency) {
        return;
    }
    self.status = MayOriginsDisorderAdditionWatchedUrgency;
    
    if (self.slashRedoUse.count) {
        [self.slashRedoUse makeObjectsPerformSelector:@selector(pause)];
    }
    
    if (self.usedArray.count > 0) {
        [NSObject cancelPreviousPerformRequestsWithTarget:self];
    }
    
    
    [self.slashRedoUse  makeObjectsPerformSelector:@selector(removeFromSuperview)];
    self.channelCount       = 0;
    self.count              = 0;
    [self.slashRedoUse  removeAllObjects];
    [self.usedArray     removeAllObjects];
    [self.pingTipArray  removeAllObjects];
    
    self.slashRedoUse       = nil;
    self.usedArray          = nil;
    self.pingTipArray       = nil;
}


- (NSInteger)descentRadiansFarObservingPlateRenderEarly:(SoftSizeIcyAndCell *)newBarrage
{
    for (int row = 0; row<_pingTipArray.count; row++) {
        NSObject *object = _pingTipArray[row];
        if ([object isKindOfClass:[NSNumber class]]) { 
            
            return row;
            
        }else if ([object isKindOfClass:[SoftSizeIcyAndCell class]]) { 
            
            SoftSizeIcyAndCell *downEncode = (SoftSizeIcyAndCell*)object;
            
            if ([self descentRadiansFarObservingPlateRenderEarly:downEncode unplugged:newBarrage]) {
                
                return row;
            }
        }
    }
    
    return -1;
}


- (BOOL)descentRadiansFarObservingPlateRenderEarly:(SoftSizeIcyAndCell *)downEncode unplugged:(SoftSizeIcyAndCell *)newBarrage
{
    
    if (downEncode.status == StrokedBoxResumedHoverAssistantPost) {
        return NO;
    }
    
    
    CGRect rect = [downEncode.layer.presentationLayer frame];
    if (rect.origin.x>SaySixBlurPut - downEncode.frame.size.width) {
        
        return NO;
    }else if (rect.size.width == 0)
    {
        
        return NO;
    }
    else if (downEncode.frame.size.width > newBarrage.frame.size.width) {
        
        return YES;
    }else
    {
        
        CGFloat time = SaySixBlurPut/(SaySixBlurPut+newBarrage.frame.size.width)*newBarrage.monthFailing;
        
        CGFloat gram = rect.origin.x - time/(downEncode.monthFailing)*(SaySixBlurPut + downEncode.frame.size.width);
        if (gram < -downEncode.frame.size.width) {
            
            return YES;
        }
    }
    return NO;
}


- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
    UITouch *loose = [touches anyObject];
    CGPoint penItalian  = [loose locationInView:self];
    for (UIView *dropCut in [self subviews])
    {
        if (![dropCut isKindOfClass:[SoftSizeIcyAndCell class]]) continue;
        SoftSizeIcyAndCell *prepOutView = (SoftSizeIcyAndCell *)dropCut;
        if ([prepOutView.layer.presentationLayer hitTest:penItalian])
        {
            
            if ([self.delegate respondsToSelector:@selector(tryUnchangedView:dispenseOneCell:)]) {
                [self.delegate tryUnchangedView:self dispenseOneCell:prepOutView];
            }
            break;
        }
    }
}




- (NSMutableArray<SoftSizeIcyAndCell *> *)usedArray {
    if (!_usedArray) {
        _usedArray = [[NSMutableArray alloc] init];
    }
    return _usedArray;
}


- (NSMutableArray<SoftSizeIcyAndCell *> *)slashRedoUse {
    if (!_slashRedoUse) {
        _slashRedoUse = [[NSMutableArray alloc] init];
    }
    return _slashRedoUse;
}


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


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

@end
