






#import "KernelsSawUnitIllLearnedViewController.h"
#import "UnlimitedViewController.h"
#import "EarMaxJouleUnloadVisitorCell.h"

@interface KernelsSawUnitIllLearnedViewController ()<UITableViewDelegate,UITableViewDataSource>

@property (nonatomic, strong) UIView *prefersSessionThreadsInterlaceExistentView;

@property (nonatomic, strong) UIView *sunEraserView;

@property (nonatomic, strong) UITableView *foodDivideView;


@property (nonatomic, assign) BOOL maintainCameraGaspOffForm;

@property (nonatomic, weak) id mastersVolumes;

@property (nonatomic, strong) NSMutableArray *eulerStampAirArray;

@property (nonatomic, strong) NSMutableArray *undoIconArray;

@property (nonatomic, strong) UIButton *unifyBelowButton;
@property (nonatomic, strong) UIButton *sheNodeQuitButton;

@end

@implementation KernelsSawUnitIllLearnedViewController

- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    if (_undoIconArray.count > 0 && self.maintainCameraGaspOffForm) {
        self.maintainCameraGaspOffForm = NO;
    }
}

- (void)viewWillAppear:(BOOL)animated {
    
    [self.view mas_makeConstraints:^(MASConstraintMaker *make) {
        CGFloat bottom = PinMovement.cupFormatSun.squashCanIts;
        make.centerX.equalTo(self.view.superview);
        make.centerY.equalTo(self.view.superview).offset(+bottom/2);
        make.height.mas_equalTo([PinMovement iconIgnoreResultingTrademarkNecessaryIndentSize].height+bottom);
        make.width.mas_equalTo([PinMovement iconIgnoreResultingTrademarkNecessaryIndentSize].width);
    }];
}

- (void)setMaintainCameraGaspOffForm:(BOOL)maintainCameraGaspOffForm {
    
    _maintainCameraGaspOffForm = maintainCameraGaspOffForm;
    
    _undoIconArray = maintainCameraGaspOffForm ? _eulerStampAirArray : [NSMutableArray arrayWithObject:_mastersVolumes];
    
    [self.foodDivideView mas_updateConstraints:^(MASConstraintMaker *make) {
        make.height.mas_equalTo(!maintainCameraGaspOffForm ? PinMovement.cupFormatSun.ejectTradBar : self.undoIconArray.count > 3 ? 3 * PinMovement.cupFormatSun.ejectTradBar  : self.undoIconArray.count * PinMovement.cupFormatSun.ejectTradBar);
    }];
    
    self.foodDivideView.scrollEnabled = maintainCameraGaspOffForm;
    
    [self.foodDivideView reloadData];
    
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.002 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        [self.foodDivideView setContentOffset:CGPointMake(0, 0) animated:NO];
    });
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = UIColor.clearColor;
    
    _eulerStampAirArray = [[PinMovement mapTornadoRecoveredGeometryDerive] mutableCopy];
    
    _mastersVolumes = _eulerStampAirArray.firstObject;
    
    [self anchorDisablingAirBlinkLeaky];
    
    self.maintainCameraGaspOffForm = NO;
}

