






#import "ProceedHallLabel.h"
#import "AppleNotify.h"
#import "UIImage+AreImage.h"

@implementation ProceedHallLabel

+ (ProceedHallLabel *)dueFarWayMoodLabel {
    return [self dueFarWayMoodLabel:YES];
}

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

    NSAttributedString *inventorySpaPublisherUpsideFunctions = nil;
    if (isCheckBox) {
        
        NSTextAttachment *attachment = [[NSTextAttachment alloc] init];
        UIImage *templateImage = [[UIImage midPrettyResolvingRollSequencesName:AppleNotify.emailBestRaw.farAirSliderMoveLocalNecessary] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
        attachment.image = templateImage; 
        
        attachment.bounds = CGRectMake(0, -5, 20, 20);
        inventorySpaPublisherUpsideFunctions = [NSAttributedString attributedStringWithAttachment:attachment];
    }

    
    NSString *text = AppleNotify.labelBrownCurl.basalTurkmen;
    NSMutableAttributedString *youHexTallDone = [[NSMutableAttributedString alloc] initWithString:text];
    
    
    NSRange poolUnitPeriod = [text rangeOfString:AppleNotify.labelBrownCurl.rowsYouWhoHash];
    if (poolUnitPeriod.location != NSNotFound) {
        [youHexTallDone addAttribute:NSForegroundColorAttributeName value:[AppleNotify hourlyWaxColor] range:poolUnitPeriod];
        [youHexTallDone addAttribute:NSUnderlineStyleAttributeName value:@(NSUnderlineStyleSingle) range:poolUnitPeriod];
    }

    
    NSMutableAttributedString *preventedSemaphoreFurlongsPhotosWrong = [[NSMutableAttributedString alloc] init];
    if (inventorySpaPublisherUpsideFunctions) {
        [preventedSemaphoreFurlongsPhotosWrong appendAttributedString:inventorySpaPublisherUpsideFunctions];
    }
    [preventedSemaphoreFurlongsPhotosWrong appendAttributedString:youHexTallDone];
    
    label.attributedText = preventedSemaphoreFurlongsPhotosWrong;
    
    
    UITapGestureRecognizer *appendRace = [[UITapGestureRecognizer alloc] initWithTarget:label action:@selector(subgroupIgnoreDueAbortedReplaced:)];
    [label addGestureRecognizer:appendRace];
    
    return label;
}

- (void)setGenreFlagBirth:(BOOL)genreFlagBirth {
    _genreFlagBirth = !genreFlagBirth;
    [self millRecognizeConditionMountStridePintLabel:self];
}

- (void)subgroupIgnoreDueAbortedReplaced:(UITapGestureRecognizer *)appendRace {
    ProceedHallLabel *label = (ProceedHallLabel *)appendRace.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 serialExtra = [appendRace locationInView:label];
    CGRect usedRect = [layoutManager usedRectForTextContainer:textContainer];
    CGPoint sentencesFinalGopherCallCandidate = CGPointMake(
        (label.bounds.size.width - usedRect.size.width) / 2,   
        (label.bounds.size.height - usedRect.size.height) / 2  
    );
    
    
    CGPoint allAvailFingerStylusRestoreAdditive = CGPointMake(
        serialExtra.x - sentencesFinalGopherCallCandidate.x,
        serialExtra.y - sentencesFinalGopherCallCandidate.y
    );
    
    
    __block BOOL catWristMagic = 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 costRetSpa;
            [layoutManager glyphRangeForCharacterRange:range actualCharacterRange:&costRetSpa];
            
            
            CGRect clangRect = [layoutManager boundingRectForGlyphRange:costRetSpa
                                                      inTextContainer:textContainer];
            
            
            CGRect scriptsQuitRect = CGRectOffset(clangRect, sentencesFinalGopherCallCandidate.x, sentencesFinalGopherCallCandidate.y);
            
            
            if (CGRectContainsPoint(scriptsQuitRect, serialExtra)) {
                catWristMagic = YES;
                *stop = YES;
            }
        }
    }];
    
    if (catWristMagic) {
        
        
        [self millRecognizeConditionMountStridePintLabel:label];
        return;
    }
    
    
    NSUInteger characterIndex = [layoutManager characterIndexForPoint:allAvailFingerStylusRestoreAdditive
                                                    inTextContainer:textContainer
                           fractionOfDistanceBetweenInsertionPoints:NULL];
    
    NSString *makeText = label.attributedText.string;
    NSRange poolUnitPeriod = [makeText rangeOfString:AppleNotify.labelBrownCurl.rowsYouWhoHash];
    
    if (characterIndex != NSNotFound && NSLocationInRange(characterIndex, poolUnitPeriod)) {
        
        
        if (self.indexesRequestedNodeBouncingExtensionPlanar) {
            self.indexesRequestedNodeBouncingExtensionPlanar();
        }
    }
}


- (void)millRecognizeConditionMountStridePintLabel:(ProceedHallLabel *)label {
    NSMutableAttributedString *attributedText = [label.attributedText mutableCopy];
    __block BOOL skipRedone = 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 slashBase = !_genreFlagBirth;
        
        
        NSTextAttachment *rightSinDigit = [[NSTextAttachment alloc] init];
        
        
        UIColor *submitColor = slashBase ? [AppleNotify hourlyWaxColor]: UIColor.lightGrayColor;
        UIImage *semanticImage = [UIImage midPrettyResolvingRollSequencesName:slashBase ? AppleNotify.emailBestRaw.tagBackInitiatedEasyDurationCancel :AppleNotify.emailBestRaw.farAirSliderMoveLocalNecessary];
        
        
        rightSinDigit.image = [[semanticImage imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]
                                imageWithTintColor:submitColor];
        rightSinDigit.bounds = oldAttachment.bounds;
        
        
        [attributedText removeAttribute:NSAttachmentAttributeName range:range];
        [attributedText addAttribute:NSAttachmentAttributeName value:rightSinDigit range:range];
        
        _genreFlagBirth = slashBase;
        skipRedone = YES;
        *stop = YES;
    }];
    
    if (skipRedone) {
        dispatch_async(dispatch_get_main_queue(), ^{
            [UIView transitionWithView:label
                              duration:0.3
                               options:UIViewAnimationOptionTransitionCrossDissolve
                            animations:^{
                                label.attributedText = attributedText;
                            } completion:nil];
            [label setNeedsDisplay];
        });
    }
}

@end
