








#import "CostBasicPolar.h"

#define CanSlantHuman self.frame.size.width

@interface CostBasicPolar()



@property (nonatomic, strong) NSMutableArray                            *missingArray;



@property (nonatomic, strong) NSMutableArray <CheckOutOddBarCell *>      *turnArray;



@property (strong, nonatomic) NSMutableArray <CheckOutOddBarCell *>      *prettyHexNow;



@property (assign, nonatomic) NSInteger                                 count;



@property (nonatomic, assign) UnderlineStrokedSmoothedLongestDublin                          status;



@property (nonatomic, assign) NSInteger                                 channelCount;



@property (nonatomic, assign) CGFloat                                   theMax;

@end

@implementation CostBasicPolar

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

- (void)appendSimple
{
    
    if (self.turnArray.firstObject) {
        
        
        CheckOutOddBarCell *angularView = self.turnArray.firstObject;
        
        angularView.frame = CGRectMake(CanSlantHuman, 0, angularView.footPenSize.width, angularView.footPenSize.height);
        
        self.theMax = angularView.theMax;
        
        self.channelCount = angularView.channelCount;
        
        
        NSInteger row = [self malayDesiredCarbonGraphicsApplyingImagePresenter:angularView];
        
        
        if (row >= 0) {
            
            
            [self.turnArray removeObjectAtIndex:0];
            
            
            if (![self.subviews containsObject:angularView]) {
                [self addSubview:angularView];
            }
            angularView.frame = CGRectMake(CanSlantHuman,  row * (angularView.footPenSize.height + _theMax), angularView.footPenSize.width, angularView.footPenSize.height);
            
            
            [_missingArray setObject:angularView atIndexedSubscript:row];
            
            
            if ([self.delegate respondsToSelector:@selector(alertGramOldView:willDisplayCell:)]) {
                [self.delegate alertGramOldView:self willDisplayCell:angularView];
            }
            
            
            [self.prettyHexNow addObject:angularView];
            
            [angularView highestOffsetsSuccessLayerRedirects:^{
                
                
                [angularView setTransform:CGAffineTransformMakeTranslation(- angularView.frame.size.width-CanSlantHuman, 0)];
                
            } completion:^(BOOL finished) {
                
                [angularView removeFromSuperview];
                
                
                [self.prettyHexNow removeObject:angularView];
                
                
                if ([self.delegate respondsToSelector:@selector(alertGramOldView:didEndDisplayingCell:)]) {
                    [self.delegate alertGramOldView:self didEndDisplayingCell:angularView];
                }
                
                
                if (--self.count <= 0) {
                    if ([self.delegate respondsToSelector:@selector(midMillibarsSessionAwakePopWaterSoftballTake:)]) {
                        [self.delegate midMillibarsSessionAwakePopWaterSoftballTake:self];
                    }
                    self.count = 0;
                }
                
                

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


- (void)catWaxJobMight:(NSArray <CheckOutOddBarCell *> *)barrages
{
    self.count += barrages.count;
    [self.turnArray addObjectsFromArray:barrages];
}

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

- (void)stop
{
    if (self.status == CampaignRelationsExplicitExpiredWeeklyTexture) {
        return;
    }
    self.status = CampaignRelationsExplicitExpiredWeeklyTexture;
    
    if (self.prettyHexNow.count) {
        [self.prettyHexNow makeObjectsPerformSelector:@selector(pause)];
    }
    
    if (self.turnArray.count > 0) {
        [NSObject cancelPreviousPerformRequestsWithTarget:self];
    }
    
    
    [self.prettyHexNow  makeObjectsPerformSelector:@selector(removeFromSuperview)];
    self.channelCount       = 0;
    self.count              = 0;
    [self.prettyHexNow  removeAllObjects];
    [self.turnArray     removeAllObjects];
    [self.missingArray  removeAllObjects];
    
    self.prettyHexNow       = nil;
    self.turnArray          = nil;
    self.missingArray       = nil;
}


- (NSInteger)malayDesiredCarbonGraphicsApplyingImagePresenter:(CheckOutOddBarCell *)newBarrage
{
    for (int row = 0; row<_missingArray.count; row++) {
        NSObject *object = _missingArray[row];
        if ([object isKindOfClass:[NSNumber class]]) { 
            
            return row;
            
        }else if ([object isKindOfClass:[CheckOutOddBarCell class]]) { 
            
            CheckOutOddBarCell *lateEyeMay = (CheckOutOddBarCell*)object;
            
            if ([self malayDesiredCarbonGraphicsApplyingImagePresenter:lateEyeMay assistant:newBarrage]) {
                
                return row;
            }
        }
    }
    
    return -1;
}


- (BOOL)malayDesiredCarbonGraphicsApplyingImagePresenter:(CheckOutOddBarCell *)lateEyeMay assistant:(CheckOutOddBarCell *)newBarrage
{
    
    if (lateEyeMay.status == BikeSocketSameRealmWeekendPassively) {
        return NO;
    }
    
    
    CGRect rect = [lateEyeMay.layer.presentationLayer frame];
    if (rect.origin.x>CanSlantHuman - lateEyeMay.frame.size.width) {
        
        return NO;
    }else if (rect.size.width == 0)
    {
        
        return NO;
    }
    else if (lateEyeMay.frame.size.width > newBarrage.frame.size.width) {
        
        return YES;
    }else
    {
        
        CGFloat time = CanSlantHuman/(CanSlantHuman+newBarrage.frame.size.width)*newBarrage.callbacksRun;
        
        CGFloat pink = rect.origin.x - time/(lateEyeMay.callbacksRun)*(CanSlantHuman + lateEyeMay.frame.size.width);
        if (pink < -lateEyeMay.frame.size.width) {
            
            return YES;
        }
    }
    return NO;
}


- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
    UITouch *abort = [touches anyObject];
    CGPoint likeStrong  = [abort locationInView:self];
    for (CheckOutOddBarCell *angularView in [self subviews])
    {
        if ([angularView.layer.presentationLayer hitTest:likeStrong])
        {
            
            if ([self.delegate respondsToSelector:@selector(alertGramOldView:oddStairMaxCell:)]) {
                [self.delegate alertGramOldView:self oddStairMaxCell:angularView];
            }
            break;
        }
    }
}




- (NSMutableArray<CheckOutOddBarCell *> *)turnArray {
    if (!_turnArray) {
        _turnArray = [[NSMutableArray alloc] init];
    }
    return _turnArray;
}


- (NSMutableArray<CheckOutOddBarCell *> *)prettyHexNow {
    if (!_prettyHexNow) {
        _prettyHexNow = [[NSMutableArray alloc] init];
    }
    return _prettyHexNow;
}


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


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

@end
