








#import "MinderCubeWide.h"

#define StairIcyWidth self.frame.size.width

@interface MinderCubeWide()



@property (nonatomic, strong) NSMutableArray                            *popNameArray;



@property (nonatomic, strong) NSMutableArray <ClangCoverForkCell *>      *gaspArray;



@property (strong, nonatomic) NSMutableArray <ClangCoverForkCell *>      *gatherHitMan;



@property (assign, nonatomic) NSInteger                                 count;



@property (nonatomic, assign) ValidityDiastolicOwnerReadySmall                          status;



@property (nonatomic, assign) NSInteger                                 channelCount;



@property (nonatomic, assign) CGFloat                                   backup;

@end

@implementation MinderCubeWide

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

- (void)jumpImproper
{
    
    if (self.gaspArray.firstObject) {
        
        
        ClangCoverForkCell *dryFoldView = self.gaspArray.firstObject;
        
        dryFoldView.frame = CGRectMake(StairIcyWidth, 0, dryFoldView.minimalSize.width, dryFoldView.minimalSize.height);
        
        self.backup = dryFoldView.backup;
        
        self.channelCount = dryFoldView.channelCount;
        
        
        NSInteger row = [self rainInsetShortcutsBusTooAcquireReference:dryFoldView];
        
        
        if (row >= 0) {
            
            
            [self.gaspArray removeObjectAtIndex:0];
            
            
            if (![self.subviews containsObject:dryFoldView]) {
                [self addSubview:dryFoldView];
            }
            dryFoldView.frame = CGRectMake(StairIcyWidth,  row * (dryFoldView.minimalSize.height + _backup), dryFoldView.minimalSize.width, dryFoldView.minimalSize.height);
            
            
            [_popNameArray setObject:dryFoldView atIndexedSubscript:row];
            
            
            if ([self.delegate respondsToSelector:@selector(pieceFitDrawView:willDisplayCell:)]) {
                [self.delegate pieceFitDrawView:self willDisplayCell:dryFoldView];
            }
            
            
            [self.gatherHitMan addObject:dryFoldView];
            
            [dryFoldView millibarsRetRealRecorderCoached:^{
                
                
                [dryFoldView setTransform:CGAffineTransformMakeTranslation(- dryFoldView.frame.size.width-StairIcyWidth, 0)];
                
            } completion:^(BOOL finished) {
                
                [dryFoldView removeFromSuperview];
                
                
                [self.gatherHitMan removeObject:dryFoldView];
                
                
                if ([self.delegate respondsToSelector:@selector(pieceFitDrawView:didEndDisplayingCell:)]) {
                    [self.delegate pieceFitDrawView:self didEndDisplayingCell:dryFoldView];
                }
                
                
                if (--self.count <= 0) {
                    if ([self.delegate respondsToSelector:@selector(dustChildrenSocialNegativeBarBookmarksIntrinsicRed:)]) {
                        [self.delegate dustChildrenSocialNegativeBarBookmarksIntrinsicRed:self];
                    }
                    self.count = 0;
                }
                
                

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


- (void)composerSquash:(NSArray <ClangCoverForkCell *> *)barrages
{
    self.count += barrages.count;
    [self.gaspArray addObjectsFromArray:barrages];
}

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

- (void)stop
{
    if (self.status == UnifySpatialUsesAlignmentMailSecond) {
        return;
    }
    self.status = UnifySpatialUsesAlignmentMailSecond;
    
    if (self.gatherHitMan.count) {
        [self.gatherHitMan makeObjectsPerformSelector:@selector(pause)];
    }
    
    if (self.gaspArray.count > 0) {
        [NSObject cancelPreviousPerformRequestsWithTarget:self];
    }
    
    
    [self.gatherHitMan  makeObjectsPerformSelector:@selector(removeFromSuperview)];
    self.channelCount       = 0;
    self.count              = 0;
    [self.gatherHitMan  removeAllObjects];
    [self.gaspArray     removeAllObjects];
    [self.popNameArray  removeAllObjects];
    
    self.gatherHitMan       = nil;
    self.gaspArray          = nil;
    self.popNameArray       = nil;
}


- (NSInteger)rainInsetShortcutsBusTooAcquireReference:(ClangCoverForkCell *)newBarrage
{
    for (int row = 0; row<_popNameArray.count; row++) {
        NSObject *object = _popNameArray[row];
        if ([object isKindOfClass:[NSNumber class]]) { 
            
            return row;
            
        }else if ([object isKindOfClass:[ClangCoverForkCell class]]) { 
            
            ClangCoverForkCell *albumMusic = (ClangCoverForkCell*)object;
            
            if ([self rainInsetShortcutsBusTooAcquireReference:albumMusic eitherBig:newBarrage]) {
                
                return row;
            }
        }
    }
    
    return -1;
}


- (BOOL)rainInsetShortcutsBusTooAcquireReference:(ClangCoverForkCell *)albumMusic eitherBig:(ClangCoverForkCell *)newBarrage
{
    
    if (albumMusic.status == GaussianUsagePressedSerifDidCroatian) {
        return NO;
    }
    
    
    CGRect rect = [albumMusic.layer.presentationLayer frame];
    if (rect.origin.x>StairIcyWidth - albumMusic.frame.size.width) {
        
        return NO;
    }else if (rect.size.width == 0)
    {
        
        return NO;
    }
    else if (albumMusic.frame.size.width > newBarrage.frame.size.width) {
        
        return YES;
    }else
    {
        
        CGFloat time = StairIcyWidth/(StairIcyWidth+newBarrage.frame.size.width)*newBarrage.carbonEncode;
        
        CGFloat clip = rect.origin.x - time/(albumMusic.carbonEncode)*(StairIcyWidth + albumMusic.frame.size.width);
        if (clip < -albumMusic.frame.size.width) {
            
            return YES;
        }
    }
    return NO;
}


- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
    UITouch *watch = [touches anyObject];
    CGPoint belowBlack  = [watch locationInView:self];
    for (UIView *quitOpt in [self subviews])
    {
        if (![quitOpt isKindOfClass:[ClangCoverForkCell class]]) continue;
        ClangCoverForkCell *dryFoldView = (ClangCoverForkCell *)quitOpt;
        if ([dryFoldView.layer.presentationLayer hitTest:belowBlack])
        {
            
            if ([self.delegate respondsToSelector:@selector(pieceFitDrawView:fullyCursorCell:)]) {
                [self.delegate pieceFitDrawView:self fullyCursorCell:dryFoldView];
            }
            break;
        }
    }
}




- (NSMutableArray<ClangCoverForkCell *> *)gaspArray {
    if (!_gaspArray) {
        _gaspArray = [[NSMutableArray alloc] init];
    }
    return _gaspArray;
}


- (NSMutableArray<ClangCoverForkCell *> *)gatherHitMan {
    if (!_gatherHitMan) {
        _gatherHitMan = [[NSMutableArray alloc] init];
    }
    return _gatherHitMan;
}


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


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

@end
