






#import "YouCardOwnViewController.h"
#import "FadeWaxBinConfig.h"
#import "NSObject+TipModel.h"
#import "UIColor+WaxColor.h"
#import "SobToast.h"

@interface YouCardOwnViewController ()<UITableViewDataSource, UITableViewDelegate>

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

@end

@implementation YouCardOwnViewController


- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    _proxyStrictPintSchemesBin = [NSMutableArray array];
    _farFullySixEra = @[];
    _sectionTitles = [NSMutableArray array];
    
    [self usedArmourView];
}

- (void)viewWillAppear:(BOOL)animated {
    
    UIEdgeInsets twoMidJust = [[AssumeNotManager shared] headsetEarlyWindow].safeAreaInsets;
    
    twoMidJust.top    += 10;
    twoMidJust.left   += 10;
    twoMidJust.bottom += 10;
    twoMidJust.right  += 10;

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


- (void)usedArmourView {
    _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.stayPaperButton.mas_bottom);
        make.left.right.bottom.equalTo(self.view);
    }];
    
    
    [_tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:NSStringFromClass(self.class)];
}


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

- (void)barHeadsetIllInfo:(NSDictionary *)info withTitle:(NSString *)title {
    if (!info || ![info isKindOfClass:[NSDictionary class]]) {
        return;
    }
    
    
    dispatch_async(dispatch_get_main_queue(), ^{
        @synchronized (self) {
            
            [self->_proxyStrictPintSchemesBin addObject:[info copy]];
            NSArray *capsDryWas = [self knowNotLossOwnDictionary:info];
            self->_farFullySixEra = [self->_farFullySixEra arrayByAddingObject:capsDryWas];
            [self->_sectionTitles addObject:title];
            
            
            [self.tableView reloadData];
        }
    });
}


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

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

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

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *past = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass(self.class) forIndexPath:indexPath];
    
    NSString *key;
    id value;
    NSInteger captionIndex = indexPath.section;
    key = _farFullySixEra[captionIndex][indexPath.row];
    value = _proxyStrictPintSchemesBin[captionIndex][key];
    BOOL panRenew = [value isKindOfClass:[NSDictionary class]] || [value isKindOfClass:[NSArray class]];
    past.backgroundColor = [UIColor clearColor];
    
    
    for (UIView *dryLate in past.contentView.subviews) {
        [dryLate removeFromSuperview];
    }
    
    
    UILabel *wasLabel = [[UILabel alloc] init];
    wasLabel.font = [UIFont monospacedSystemFontOfSize:14 weight:UIFontWeightMedium];
    wasLabel.textColor = [UIColor darkGrayColor];
    wasLabel.text = key;
    wasLabel.numberOfLines = 0;
    [past.contentView addSubview:wasLabel];
    
    
    UILabel *limitLabel = [[UILabel alloc] init];
    limitLabel.font = [UIFont monospacedSystemFontOfSize:14 weight:UIFontWeightRegular];
    limitLabel.textColor = [UIColor blackColor];
    limitLabel.numberOfLines = 0;
    limitLabel.textAlignment = NSTextAlignmentRight;
    [past.contentView addSubview:limitLabel];
    
    
    [wasLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(past.contentView).offset(IndicesBest.trustMainArm.renameArmpit);
        make.top.equalTo(past.contentView).offset(IndicesBest.trustMainArm.sunKilohertz);
        make.bottom.equalTo(past.contentView).offset(-IndicesBest.trustMainArm.sunKilohertz);
        make.width.equalTo(past.contentView.mas_width).multipliedBy(panRenew?IndicesBest.trustMainArm.forKernelCut:IndicesBest.trustMainArm.mayFaxPrimary);
    }];
    
    [limitLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(past.contentView).offset(-IndicesBest.trustMainArm.renameArmpit);
        make.top.equalTo(past.contentView).offset(IndicesBest.trustMainArm.sunKilohertz);
        make.bottom.equalTo(past.contentView).offset(-IndicesBest.trustMainArm.sunKilohertz);
        make.left.equalTo(wasLabel.mas_right).offset(IndicesBest.trustMainArm.sunKilohertz);
    }];
    
    
    if (panRenew) {
        past.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    } else {
        limitLabel.text = [value description];
        past.accessoryType = UITableViewCellAccessoryNone;
    }
    
    return past;
}


- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    
    id value;
    NSString *key;
    
    NSInteger captionIndex = indexPath.section;
    key = _farFullySixEra[captionIndex][indexPath.row];
    value = _proxyStrictPintSchemesBin[captionIndex][key];
    
    
    if ([value isKindOfClass:[NSDictionary class]]) {
        [self quotesTintDictionary:value withTitle:key];
    } else if ([value isKindOfClass:[NSArray class]]) {
        [self seeFailYouArray:value withTitle:key];
    } else {
        
        UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
        [pasteboard setString:[value description]];
        [SobToast dragRed:IndicesBest.trustMainArm.boxValueRingArcadeProductEra];
    }
}


- (void)quotesTintDictionary:(NSDictionary *)four withTitle:(NSString *)title {
    YouCardOwnViewController *gaussian = [[YouCardOwnViewController alloc] init];
    [self.navigationController pushViewController:gaussian animated:NO];
    [gaussian barHeadsetIllInfo:four withTitle:title];
}

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

@end
