








#import "UnitCanSumDust.h"

#define CapAllReports self.frame.size.width

@interface UnitCanSumDust()



@property (nonatomic, strong) NSMutableArray                            *bagBestArray;



@property (nonatomic, strong) NSMutableArray <UnifyFlatBringCell *>      *maleArray;



@property (strong, nonatomic) NSMutableArray <UnifyFlatBringCell *>      *cookiesInner;



@property (assign, nonatomic) NSInteger                                 count;



@property (nonatomic, assign) TradReachableHumanEulerDeny                          status;



@property (nonatomic, assign) NSInteger                                 channelCount;



@property (nonatomic, assign) CGFloat                                   coptic;

@end

@implementation UnitCanSumDust

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

- (void)lawBitExtern
{
    
    if (self.maleArray.firstObject) {
        
        
        UnifyFlatBringCell *butHeapView = self.maleArray.firstObject;
        
        butHeapView.frame = CGRectMake(CapAllReports, 0, butHeapView.retriedSize.width, butHeapView.retriedSize.height);
        
        self.coptic = butHeapView.coptic;
        
        self.channelCount = butHeapView.channelCount;
        
        
        NSInteger row = [self catShortcutsKashmiriFormattedChromeFragmentsWorld:butHeapView];
        
        
        if (row >= 0) {
            
            
            [self.maleArray removeObjectAtIndex:0];
            
            
            if (![self.subviews containsObject:butHeapView]) {
                [self addSubview:butHeapView];
            }
            butHeapView.frame = CGRectMake(CapAllReports,  row * (butHeapView.retriedSize.height + _coptic), butHeapView.retriedSize.width, butHeapView.retriedSize.height);
            
            
            [_bagBestArray setObject:butHeapView atIndexedSubscript:row];
            
            
            if ([self.delegate respondsToSelector:@selector(bendEscapingView:willDisplayCell:)]) {
                [self.delegate bendEscapingView:self willDisplayCell:butHeapView];
            }
            
            
            [self.cookiesInner addObject:butHeapView];
            
            [butHeapView operatingCameraAllPerformsSolutions:^{
                
                
                [butHeapView setTransform:CGAffineTransformMakeTranslation(- butHeapView.frame.size.width-CapAllReports, 0)];
                
            } completion:^(BOOL finished) {
                
                [butHeapView removeFromSuperview];
                
                
                [self.cookiesInner removeObject:butHeapView];
                
                
                if ([self.delegate respondsToSelector:@selector(bendEscapingView:didEndDisplayingCell:)]) {
                    [self.delegate bendEscapingView:self didEndDisplayingCell:butHeapView];
                }
                
                
                if (--self.count <= 0) {
                    if ([self.delegate respondsToSelector:@selector(undoneNotifiedPinchFlatAutoSmartComposerLetters:)]) {
                        [self.delegate undoneNotifiedPinchFlatAutoSmartComposerLetters:self];
                    }
                    self.count = 0;
                }
                
                

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


- (void)hailMenOurRing:(NSArray <UnifyFlatBringCell *> *)barrages
{
    self.count += barrages.count;
    [self.maleArray addObjectsFromArray:barrages];
}

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

- (void)stop
{
    if (self.status == YellowPolicyTwistBondKeepZip) {
        return;
    }
    self.status = YellowPolicyTwistBondKeepZip;
    
    if (self.cookiesInner.count) {
        [self.cookiesInner makeObjectsPerformSelector:@selector(pause)];
    }
    
    if (self.maleArray.count > 0) {
        [NSObject cancelPreviousPerformRequestsWithTarget:self];
    }
    
    
    [self.cookiesInner  makeObjectsPerformSelector:@selector(removeFromSuperview)];
    self.channelCount       = 0;
    self.count              = 0;
    [self.cookiesInner  removeAllObjects];
    [self.maleArray     removeAllObjects];
    [self.bagBestArray  removeAllObjects];
    
    self.cookiesInner       = nil;
    self.maleArray          = nil;
    self.bagBestArray       = nil;
}


- (NSInteger)catShortcutsKashmiriFormattedChromeFragmentsWorld:(UnifyFlatBringCell *)newBarrage
{
    for (int row = 0; row<_bagBestArray.count; row++) {
        NSObject *object = _bagBestArray[row];
        if ([object isKindOfClass:[NSNumber class]]) { 
            
            return row;
            
        }else if ([object isKindOfClass:[UnifyFlatBringCell class]]) { 
            
            UnifyFlatBringCell *versionSob = (UnifyFlatBringCell*)object;
            
            if ([self catShortcutsKashmiriFormattedChromeFragmentsWorld:versionSob onlyQueue:newBarrage]) {
                
                return row;
            }
        }
    }
    
    return -1;
}


- (BOOL)catShortcutsKashmiriFormattedChromeFragmentsWorld:(UnifyFlatBringCell *)versionSob onlyQueue:(UnifyFlatBringCell *)newBarrage
{
    
    if (versionSob.status == ThreadEnvelopeProcessGolfGopherDust) {
        return NO;
    }
    
    
    CGRect rect = [versionSob.layer.presentationLayer frame];
    if (rect.origin.x>CapAllReports - versionSob.frame.size.width) {
        
        return NO;
    }else if (rect.size.width == 0)
    {
        
        return NO;
    }
    else if (versionSob.frame.size.width > newBarrage.frame.size.width) {
        
        return YES;
    }else
    {
        
        CGFloat time = CapAllReports/(CapAllReports+newBarrage.frame.size.width)*newBarrage.closeDropIll;
        
        CGFloat scan = rect.origin.x - time/(versionSob.closeDropIll)*(CapAllReports + versionSob.frame.size.width);
        if (scan < -versionSob.frame.size.width) {
            
            return YES;
        }
    }
    return NO;
}


- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
    UITouch *vital = [touches anyObject];
    CGPoint removesEra  = [vital locationInView:self];
    for (UIView *farFlag in [self subviews])
    {
        if (![farFlag isKindOfClass:[UnifyFlatBringCell class]]) continue;
        UnifyFlatBringCell *butHeapView = (UnifyFlatBringCell *)farFlag;
        if ([butHeapView.layer.presentationLayer hitTest:removesEra])
        {
            
            if ([self.delegate respondsToSelector:@selector(bendEscapingView:tagsStopAskCell:)]) {
                [self.delegate bendEscapingView:self tagsStopAskCell:butHeapView];
            }
            break;
        }
    }
}




- (NSMutableArray<UnifyFlatBringCell *> *)maleArray {
    if (!_maleArray) {
        _maleArray = [[NSMutableArray alloc] init];
    }
    return _maleArray;
}


- (NSMutableArray<UnifyFlatBringCell *> *)cookiesInner {
    if (!_cookiesInner) {
        _cookiesInner = [[NSMutableArray alloc] init];
    }
    return _cookiesInner;
}


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


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

@end
