






#import "CapsGoalGetLabel.h"
#import "PintResting.h"
#import "UIImage+PubImage.h"

@implementation CapsGoalGetLabel

+ (CapsGoalGetLabel *)resourceBrandLabel {
    return [self resourceBrandLabel:YES];
}

+ (CapsGoalGetLabel *)resourceBrandLabel:(BOOL)isCheckBox {
    
    CapsGoalGetLabel *label = [[CapsGoalGetLabel alloc] init];
    label.numberOfLines = 0;
    label.textAlignment = NSTextAlignmentCenter;
    label.textColor = [UIColor lightGrayColor];
    label.font = [UIFont systemFontOfSize:12];
    label.userInteractionEnabled = YES; 

    NSAttributedString *assertPlugPressRedirectHover = nil;
    if (isCheckBox) {
        
        NSTextAttachment *attachment = [[NSTextAttachment alloc] init];
        UIImage *templateImage = [[UIImage attributeModifyKilowattsRoomChromaName:PintResting.findClickCat.menuCanFlattenColumnsAdvancesSequences] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
        attachment.image = templateImage; 
        
        attachment.bounds = CGRectMake(0, -5, 20, 20);
        assertPlugPressRedirectHover = [NSAttributedString attributedStringWithAttachment:attachment];
    }

    
    NSString *text = PintResting.exposeLeapAuto.stackBigLoop;
    NSMutableAttributedString *burnZipRopeBin = [[NSMutableAttributedString alloc] initWithString:text];
    
    
    NSRange onceBinOldLeft = [text rangeOfString:PintResting.exposeLeapAuto.eventualBottom];
    if (onceBinOldLeft.location != NSNotFound) {
        [burnZipRopeBin addAttribute:NSForegroundColorAttributeName value:[PintResting armHelperColor] range:onceBinOldLeft];
        [burnZipRopeBin addAttribute:NSUnderlineStyleAttributeName value:@(NSUnderlineStyleSingle) range:onceBinOldLeft];
    }

    
    NSMutableAttributedString *audienceRunRecursiveStackedProcess = [[NSMutableAttributedString alloc] init];
    if (assertPlugPressRedirectHover) {
        [audienceRunRecursiveStackedProcess appendAttributedString:assertPlugPressRedirectHover];
    }
    [audienceRunRecursiveStackedProcess appendAttributedString:burnZipRopeBin];
    
    label.attributedText = audienceRunRecursiveStackedProcess;
    
    
    UITapGestureRecognizer *composeBut = [[UITapGestureRecognizer alloc] initWithTarget:label action:@selector(makeConvergedTwoRedLocalized:)];
    [label addGestureRecognizer:composeBut];
    
    return label;
}

- (void)setPortMaskIgnore:(BOOL)portMaskIgnore {
    _portMaskIgnore = !portMaskIgnore;
    [self leakyWirelessCalciumHueOvulationSensitiveLabel:self];
}

- (void)makeConvergedTwoRedLocalized:(UITapGestureRecognizer *)composeBut {
    CapsGoalGetLabel *label = (CapsGoalGetLabel *)composeBut.view;
    if (!label.attributedText) return;
    
    
    NSTextStorage *textStorage = [[NSTextStorage alloc] initWithAttributedString:label.attributedText];
    NSLayoutManager *layoutManager = [[NSLayoutManager alloc] init];
    NSTextContainer *textContainer = [[NSTextContainer alloc] initWithSize:label.bounds.size];
    
    textContainer.lineFragmentPadding = 0;
    textContainer.maximumNumberOfLines = label.numberOfLines;
    textContainer.lineBreakMode = label.lineBreakMode;
    
    [textStorage addLayoutManager:layoutManager];
    [layoutManager addTextContainer:textContainer];
    
    
    [layoutManager ensureLayoutForTextContainer:textContainer];
    
    
    CGPoint thatDogPing = [composeBut locationInView:label];
    CGRect usedRect = [layoutManager usedRectForTextContainer:textContainer];
    CGPoint renewalBusyControlTurkmenSelect = CGPointMake(
        (label.bounds.size.width - usedRect.size.width) / 2,   
        (label.bounds.size.height - usedRect.size.height) / 2  
    );
    
    
    CGPoint listMonthSerializePossibleExtraLocations = CGPointMake(
        thatDogPing.x - renewalBusyControlTurkmenSelect.x,
        thatDogPing.y - renewalBusyControlTurkmenSelect.y
    );
    
    
    __block BOOL whoSunVisible = NO;
    [label.attributedText enumerateAttribute:NSAttachmentAttributeName
                                    inRange:NSMakeRange(0, label.attributedText.length)
                                    options:0
                                 usingBlock:^(id value, NSRange range, BOOL *stop) {
        if ([value isKindOfClass:[NSTextAttachment class]]) {
            
            NSRange nearResize;
            [layoutManager glyphRangeForCharacterRange:range actualCharacterRange:&nearResize];
            
            
            CGRect stackRect = [layoutManager boundingRectForGlyphRange:nearResize
                                                      inTextContainer:textContainer];
            
            
            CGRect mouseTabDryRect = CGRectOffset(stackRect, renewalBusyControlTurkmenSelect.x, renewalBusyControlTurkmenSelect.y);
            
            
            if (CGRectContainsPoint(mouseTabDryRect, thatDogPing)) {
                whoSunVisible = YES;
                *stop = YES;
            }
        }
    }];
    
    if (whoSunVisible) {
        
        
        [self leakyWirelessCalciumHueOvulationSensitiveLabel:label];
        return;
    }
    
    
    NSUInteger characterIndex = [layoutManager characterIndexForPoint:listMonthSerializePossibleExtraLocations
                                                    inTextContainer:textContainer
                           fractionOfDistanceBetweenInsertionPoints:NULL];
    
    NSString *zoomText = label.attributedText.string;
    NSRange onceBinOldLeft = [zoomText rangeOfString:PintResting.exposeLeapAuto.eventualBottom];
    
    if (characterIndex != NSNotFound && NSLocationInRange(characterIndex, onceBinOldLeft)) {
        
        
        if (self.bevelOptimizeCutGuaraniSinSpa) {
            self.bevelOptimizeCutGuaraniSinSpa();
        }
    }
}


- (void)leakyWirelessCalciumHueOvulationSensitiveLabel:(CapsGoalGetLabel *)label {
    NSMutableAttributedString *attributedText = [label.attributedText mutableCopy];
    __block BOOL hisHandled = NO;
    
    [attributedText enumerateAttribute:NSAttachmentAttributeName
                             inRange:NSMakeRange(0, attributedText.length)
                             options:0
                          usingBlock:^(NSTextAttachment *oldAttachment, NSRange range, BOOL *stop) {
        if (![oldAttachment isKindOfClass:[NSTextAttachment class]]) return;
        
        
        BOOL uighurTen = !_portMaskIgnore;
        
        
        NSTextAttachment *resignPopover = [[NSTextAttachment alloc] init];
        
        
        UIColor *netTwoColor = uighurTen ? [PintResting armHelperColor]: UIColor.lightGrayColor;
        UIImage *markCubeImage = [UIImage attributeModifyKilowattsRoomChromaName:uighurTen ? PintResting.findClickCat.creditWonMetabolicHigherMomentaryFixing :PintResting.findClickCat.menuCanFlattenColumnsAdvancesSequences];
        
        
        resignPopover.image = [[markCubeImage imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]
                                imageWithTintColor:netTwoColor];
        resignPopover.bounds = oldAttachment.bounds;
        
        
        [attributedText removeAttribute:NSAttachmentAttributeName range:range];
        [attributedText addAttribute:NSAttachmentAttributeName value:resignPopover range:range];
        
        _portMaskIgnore = uighurTen;
        hisHandled = YES;
        *stop = YES;
    }];
    
    if (hisHandled) {
        dispatch_async(dispatch_get_main_queue(), ^{
            [UIView transitionWithView:label
                              duration:0.3
                               options:UIViewAnimationOptionTransitionCrossDissolve
                            animations:^{
                                label.attributedText = attributedText;
                            } completion:nil];
            [label setNeedsDisplay];
        });
    }
}

@end
