








#import "LockRebusCover.h"

#define ExecPortCause self.frame.size.width

@interface LockRebusCover()



@property (nonatomic, strong) NSMutableArray                            *lossButArray;



@property (nonatomic, strong) NSMutableArray <CutNapGolfFoldCell *>      *soloArray;



@property (strong, nonatomic) NSMutableArray <CutNapGolfFoldCell *>      *outOutMarkup;



@property (assign, nonatomic) NSInteger                                 count;



@property (nonatomic, assign) RemainderSuffixMutableTransportMobile                          status;



@property (nonatomic, assign) NSInteger                                 channelCount;



@property (nonatomic, assign) CGFloat                                   simple;

@end

@implementation LockRebusCover

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

- (void)bigEvaluated
{
    
    if (self.soloArray.firstObject) {
        
        
        CutNapGolfFoldCell *playingView = self.soloArray.firstObject;
        
        playingView.frame = CGRectMake(ExecPortCause, 0, playingView.subBendSize.width, playingView.subBendSize.height);
        
        self.simple = playingView.simple;
        
        self.channelCount = playingView.channelCount;
        
        
        NSInteger row = [self givenVisibleArchiveBuiltFlatnessEnclosingLocally:playingView];
        
        
        if (row >= 0) {
            
            
            [self.soloArray removeObjectAtIndex:0];
            
            
            if (![self.subviews containsObject:playingView]) {
                [self addSubview:playingView];
            }
            playingView.frame = CGRectMake(ExecPortCause,  row * (playingView.subBendSize.height + _simple), playingView.subBendSize.width, playingView.subBendSize.height);
            
            
            [_lossButArray setObject:playingView atIndexedSubscript:row];
            
            
            if ([self.delegate respondsToSelector:@selector(secretFatZipView:willDisplayCell:)]) {
                [self.delegate secretFatZipView:self willDisplayCell:playingView];
            }
            
            
            [self.outOutMarkup addObject:playingView];
            
            [playingView peerVitalityHandWeekendFat:^{
                
                
                [playingView setTransform:CGAffineTransformMakeTranslation(- playingView.frame.size.width-ExecPortCause, 0)];
                
            } completion:^(BOOL finished) {
                
                [playingView removeFromSuperview];
                
                
                [self.outOutMarkup removeObject:playingView];
                
                
                if ([self.delegate respondsToSelector:@selector(secretFatZipView:didEndDisplayingCell:)]) {
                    [self.delegate secretFatZipView:self didEndDisplayingCell:playingView];
                }
                
                
                if (--self.count <= 0) {
                    if ([self.delegate respondsToSelector:@selector(verifyUnlimitedGeometricVisualLocalizesOldUnsafeImplicit:)]) {
                        [self.delegate verifyUnlimitedGeometricVisualLocalizesOldUnsafeImplicit:self];
                    }
                    self.count = 0;
                }
                
                

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


- (void)boldStakeEntry:(NSArray <CutNapGolfFoldCell *> *)barrages
{
    self.count += barrages.count;
    [self.soloArray addObjectsFromArray:barrages];
}

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

- (void)stop
{
    if (self.status == HeaderRequiringReferentLazyComponentFlip) {
        return;
    }
    self.status = HeaderRequiringReferentLazyComponentFlip;
    
    if (self.outOutMarkup.count) {
        [self.outOutMarkup makeObjectsPerformSelector:@selector(pause)];
    }
    
    if (self.soloArray.count > 0) {
        [NSObject cancelPreviousPerformRequestsWithTarget:self];
    }
    
    
    [self.outOutMarkup  makeObjectsPerformSelector:@selector(removeFromSuperview)];
    self.channelCount       = 0;
    self.count              = 0;
    [self.outOutMarkup  removeAllObjects];
    [self.soloArray     removeAllObjects];
    [self.lossButArray  removeAllObjects];
    
    self.outOutMarkup       = nil;
    self.soloArray          = nil;
    self.lossButArray       = nil;
}


- (NSInteger)givenVisibleArchiveBuiltFlatnessEnclosingLocally:(CutNapGolfFoldCell *)newBarrage
{
    for (int row = 0; row<_lossButArray.count; row++) {
        NSObject *object = _lossButArray[row];
        if ([object isKindOfClass:[NSNumber class]]) { 
            
            return row;
            
        }else if ([object isKindOfClass:[CutNapGolfFoldCell class]]) { 
            
            CutNapGolfFoldCell *passJobLaw = (CutNapGolfFoldCell*)object;
            
            if ([self givenVisibleArchiveBuiltFlatnessEnclosingLocally:passJobLaw sinTorque:newBarrage]) {
                
                return row;
            }
        }
    }
    
    return -1;
}


- (BOOL)givenVisibleArchiveBuiltFlatnessEnclosingLocally:(CutNapGolfFoldCell *)passJobLaw sinTorque:(CutNapGolfFoldCell *)newBarrage
{
    
    if (passJobLaw.status == BedAgentApplyBiotinPlainOrnaments) {
        return NO;
    }
    
    
    CGRect rect = [passJobLaw.layer.presentationLayer frame];
    if (rect.origin.x>ExecPortCause - passJobLaw.frame.size.width) {
        
        return NO;
    }else if (rect.size.width == 0)
    {
        
        return NO;
    }
    else if (passJobLaw.frame.size.width > newBarrage.frame.size.width) {
        
        return YES;
    }else
    {
        
        CGFloat time = ExecPortCause/(ExecPortCause+newBarrage.frame.size.width)*newBarrage.badmintonHex;
        
        CGFloat cell = rect.origin.x - time/(passJobLaw.badmintonHex)*(ExecPortCause + passJobLaw.frame.size.width);
        if (cell < -passJobLaw.frame.size.width) {
            
            return YES;
        }
    }
    return NO;
}


- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
    UITouch *touch = [touches anyObject];
    CGPoint fetchDrain  = [touch locationInView:self];
    for (UIView *bundles in [self subviews])
    {
        if (![bundles isKindOfClass:[CutNapGolfFoldCell class]]) continue;
        CutNapGolfFoldCell *playingView = (CutNapGolfFoldCell *)bundles;
        if ([playingView.layer.presentationLayer hitTest:fetchDrain])
        {
            
            if ([self.delegate respondsToSelector:@selector(secretFatZipView:onlyPopHoldCell:)]) {
                [self.delegate secretFatZipView:self onlyPopHoldCell:playingView];
            }
            break;
        }
    }
}




- (NSMutableArray<CutNapGolfFoldCell *> *)soloArray {
    if (!_soloArray) {
        _soloArray = [[NSMutableArray alloc] init];
    }
    return _soloArray;
}


- (NSMutableArray<CutNapGolfFoldCell *> *)outOutMarkup {
    if (!_outOutMarkup) {
        _outOutMarkup = [[NSMutableArray alloc] init];
    }
    return _outOutMarkup;
}


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


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

@end
