








#import "SuffixRestores.h"

#define SayAreVisible self.frame.size.width

@interface SuffixRestores()



@property (nonatomic, strong) NSMutableArray                            *kerningArray;



@property (nonatomic, strong) NSMutableArray <PubAnyPartDrumCell *>      *dropArray;



@property (strong, nonatomic) NSMutableArray <PubAnyPartDrumCell *>      *spineBagSnap;



@property (assign, nonatomic) NSInteger                                 count;



@property (nonatomic, assign) MomentNearLatitudeMegawattsScale                          status;



@property (nonatomic, assign) NSInteger                                 channelCount;



@property (nonatomic, assign) CGFloat                                   obtain;

@end

@implementation SuffixRestores

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

- (void)detailNotCan
{
    
    if (self.dropArray.firstObject) {
        
        
        PubAnyPartDrumCell *scanWonView = self.dropArray.firstObject;
        
        scanWonView.frame = CGRectMake(SayAreVisible, 0, scanWonView.mapSkinSize.width, scanWonView.mapSkinSize.height);
        
        self.obtain = scanWonView.obtain;
        
        self.channelCount = scanWonView.channelCount;
        
        
        NSInteger row = [self twelveOpacityActualDeleteVitalOutletSelection:scanWonView];
        
        
        if (row >= 0) {
            
            
            [self.dropArray removeObjectAtIndex:0];
            
            
            if (![self.subviews containsObject:scanWonView]) {
                [self addSubview:scanWonView];
            }
            scanWonView.frame = CGRectMake(SayAreVisible,  row * (scanWonView.mapSkinSize.height + _obtain), scanWonView.mapSkinSize.width, scanWonView.mapSkinSize.height);
            
            
            [_kerningArray setObject:scanWonView atIndexedSubscript:row];
            
            
            if ([self.delegate respondsToSelector:@selector(hisSinkReuseView:willDisplayCell:)]) {
                [self.delegate hisSinkReuseView:self willDisplayCell:scanWonView];
            }
            
            
            [self.spineBagSnap addObject:scanWonView];
            
            [scanWonView routeApplierExtentNodeWill:^{
                
                
                [scanWonView setTransform:CGAffineTransformMakeTranslation(- scanWonView.frame.size.width-SayAreVisible, 0)];
                
            } completion:^(BOOL finished) {
                
                [scanWonView removeFromSuperview];
                
                
                [self.spineBagSnap removeObject:scanWonView];
                
                
                if ([self.delegate respondsToSelector:@selector(hisSinkReuseView:didEndDisplayingCell:)]) {
                    [self.delegate hisSinkReuseView:self didEndDisplayingCell:scanWonView];
                }
                
                
                if (--self.count <= 0) {
                    if ([self.delegate respondsToSelector:@selector(trackingStylusTokenSheFrameStartMenCup:)]) {
                        [self.delegate trackingStylusTokenSheFrameStartMenCup:self];
                    }
                    self.count = 0;
                }
                
                

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


- (void)oneChatLoudPan:(NSArray <PubAnyPartDrumCell *> *)barrages
{
    self.count += barrages.count;
    [self.dropArray addObjectsFromArray:barrages];
}

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

- (void)stop
{
    if (self.status == DecodingRepublicOurPivotIndexingSundanese) {
        return;
    }
    self.status = DecodingRepublicOurPivotIndexingSundanese;
    
    if (self.spineBagSnap.count) {
        [self.spineBagSnap makeObjectsPerformSelector:@selector(pause)];
    }
    
    if (self.dropArray.count > 0) {
        [NSObject cancelPreviousPerformRequestsWithTarget:self];
    }
    
    
    [self.spineBagSnap  makeObjectsPerformSelector:@selector(removeFromSuperview)];
    self.channelCount       = 0;
    self.count              = 0;
    [self.spineBagSnap  removeAllObjects];
    [self.dropArray     removeAllObjects];
    [self.kerningArray  removeAllObjects];
    
    self.spineBagSnap       = nil;
    self.dropArray          = nil;
    self.kerningArray       = nil;
}


- (NSInteger)twelveOpacityActualDeleteVitalOutletSelection:(PubAnyPartDrumCell *)newBarrage
{
    for (int row = 0; row<_kerningArray.count; row++) {
        NSObject *object = _kerningArray[row];
        if ([object isKindOfClass:[NSNumber class]]) { 
            
            return row;
            
        }else if ([object isKindOfClass:[PubAnyPartDrumCell class]]) { 
            
            PubAnyPartDrumCell *kitSlowHow = (PubAnyPartDrumCell*)object;
            
            if ([self twelveOpacityActualDeleteVitalOutletSelection:kitSlowHow helpFloor:newBarrage]) {
                
                return row;
            }
        }
    }
    
    return -1;
}


- (BOOL)twelveOpacityActualDeleteVitalOutletSelection:(PubAnyPartDrumCell *)kitSlowHow helpFloor:(PubAnyPartDrumCell *)newBarrage
{
    
    if (kitSlowHow.status == TryOffParentReclaimDissolveHue) {
        return NO;
    }
    
    
    CGRect rect = [kitSlowHow.layer.presentationLayer frame];
    if (rect.origin.x>SayAreVisible - kitSlowHow.frame.size.width) {
        
        return NO;
    }else if (rect.size.width == 0)
    {
        
        return NO;
    }
    else if (kitSlowHow.frame.size.width > newBarrage.frame.size.width) {
        
        return YES;
    }else
    {
        
        CGFloat time = SayAreVisible/(SayAreVisible+newBarrage.frame.size.width)*newBarrage.assetAirline;
        
        CGFloat book = rect.origin.x - time/(kitSlowHow.assetAirline)*(SayAreVisible + kitSlowHow.frame.size.width);
        if (book < -kitSlowHow.frame.size.width) {
            
            return YES;
        }
    }
    return NO;
}


- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
    UITouch *exits = [touches anyObject];
    CGPoint matchGiven  = [exits locationInView:self];
    for (UIView *tagFive in [self subviews])
    {
        if (![tagFive isKindOfClass:[PubAnyPartDrumCell class]]) continue;
        PubAnyPartDrumCell *scanWonView = (PubAnyPartDrumCell *)tagFive;
        if ([scanWonView.layer.presentationLayer hitTest:matchGiven])
        {
            
            if ([self.delegate respondsToSelector:@selector(hisSinkReuseView:backRenewedCell:)]) {
                [self.delegate hisSinkReuseView:self backRenewedCell:scanWonView];
            }
            break;
        }
    }
}




- (NSMutableArray<PubAnyPartDrumCell *> *)dropArray {
    if (!_dropArray) {
        _dropArray = [[NSMutableArray alloc] init];
    }
    return _dropArray;
}


- (NSMutableArray<PubAnyPartDrumCell *> *)spineBagSnap {
    if (!_spineBagSnap) {
        _spineBagSnap = [[NSMutableArray alloc] init];
    }
    return _spineBagSnap;
}


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


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

@end
