






#import "AfterOldMixLabel.h"
#import "PriorEarSee.h"
#import "UIImage+BusImage.h"

@implementation AfterOldMixLabel

+ (AfterOldMixLabel *)toolBarOldAskLabel {
    return [self toolBarOldAskLabel:YES];
}

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

    NSAttributedString *opaqueForPrematureBarsEffort = nil;
    if (isCheckBox) {
        
        NSTextAttachment *attachment = [[NSTextAttachment alloc] init];
        UIImage *templateImage = [[UIImage canSendMismatchSpousesNextName:PriorEarSee.netListPhoto.filmWeekFoundSuddenLoudUpdate] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
        attachment.image = templateImage; 
        
        attachment.bounds = CGRectMake(0, -5, 20, 20);
        opaqueForPrematureBarsEffort = [NSAttributedString attributedStringWithAttachment:attachment];
    }

    
    NSString *text = PriorEarSee.drawCreditLeft.herSentCaret;
    NSMutableAttributedString *usesRedLineLow = [[NSMutableAttributedString alloc] initWithString:text];
    
    
    NSRange musicRealCurve = [text rangeOfString:PriorEarSee.drawCreditLeft.profilePresses];
    if (musicRealCurve.location != NSNotFound) {
        [usesRedLineLow addAttribute:NSForegroundColorAttributeName value:[PriorEarSee seeKazakhColor] range:musicRealCurve];
        [usesRedLineLow addAttribute:NSUnderlineStyleAttributeName value:@(NSUnderlineStyleSingle) range:musicRealCurve];
    }

    
    NSMutableAttributedString *senderPermuteHardFlagImportant = [[NSMutableAttributedString alloc] init];
    if (opaqueForPrematureBarsEffort) {
        [senderPermuteHardFlagImportant appendAttributedString:opaqueForPrematureBarsEffort];
    }
    [senderPermuteHardFlagImportant appendAttributedString:usesRedLineLow];
    
    label.attributedText = senderPermuteHardFlagImportant;
    
    
    UITapGestureRecognizer *descentOur = [[UITapGestureRecognizer alloc] initWithTarget:label action:@selector(hourlyCancelsPubTertiaryWon:)];
    [label addGestureRecognizer:descentOur];
    
    return label;
}

- (void)setViewNapTapFont:(BOOL)viewNapTapFont {
    _viewNapTapFont = !viewNapTapFont;
    [self boldLearnCheckerMenFingerVeryLabel:self];
}

- (void)hourlyCancelsPubTertiaryWon:(UITapGestureRecognizer *)descentOur {
    AfterOldMixLabel *label = (AfterOldMixLabel *)descentOur.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 tagContacts = [descentOur locationInView:label];
    CGRect usedRect = [layoutManager usedRectForTextContainer:textContainer];
    CGPoint hoursDeletingRestoringKurdishFor = CGPointMake(
        (label.bounds.size.width - usedRect.size.width) / 2,   
        (label.bounds.size.height - usedRect.size.height) / 2  
    );
    
    
    CGPoint obscuresScrolledHeadTabBurmeseArrival = CGPointMake(
        tagContacts.x - hoursDeletingRestoringKurdishFor.x,
        tagContacts.y - hoursDeletingRestoringKurdishFor.y
    );
    
    
    __block BOOL affineLocator = 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 kitUnsaved;
            [layoutManager glyphRangeForCharacterRange:range actualCharacterRange:&kitUnsaved];
            
            
            CGRect ejectRect = [layoutManager boundingRectForGlyphRange:kitUnsaved
                                                      inTextContainer:textContainer];
            
            
            CGRect playingEasyRect = CGRectOffset(ejectRect, hoursDeletingRestoringKurdishFor.x, hoursDeletingRestoringKurdishFor.y);
            
            
            if (CGRectContainsPoint(playingEasyRect, tagContacts)) {
                affineLocator = YES;
                *stop = YES;
            }
        }
    }];
    
    if (affineLocator) {
        
        
        [self boldLearnCheckerMenFingerVeryLabel:label];
        return;
    }
    
    
    NSUInteger characterIndex = [layoutManager characterIndexForPoint:obscuresScrolledHeadTabBurmeseArrival
                                                    inTextContainer:textContainer
                           fractionOfDistanceBetweenInsertionPoints:NULL];
    
    NSString *editText = label.attributedText.string;
    NSRange musicRealCurve = [editText rangeOfString:PriorEarSee.drawCreditLeft.profilePresses];
    
    if (characterIndex != NSNotFound && NSLocationInRange(characterIndex, musicRealCurve)) {
        
        
        if (self.clientsGigabytesSilentMinderCollectedBroken) {
            self.clientsGigabytesSilentMinderCollectedBroken();
        }
    }
}


- (void)boldLearnCheckerMenFingerVeryLabel:(AfterOldMixLabel *)label {
    NSMutableAttributedString *attributedText = [label.attributedText mutableCopy];
    __block BOOL getBitsMan = 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 boxEncode = !_viewNapTapFont;
        
        
        NSTextAttachment *seekHasKitMin = [[NSTextAttachment alloc] init];
        
        
        UIColor *fourthColor = boxEncode ? [PriorEarSee seeKazakhColor]: UIColor.lightGrayColor;
        UIImage *pathSortImage = [UIImage canSendMismatchSpousesNextName:boxEncode ? PriorEarSee.netListPhoto.audienceRetainedDecimalFunkRowProvides :PriorEarSee.netListPhoto.filmWeekFoundSuddenLoudUpdate];
        
        
        seekHasKitMin.image = [[pathSortImage imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]
                                imageWithTintColor:fourthColor];
        seekHasKitMin.bounds = oldAttachment.bounds;
        
        
        [attributedText removeAttribute:NSAttachmentAttributeName range:range];
        [attributedText addAttribute:NSAttachmentAttributeName value:seekHasKitMin range:range];
        
        _viewNapTapFont = boxEncode;
        getBitsMan = YES;
        *stop = YES;
    }];
    
    if (getBitsMan) {
        dispatch_async(dispatch_get_main_queue(), ^{
            [UIView transitionWithView:label
                              duration:0.3
                               options:UIViewAnimationOptionTransitionCrossDissolve
                            animations:^{
                                label.attributedText = attributedText;
                            } completion:nil];
            [label setNeedsDisplay];
        });
    }
}

@end
