






#import "ZipPlanYetViewController.h"
#import "CertPenSheConfig.h"
#import "NSObject+CanModel.h"
#import "UIColor+RowColor.h"
#import "HerToast.h"

@interface ZipPlanYetViewController ()<UITableViewDataSource, UITableViewDelegate>

@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) NSMutableArray<NSDictionary *> *systemHighTeaspoonsSwimmingCellular; 
@property (nonatomic, strong) NSArray<NSArray<NSString *> *> *cellWakeTipHis; 
@property (nonatomic, strong) NSMutableArray<NSString *> *sectionTitles; 

@end

@implementation ZipPlanYetViewController


- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    _systemHighTeaspoonsSwimmingCellular = [NSMutableArray array];
    _cellWakeTipHis = @[];
    _sectionTitles = [NSMutableArray array];
    
    [self hailAllAddView];
}

- (void)viewWillAppear:(BOOL)animated {
    
    UIEdgeInsets eyeTakeIll = [[ExportKitManager shared] outButtonFarWindow].safeAreaInsets;
    
    eyeTakeIll.top    += 10;
    eyeTakeIll.left   += 10;
    eyeTakeIll.bottom += 10;
    eyeTakeIll.right  += 10;

    [self.view mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.mas_equalTo(eyeTakeIll);
    }];
}


- (void)hailAllAddView {
    _tableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStyleGrouped];
    _tableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
    _tableView.dataSource = self;
    _tableView.delegate = self;
    _tableView.backgroundColor = [UIColor clearColor];
    [self.view addSubview:_tableView];
    [_tableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.pastFlashButton.mas_bottom);
        make.left.right.bottom.equalTo(self.view);
    }];
    
    
    [_tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:NSStringFromClass(self.class)];
}


- (NSArray<NSString *> *)manCallAutoPenDictionary:(NSDictionary *)deep {
    return [[deep allKeys] sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)];
}

- (void)bitWetBoxMakeInfo:(NSDictionary *)info withTitle:(NSString *)title {
    if (!info || ![info isKindOfClass:[NSDictionary class]]) {
        return;
    }
    
    
    dispatch_async(dispatch_get_main_queue(), ^{
        @synchronized (self) {
            
            [self->_systemHighTeaspoonsSwimmingCellular addObject:[info copy]];
            NSArray *ropeNotAnd = [self manCallAutoPenDictionary:info];
            self->_cellWakeTipHis = [self->_cellWakeTipHis arrayByAddingObject:ropeNotAnd];
            [self->_sectionTitles addObject:title];
            
            
            [self.tableView reloadData];
        }
    });
}


- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return _systemHighTeaspoonsSwimmingCellular.count;
}

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

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
    return _sectionTitles[section];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *mill = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass(self.class) forIndexPath:indexPath];
    
    NSString *key;
    id value;
    NSInteger pingKeyIndex = indexPath.section;
    key = _cellWakeTipHis[pingKeyIndex][indexPath.row];
    value = _systemHighTeaspoonsSwimmingCellular[pingKeyIndex][key];
    BOOL sunCocoa = [value isKindOfClass:[NSDictionary class]] || [value isKindOfClass:[NSArray class]];
    mill.backgroundColor = [UIColor clearColor];
    
    
    for (UIView *sexFill in mill.contentView.subviews) {
        [sexFill removeFromSuperview];
    }
    
    
    UILabel *tryLabel = [[UILabel alloc] init];
    tryLabel.font = [UIFont monospacedSystemFontOfSize:14 weight:UIFontWeightMedium];
    tryLabel.textColor = [UIColor darkGrayColor];
    tryLabel.text = key;
    tryLabel.numberOfLines = 0;
    [mill.contentView addSubview:tryLabel];
    
    
    UILabel *resetLabel = [[UILabel alloc] init];
    resetLabel.font = [UIFont monospacedSystemFontOfSize:14 weight:UIFontWeightRegular];
    resetLabel.textColor = [UIColor blackColor];
    resetLabel.numberOfLines = 0;
    resetLabel.textAlignment = NSTextAlignmentRight;
    [mill.contentView addSubview:resetLabel];
    
    
    [tryLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(mill.contentView).offset(MenTintSave.ironRouteMix.scoreWaitRow);
        make.top.equalTo(mill.contentView).offset(MenTintSave.ironRouteMix.hitConstruct);
        make.bottom.equalTo(mill.contentView).offset(-MenTintSave.ironRouteMix.hitConstruct);
        make.width.equalTo(mill.contentView.mas_width).multipliedBy(sunCocoa?MenTintSave.ironRouteMix.whiteOverall:MenTintSave.ironRouteMix.plateFixPitch);
    }];
    
    [resetLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(mill.contentView).offset(-MenTintSave.ironRouteMix.scoreWaitRow);
        make.top.equalTo(mill.contentView).offset(MenTintSave.ironRouteMix.hitConstruct);
        make.bottom.equalTo(mill.contentView).offset(-MenTintSave.ironRouteMix.hitConstruct);
        make.left.equalTo(tryLabel.mas_right).offset(MenTintSave.ironRouteMix.hitConstruct);
    }];
    
    
    if (sunCocoa) {
        mill.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    } else {
        resetLabel.text = [value description];
        mill.accessoryType = UITableViewCellAccessoryNone;
    }
    
    return mill;
}


- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    
    id value;
    NSString *key;
    
    NSInteger pingKeyIndex = indexPath.section;
    key = _cellWakeTipHis[pingKeyIndex][indexPath.row];
    value = _systemHighTeaspoonsSwimmingCellular[pingKeyIndex][key];
    
    
    if ([value isKindOfClass:[NSDictionary class]]) {
        [self kinLessCatDictionary:value withTitle:key];
    } else if ([value isKindOfClass:[NSArray class]]) {
        [self sonUseAreaArray:value withTitle:key];
    } else {
        
        UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
        [pasteboard setString:[value description]];
        [HerToast fatSlab:MenTintSave.ironRouteMix.reversedSoftwareJumpPreservedHangBar];
    }
}


- (void)kinLessCatDictionary:(NSDictionary *)deep withTitle:(NSString *)title {
    ZipPlanYetViewController *farsiYou = [[ZipPlanYetViewController alloc] init];
    [self.navigationController pushViewController:farsiYou animated:NO];
    [farsiYou bitWetBoxMakeInfo:deep withTitle:title];
}

- (void)sonUseAreaArray:(NSArray *)array withTitle:(NSString *)title {
    
    NSMutableDictionary *childDict = [NSMutableDictionary dictionary];
    for (NSInteger i = 0; i < array.count; i++) {
        childDict[[NSString stringWithFormat:@"[%ld]", (long)i]] = array[i];
    }
    
    ZipPlanYetViewController *farsiYou = [[ZipPlanYetViewController alloc] init];
    [self.navigationController pushViewController:farsiYou animated:NO];
    [farsiYou bitWetBoxMakeInfo:childDict withTitle:[NSString stringWithFormat:@"%@ (Array)", title]];
}

@end
