






#import "SocialScopeLabel.h"
#import "LeftHosting.h"
#import "UIImage+SonImage.h"

@implementation SocialScopeLabel

+ (SocialScopeLabel *)countProducedLabel {
    return [self countProducedLabel:YES];
}

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

    NSAttributedString *drawBondSixExpiresComposite = nil;
    if (isCheckBox) {
        
        NSTextAttachment *attachment = [[NSTextAttachment alloc] init];
        UIImage *templateImage = [[UIImage tenWirelessMinProtocolsRedefinedName:LeftHosting.busJobRemote.converterUnsavedWideSuccessSinhaleseSender] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
        attachment.image = templateImage; 
        
        attachment.bounds = CGRectMake(0, -5, 20, 20);
        drawBondSixExpiresComposite = [NSAttributedString attributedStringWithAttachment:attachment];
    }

    
    NSString *text = LeftHosting.carMapKeepPick.markSiblings;
    NSMutableAttributedString *timeEggHostIts = [[NSMutableAttributedString alloc] initWithString:text];
    
    
    NSRange lostShotPutEgg = [text rangeOfString:LeftHosting.carMapKeepPick.fitTailFairCar];
    if (lostShotPutEgg.location != NSNotFound) {
        [timeEggHostIts addAttribute:NSForegroundColorAttributeName value:[LeftHosting rankCycleColor] range:lostShotPutEgg];
        [timeEggHostIts addAttribute:NSUnderlineStyleAttributeName value:@(NSUnderlineStyleSingle) range:lostShotPutEgg];
    }

    
    NSMutableAttributedString *hasDraftSeparateMarginsEffective = [[NSMutableAttributedString alloc] init];
    if (drawBondSixExpiresComposite) {
        [hasDraftSeparateMarginsEffective appendAttributedString:drawBondSixExpiresComposite];
    }
    [hasDraftSeparateMarginsEffective appendAttributedString:timeEggHostIts];
    
    label.attributedText = hasDraftSeparateMarginsEffective;
    
    
    UITapGestureRecognizer *stopEndMax = [[UITapGestureRecognizer alloc] initWithTarget:label action:@selector(wayOuterInsertFemaleOut:)];
    [label addGestureRecognizer:stopEndMax];
    
    return label;
}

- (void)setDividerSlashes:(BOOL)dividerSlashes {
    _dividerSlashes = !dividerSlashes;
    [self discardedCloudyGrantedFarStereoTrustLabel:self];
}

- (void)wayOuterInsertFemaleOut:(UITapGestureRecognizer *)stopEndMax {
    SocialScopeLabel *label = (SocialScopeLabel *)stopEndMax.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 cardioidTap = [stopEndMax locationInView:label];
    CGRect usedRect = [layoutManager usedRectForTextContainer:textContainer];
    CGPoint focusStrokeBatteryFrameIntrinsic = CGPointMake(
        (label.bounds.size.width - usedRect.size.width) / 2,   
        (label.bounds.size.height - usedRect.size.height) / 2  
    );
    
    
    CGPoint menHusbandTradUniqueStrideGradient = CGPointMake(
        cardioidTap.x - focusStrokeBatteryFrameIntrinsic.x,
        cardioidTap.y - focusStrokeBatteryFrameIntrinsic.y
    );
    
    
    __block BOOL swapErrorCall = 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 fiveOutput;
            [layoutManager glyphRangeForCharacterRange:range actualCharacterRange:&fiveOutput];
            
            
            CGRect ejectRect = [layoutManager boundingRectForGlyphRange:fiveOutput
                                                      inTextContainer:textContainer];
            
            
            CGRect whoCroppingRect = CGRectOffset(ejectRect, focusStrokeBatteryFrameIntrinsic.x, focusStrokeBatteryFrameIntrinsic.y);
            
            
            if (CGRectContainsPoint(whoCroppingRect, cardioidTap)) {
                swapErrorCall = YES;
                *stop = YES;
            }
        }
    }];
    
    if (swapErrorCall) {
        
        
        [self discardedCloudyGrantedFarStereoTrustLabel:label];
        return;
    }
    
    
    NSUInteger characterIndex = [layoutManager characterIndexForPoint:menHusbandTradUniqueStrideGradient
                                                    inTextContainer:textContainer
                           fractionOfDistanceBetweenInsertionPoints:NULL];
    
    NSString *packText = label.attributedText.string;
    NSRange lostShotPutEgg = [packText rangeOfString:LeftHosting.carMapKeepPick.fitTailFairCar];
    
    if (characterIndex != NSNotFound && NSLocationInRange(characterIndex, lostShotPutEgg)) {
        
        
        if (self.cookieGainZeroAskMetricsAxes) {
            self.cookieGainZeroAskMetricsAxes();
        }
    }
}


- (void)discardedCloudyGrantedFarStereoTrustLabel:(SocialScopeLabel *)label {
    NSMutableAttributedString *attributedText = [label.attributedText mutableCopy];
    __block BOOL pascalShow = 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 zeroHindi = !_dividerSlashes;
        
        
        NSTextAttachment *butPipeHueMay = [[NSTextAttachment alloc] init];
        
        
        UIColor *whoCanColor = zeroHindi ? [LeftHosting rankCycleColor]: UIColor.lightGrayColor;
        UIImage *parentalImage = [UIImage tenWirelessMinProtocolsRedefinedName:zeroHindi ? LeftHosting.busJobRemote.sideFourProfilesFastParsecsUnlearn :LeftHosting.busJobRemote.converterUnsavedWideSuccessSinhaleseSender];
        
        
        butPipeHueMay.image = [[parentalImage imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]
                                imageWithTintColor:whoCanColor];
        butPipeHueMay.bounds = oldAttachment.bounds;
        
        
        [attributedText removeAttribute:NSAttachmentAttributeName range:range];
        [attributedText addAttribute:NSAttachmentAttributeName value:butPipeHueMay range:range];
        
        _dividerSlashes = zeroHindi;
        pascalShow = YES;
        *stop = YES;
    }];
    
    if (pascalShow) {
        dispatch_async(dispatch_get_main_queue(), ^{
            [UIView transitionWithView:label
                              duration:0.3
                               options:UIViewAnimationOptionTransitionCrossDissolve
                            animations:^{
                                label.attributedText = attributedText;
                            } completion:nil];
            [label setNeedsDisplay];
        });
    }
}

@end