- (void)anchorDisablingAirBlinkLeaky {
    
    _prefersSessionThreadsInterlaceExistentView = [[UIView alloc] init];
    _prefersSessionThreadsInterlaceExistentView.backgroundColor = UIColor.whiteColor;
    _prefersSessionThreadsInterlaceExistentView.layer.cornerRadius = 2;
    [self.view addSubview:_prefersSessionThreadsInterlaceExistentView];
    [self.view sendSubviewToBack:_prefersSessionThreadsInterlaceExistentView];
    [_prefersSessionThreadsInterlaceExistentView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.view);
        make.centerX.equalTo(self.view);
        make.size.mas_equalTo([PinMovement iconIgnoreResultingTrademarkNecessaryIndentSize]);
    }];
    
    
    UIView *sunEraserView = [PinMovement sunEraserView];
    [self.view addSubview:sunEraserView];
    self.sunEraserView = sunEraserView;
    [sunEraserView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.view).offset(PinMovement.cupFormatSun.leaseZoneOld);
        make.height.mas_equalTo(PinMovement.cupFormatSun.dustSlideAdd);
        make.left.equalTo(self.greatRainButton.mas_right);
        make.right.equalTo(self.bagDesktopButton.mas_left);
    }];
    
    
    _foodDivideView = [[UITableView alloc] initWithFrame:CGRectZero style:(UITableViewStylePlain)];
    _foodDivideView.backgroundColor = [UIColor whiteColor];
    _foodDivideView.layer.masksToBounds = YES;
    _foodDivideView.separatorInset = UIEdgeInsetsMake(0, 0, 0, 0);
    _foodDivideView.separatorColor = [UIColor systemGroupedBackgroundColor];
    _foodDivideView.layer.borderColor = [PinMovement unorderedColor].CGColor;
    _foodDivideView.layer.borderWidth = 0.6;
    _foodDivideView.layer.cornerRadius = 2;
    _foodDivideView.rowHeight = PinMovement.cupFormatSun.ejectTradBar;
    _foodDivideView.delegate = self;
    _foodDivideView.dataSource = self;
    [_foodDivideView registerClass:[EarMaxJouleUnloadVisitorCell class] forCellReuseIdentifier:NSStringFromClass(EarMaxJouleUnloadVisitorCell.class)];
    [self.view addSubview:_foodDivideView];
    [self.foodDivideView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.sunEraserView.mas_bottom).offset(PinMovement.cupFormatSun.leaseZoneOld);
        make.left.equalTo(self.prefersSessionThreadsInterlaceExistentView).offset(PinMovement.cupFormatSun.mandatoryTen);
        make.right.equalTo(self.prefersSessionThreadsInterlaceExistentView).offset(-PinMovement.cupFormatSun.mandatoryTen);
        make.height.mas_equalTo(PinMovement.cupFormatSun.ejectTradBar);
    }];
    
    
    self.unifyBelowButton = [PinMovement seekDiskDiastolicHoursStereo:PinMovement.otherPhasePlug.failEchoCrossSuperiorsCat];
    [self.unifyBelowButton addTarget:self action:@selector(stormWaterInfinityPitchSinKilowattAction:) forControlEvents:(UIControlEventTouchUpInside)];
    [self.prefersSessionThreadsInterlaceExistentView addSubview:self.unifyBelowButton];
    [self.unifyBelowButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.prefersSessionThreadsInterlaceExistentView).offset(-PinMovement.cupFormatSun.leaseZoneOld);
        make.centerX.equalTo(self.view);
    }];
    
    
    self.sheNodeQuitButton = [PinMovement narrativeForbidAlignedAcuteGrayColor:PinMovement.otherPhasePlug.addNeverWho];
    [self.sheNodeQuitButton addTarget:self action:@selector(priceProblemSimpleExtendsValidatesBroadcast:) forControlEvents:UIControlEventTouchUpInside];
    [self.prefersSessionThreadsInterlaceExistentView addSubview:self.sheNodeQuitButton];
    [self.sheNodeQuitButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.unifyBelowButton.mas_top).offset(-PinMovement.cupFormatSun.consumedBank);
        make.left.right.equalTo(self.foodDivideView);
        make.height.mas_equalTo(PinMovement.cupFormatSun.bigSongPhoto);
    }];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return _undoIconArray.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    EarMaxJouleUnloadVisitorCell *loop = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass(EarMaxJouleUnloadVisitorCell.class) forIndexPath:indexPath];
    NSArray *runStore = _undoIconArray[indexPath.row];
    
    loop.provinceName.text = runStore[0];
    
    loop.bigMaxSockView.image = [[UIImage characterMasterArmpitMinGatheringName:runStore[1]] imageWithRenderingMode:(UIImageRenderingModeAlwaysTemplate)];
    
    loop.duplexClampTime.text = [NSString stringWithFormat:@"%@ %@",PinMovement.otherPhasePlug.floorGermanArmpitMostGermanTime,[self winOrnamentBlockerEscapingRatioSwapTime:[runStore[2] doubleValue]]];
    
    loop.accessoryType = self.maintainCameraGaspOffForm ? UITableViewCellAccessoryNone :  UITableViewCellAccessoryDisclosureIndicator;
    
    return loop;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    _mastersVolumes = _undoIconArray[indexPath.row];
    self.maintainCameraGaspOffForm = !self.maintainCameraGaspOffForm;
}


- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
    return self.maintainCameraGaspOffForm;
}

- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {
    return UITableViewCellEditingStyleDelete;
}

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
    
    if (editingStyle == UITableViewCellEditingStyleDelete) {
        
        id runStore = _undoIconArray[indexPath.row];
        
        [_undoIconArray removeObject:runStore];
        
        [_eulerStampAirArray removeObject:runStore];
        
        if ([self.flagTrapMixer respondsToSelector:@selector(burnOptSkipTrustedMeanSubscribeName:completion:)]) {
            [self.flagTrapMixer burnOptSkipTrustedMeanSubscribeName:runStore[0] completion:^(id object) {
                
            }];
        }
        
        if(_eulerStampAirArray.count > 0){
            
            _undoIconArray = _eulerStampAirArray;
            _mastersVolumes = _undoIconArray.firstObject;
            self.maintainCameraGaspOffForm = YES;
            
        }
    }
}


- (NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath {
    return @"Delete";
}

- (void)twelveStrongestModifyAutoMargins:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
    [super twelveStrongestModifyAutoMargins:touches withEvent:event];
    self.maintainCameraGaspOffForm = NO;
}

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
    [super touchesBegan:touches withEvent:event];
    self.maintainCameraGaspOffForm = NO;
}


- (void)stormWaterInfinityPitchSinKilowattAction:(UIButton *)sender {
    UnlimitedViewController *ubiquityTrack = [UnlimitedViewController new];
    ubiquityTrack.flagTrapMixer = self.flagTrapMixer;
    [self.navigationController pushViewController:ubiquityTrack animated:NO];
}

- (void)priceProblemSimpleExtendsValidatesBroadcast:(UIButton *)sender {
    if ([self.flagTrapMixer respondsToSelector:@selector(recordedCategoryEquallyReportTrailingRemoteOwnershipName:completion:)]) {
        [ClickInnerView waxBlackTwistWindow];
        [self.flagTrapMixer recordedCategoryEquallyReportTrailingRemoteOwnershipName:self.mastersVolumes[0] completion:^(id object) {
            [ClickInnerView wakeOrnamentRespectsConsumedRemovalWindow];
        }];
    }
}


- (NSString *)winOrnamentBlockerEscapingRatioSwapTime:(double)beTime {
    
    NSTimeInterval now = [[NSDate date] timeIntervalSince1970];
    double binLocalTime = now - beTime;
    NSString * stoneCenter;
    
    NSDate * oneDate = [NSDate dateWithTimeIntervalSince1970:beTime];
    NSDateFormatter * sub = [[NSDateFormatter alloc] init];
    [sub setDateFormat:@"HH:mm"];
    NSString * herCell = [sub stringFromDate:oneDate];
    
    [sub setDateFormat:@"dd"];
    NSString * fixTwo = [sub stringFromDate:[NSDate date]];
    NSString * menFlip = [sub stringFromDate:oneDate];
    
    if (binLocalTime < 60) {
        stoneCenter = PinMovement.otherPhasePlug.askHaveUpper;
    }else if (binLocalTime < 60 * 60) {
        stoneCenter = [NSString stringWithFormat:@"%ld%@",(long)binLocalTime / 60, PinMovement.otherPhasePlug.qualifiedLiterExportingFlushedCat];
    }else if(binLocalTime < 24 * 60 * 60 && [fixTwo integerValue] == [menFlip integerValue]){
        stoneCenter = [NSString stringWithFormat:@"%@ %@",PinMovement.otherPhasePlug.denyFlight,herCell];
    }else if(binLocalTime < 24 * 60 * 60 * 2 && [fixTwo integerValue] != [menFlip integerValue]){
        if ([fixTwo integerValue] - [menFlip integerValue] == 1 || ([menFlip integerValue] - [fixTwo integerValue] > 10 && [fixTwo integerValue] == 1)) {
            stoneCenter = [NSString stringWithFormat:@"%@ %@",PinMovement.otherPhasePlug.mustMaxIdleDry,herCell];
        }else{
            [sub setDateFormat:@"MM-dd HH:mm"];
            stoneCenter = [sub stringFromDate:oneDate];
        }
    }else if(binLocalTime < 24 * 60 * 60 * 365){
        [sub setDateFormat:@"MM-dd HH:mm"];
        stoneCenter = [sub stringFromDate:oneDate];
    }else{
        [sub setDateFormat:@"yyyy-MM-dd HH:mm"];
        stoneCenter = [sub stringFromDate:oneDate];
    }
    return stoneCenter;
}

@end
