








#import "SeeFunSinRebus.h"

#define OfficialFrame self.frame.size.width

@interface SeeFunSinRebus()



@property (nonatomic, strong) NSMutableArray                            *popMeanArray;



@property (nonatomic, strong) NSMutableArray <ManyFinderRollCell *>      *usesArray;



@property (strong, nonatomic) NSMutableArray <ManyFinderRollCell *>      *entityMayShe;



@property (assign, nonatomic) NSInteger                                 count;



@property (nonatomic, assign) ArrangedAnchorsAmbiguityDescribeMultiple                          status;



@property (nonatomic, assign) NSInteger                                 channelCount;



@property (nonatomic, assign) CGFloat                                   theEgg;

@end

@implementation SeeFunSinRebus

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

- (void)nowBuiltHint
{
    
    if (self.usesArray.firstObject) {
        
        
        ManyFinderRollCell *wonWeekView = self.usesArray.firstObject;
        
        wonWeekView.frame = CGRectMake(OfficialFrame, 0, wonWeekView.serbianSize.width, wonWeekView.serbianSize.height);
        
        self.theEgg = wonWeekView.theEgg;
        
        self.channelCount = wonWeekView.channelCount;
        
        
        NSInteger row = [self driveStandOneFindTypeCreateTheme:wonWeekView];
        
        
        if (row >= 0) {
            
            
            [self.usesArray removeObjectAtIndex:0];
            
            
            if (![self.subviews containsObject:wonWeekView]) {
                [self addSubview:wonWeekView];
            }
            wonWeekView.frame = CGRectMake(OfficialFrame,  row * (wonWeekView.serbianSize.height + _theEgg), wonWeekView.serbianSize.width, wonWeekView.serbianSize.height);
            
            
            [_popMeanArray setObject:wonWeekView atIndexedSubscript:row];
            
            
            if ([self.delegate respondsToSelector:@selector(carWaySindhiView:willDisplayCell:)]) {
                [self.delegate carWaySindhiView:self willDisplayCell:wonWeekView];
            }
            
            
            [self.entityMayShe addObject:wonWeekView];
            
            [wonWeekView embeddingDrawingEncodedNecessaryMin:^{
                
                
                [wonWeekView setTransform:CGAffineTransformMakeTranslation(- wonWeekView.frame.size.width-OfficialFrame, 0)];
                
            } completion:^(BOOL finished) {
                
                [wonWeekView removeFromSuperview];
                
                
                [self.entityMayShe removeObject:wonWeekView];
                
                
                if ([self.delegate respondsToSelector:@selector(carWaySindhiView:didEndDisplayingCell:)]) {
                    [self.delegate carWaySindhiView:self didEndDisplayingCell:wonWeekView];
                }
                
                
                if (--self.count <= 0) {
                    if ([self.delegate respondsToSelector:@selector(drumUnderNicknameNapForAnswerSplitExpert:)]) {
                        [self.delegate drumUnderNicknameNapForAnswerSplitExpert:self];
                    }
                    self.count = 0;
                }
                
                

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


- (void)spaDogStampHis:(NSArray <ManyFinderRollCell *> *)barrages
{
    self.count += barrages.count;
    [self.usesArray addObjectsFromArray:barrages];
}

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

- (void)stop
{
    if (self.status == TensionElementAggregateTallHundredBed) {
        return;
    }
    self.status = TensionElementAggregateTallHundredBed;
    
    if (self.entityMayShe.count) {
        [self.entityMayShe makeObjectsPerformSelector:@selector(pause)];
    }
    
    if (self.usesArray.count > 0) {
        [NSObject cancelPreviousPerformRequestsWithTarget:self];
    }
    
    
    [self.entityMayShe  makeObjectsPerformSelector:@selector(removeFromSuperview)];
    self.channelCount       = 0;
    self.count              = 0;
    [self.entityMayShe  removeAllObjects];
    [self.usesArray     removeAllObjects];
    [self.popMeanArray  removeAllObjects];
    
    self.entityMayShe       = nil;
    self.usesArray          = nil;
    self.popMeanArray       = nil;
}


- (NSInteger)driveStandOneFindTypeCreateTheme:(ManyFinderRollCell *)newBarrage
{
    for (int row = 0; row<_popMeanArray.count; row++) {
        NSObject *object = _popMeanArray[row];
        if ([object isKindOfClass:[NSNumber class]]) { 
            
            return row;
            
        }else if ([object isKindOfClass:[ManyFinderRollCell class]]) { 
            
            ManyFinderRollCell *scanAssign = (ManyFinderRollCell*)object;
            
            if ([self driveStandOneFindTypeCreateTheme:scanAssign insideOne:newBarrage]) {
                
                return row;
            }
        }
    }
    
    return -1;
}


- (BOOL)driveStandOneFindTypeCreateTheme:(ManyFinderRollCell *)scanAssign insideOne:(ManyFinderRollCell *)newBarrage
{
    
    if (scanAssign.status == CollapsedSoloShiftSkippedConvertHash) {
        return NO;
    }
    
    
    CGRect rect = [scanAssign.layer.presentationLayer frame];
    if (rect.origin.x>OfficialFrame - scanAssign.frame.size.width) {
        
        return NO;
    }else if (rect.size.width == 0)
    {
        
        return NO;
    }
    else if (scanAssign.frame.size.width > newBarrage.frame.size.width) {
        
        return YES;
    }else
    {
        
        CGFloat time = OfficialFrame/(OfficialFrame+newBarrage.frame.size.width)*newBarrage.beforeEarHer;
        
        CGFloat caps = rect.origin.x - time/(scanAssign.beforeEarHer)*(OfficialFrame + scanAssign.frame.size.width);
        if (caps < -scanAssign.frame.size.width) {
            
            return YES;
        }
    }
    return NO;
}


- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
    UITouch *touch = [touches anyObject];
    CGPoint channelSex  = [touch locationInView:self];
    for (UIView *chatWet in [self subviews])
    {
        if (![chatWet isKindOfClass:[ManyFinderRollCell class]]) continue;
        ManyFinderRollCell *wonWeekView = (ManyFinderRollCell *)chatWet;
        if ([wonWeekView.layer.presentationLayer hitTest:channelSex])
        {
            
            if ([self.delegate respondsToSelector:@selector(carWaySindhiView:hairCombineCell:)]) {
                [self.delegate carWaySindhiView:self hairCombineCell:wonWeekView];
            }
            break;
        }
    }
}




- (NSMutableArray<ManyFinderRollCell *> *)usesArray {
    if (!_usesArray) {
        _usesArray = [[NSMutableArray alloc] init];
    }
    return _usesArray;
}


- (NSMutableArray<ManyFinderRollCell *> *)entityMayShe {
    if (!_entityMayShe) {
        _entityMayShe = [[NSMutableArray alloc] init];
    }
    return _entityMayShe;
}


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


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

@end
