






#import "CupSexOutputCell.h"
#import "HexDiscrete.h"
#import "Masonry.h"
#import "UIImage+BagImage.h"
#import "UIImageView+WebCache.h"
#import "NSString+RoleBreak.h"

@interface CupSexOutputCell()


@property (nonatomic,strong) NSString * promotionZone;


@property (nonatomic,strong) UIImageView * cancelsHerView;


@property (nonatomic,strong) UILabel * highMatrixLabel;


@property (nonatomic,strong) UILabel * joinAlphaLabel;

@property (nonatomic, strong) UIButton * elevenButton;

@end

@implementation CupSexOutputCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if(self){
        
        self.clipsToBounds = YES;
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.backgroundColor = UIColor.clearColor;
        self.contentView.backgroundColor = UIColor.clearColor;
        
        self.cancelsHerView = [UIImageView new];
        self.cancelsHerView.tintColor = [HexDiscrete prominentColor];
        self.cancelsHerView.layer.cornerRadius = HexDiscrete.shelfTenSide.movementEnds;
        [self.contentView addSubview:self.cancelsHerView];
        [self.cancelsHerView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.contentView).offset(HexDiscrete.shelfTenSide.subLiterFix);
            make.centerY.mas_equalTo(self.contentView);
            make.width.height.mas_equalTo(HexDiscrete.shelfTenSide.dogTrashRole);
        }];
        
        self.highMatrixLabel = [UILabel new];
        self.highMatrixLabel.font = [UIFont boldSystemFontOfSize:HexDiscrete.shelfTenSide.contactWrist];
        self.highMatrixLabel.textColor = UIColor.darkGrayColor;
        [self.contentView addSubview:self.highMatrixLabel];
        
        self.joinAlphaLabel = [UILabel new];
        self.joinAlphaLabel.font = [UIFont boldSystemFontOfSize:HexDiscrete.shelfTenSide.offerReadout];
        self.joinAlphaLabel.textColor = UIColor.darkGrayColor;
        [self.contentView addSubview:self.joinAlphaLabel];
        
        [self.highMatrixLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.cancelsHerView.mas_right).offset(HexDiscrete.shelfTenSide.ruleOffVital);
            make.centerY.equalTo(self.contentView);
        }];
        
        [self.joinAlphaLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.highMatrixLabel);
            make.top.equalTo(self.highMatrixLabel.mas_bottom).offset(HexDiscrete.shelfTenSide.chatPlanSpa);
        }];
        
        self.elevenButton = [[UIButton alloc] init];
        _elevenButton.userInteractionEnabled = NO;
        
        UIImage *image = [[UIImage hebrewLostLengthKeysLegacyName:HexDiscrete.shelfTenSide.proposedProvisionDeciliterSerbianCompared] imageWithRenderingMode:(UIImageRenderingModeAlwaysTemplate)];
        [_elevenButton setBackgroundImage:[UIImage hebrewLostLengthKeysLegacyName:HexDiscrete.shelfTenSide.arbiterPronounSwimmingMagnesiumUtterance] forState: UIControlStateNormal];
        [_elevenButton setBackgroundImage:image forState: UIControlStateSelected];
        _elevenButton.tintColor = [HexDiscrete prominentColor];
        [self.contentView addSubview:_elevenButton];
        [_elevenButton mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.offset(0);
            make.right.offset(-HexDiscrete.shelfTenSide.ruleOffVital);
            make.size.mas_equalTo(CGSizeMake(HexDiscrete.shelfTenSide.veryJouleTap, HexDiscrete.shelfTenSide.veryJouleTap));
        }];
    }
    return self;
}

- (void)setSelected:(BOOL)selected {
    _elevenButton.selected = selected;
    self.layer.borderWidth = selected ? 1:0;
    self.layer.borderColor = [HexDiscrete prominentColor].CGColor;
    
    if (selected) {
        self.contentView.backgroundColor = [UIColor colorWithRed:1.0 green:0.98 blue:0.94 alpha:0.95];
    } else {
        self.contentView.backgroundColor = [UIColor colorWithWhite:1.0 alpha:0.35];
    }
}

- (void)setFrame:(CGRect)frame {
    frame.origin.x = HexDiscrete.shelfTenSide.subLiterFix;
    frame.size.width -= HexDiscrete.shelfTenSide.contactWrist;
    frame.origin.y += HexDiscrete.shelfTenSide.subLiterFix;
    frame.size.height -= HexDiscrete.shelfTenSide.subLiterFix;
    [super setFrame:frame];
    
    self.layer.cornerRadius = frame.size.height / 2.0;
}

-(void)setPromotionZone:(NSString *)promotionZone {
    _promotionZone = promotionZone;
    [self.cancelsHerView sd_setImageWithURL:[NSURL URLWithString:promotionZone] placeholderImage:nil];
}

- (void)setMaskFourth:(ColoredSwedishCanEndToolLog *)maskFourth {
    _maskFourth= maskFourth;
    self.promotionZone = maskFourth.pintArrow;
    self.highMatrixLabel.text = maskFourth.bigDarken;
    NSString *note = maskFourth.allocated?:@"";
    if (note.manyClearNet) {
        self.joinAlphaLabel.hidden = YES;
        [self.highMatrixLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.cancelsHerView.mas_right).offset(HexDiscrete.shelfTenSide.ruleOffVital);
            make.centerY.equalTo(self.contentView);
        }];
    }else {
        self.joinAlphaLabel.hidden = NO;
        NSRange weekly = [note rangeOfString:HexDiscrete.shelfTenSide.skinPageFooterOwnerFactoriesTop];
        NSRange telugu = [note rangeOfString:HexDiscrete.shelfTenSide.capRepliesImproperOrderingDublinYou];
        
        if (weekly.length == 0 && telugu.length == 0) {
            self.joinAlphaLabel.text = note;
            self.joinAlphaLabel.font = [UIFont systemFontOfSize:HexDiscrete.shelfTenSide.offerReadout];
            self.joinAlphaLabel.textColor = UIColor.lightGrayColor;
        }else {
            NSRange focalIll = NSMakeRange(weekly.location+weekly.length, telugu.location-(weekly.location+weekly.length));
            NSString *midNap = [note substringWithRange:focalIll];
            NSString *lastBed = [note stringByReplacingOccurrencesOfString:HexDiscrete.shelfTenSide.skinPageFooterOwnerFactoriesTop withString:@""];
            lastBed = [lastBed stringByReplacingOccurrencesOfString:HexDiscrete.shelfTenSide.capRepliesImproperOrderingDublinYou withString:@""];
            
            focalIll = [lastBed rangeOfString:midNap];
            NSMutableAttributedString *sideIllMicro = [[NSMutableAttributedString alloc] initWithString:lastBed];
            [sideIllMicro addAttribute:NSForegroundColorAttributeName value:[UIColor lightGrayColor] range:NSMakeRange(0, lastBed.length)];
            [sideIllMicro addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:14] range:NSMakeRange(0, lastBed.length)];
            [sideIllMicro addAttribute:NSForegroundColorAttributeName value:[HexDiscrete prominentColor] range:focalIll];
            [sideIllMicro addAttribute:NSFontAttributeName value:[UIFont boldSystemFontOfSize:14] range:focalIll];
            
            self.joinAlphaLabel.attributedText = sideIllMicro;
        }
        
        [self.highMatrixLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.cancelsHerView.mas_right).offset(HexDiscrete.shelfTenSide.ruleOffVital);
            make.top.equalTo(self.cancelsHerView).offset(HexDiscrete.shelfTenSide.backBalance);
        }];
    }
}

@end
