






#import "BirthMidAddLabel.h"
#import "HexDiscrete.h"
#import "UIImage+BagImage.h"

@implementation BirthMidAddLabel

+ (BirthMidAddLabel *)fitTextFarManLabel {
    return [self fitTextFarManLabel:YES];
}

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

    NSAttributedString *sunListenersHelpSeekingAddress = nil;
    if (isCheckBox) {
        
        NSTextAttachment *attachment = [[NSTextAttachment alloc] init];
        UIImage *templateImage = [[UIImage hebrewLostLengthKeysLegacyName:HexDiscrete.shelfTenSide.yesterdaySlopeExtensionHigherLiveLeftover] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
        attachment.image = templateImage; 
        
        attachment.bounds = CGRectMake(0, -5, 20, 20);
        sunListenersHelpSeekingAddress = [NSAttributedString attributedStringWithAttachment:attachment];
    }

    
    NSString *text = HexDiscrete.twistSheWasWin.dueSobDirect;
    NSMutableAttributedString *selfFireWeekly = [[NSMutableAttributedString alloc] initWithString:text];
    
    
    NSRange ironWaxRedAxes = [text rangeOfString:HexDiscrete.twistSheWasWin.bitRateSafeSum];
    if (ironWaxRedAxes.location != NSNotFound) {
        [selfFireWeekly addAttribute:NSForegroundColorAttributeName value:[HexDiscrete prominentColor] range:ironWaxRedAxes];
        [selfFireWeekly addAttribute:NSUnderlineStyleAttributeName value:@(NSUnderlineStyleSingle) range:ironWaxRedAxes];
    }

    
    NSMutableAttributedString *bounceScrollRawAutoGerman = [[NSMutableAttributedString alloc] init];
    if (sunListenersHelpSeekingAddress) {
        [bounceScrollRawAutoGerman appendAttributedString:sunListenersHelpSeekingAddress];
    }
    [bounceScrollRawAutoGerman appendAttributedString:selfFireWeekly];
    
    label.attributedText = bounceScrollRawAutoGerman;
    
    
    UITapGestureRecognizer *panWaxPair = [[UITapGestureRecognizer alloc] initWithTarget:label action:@selector(scalarDolbyMastersSymbolKind:)];
    [label addGestureRecognizer:panWaxPair];
    
    return label;
}

- (void)setSnapStairGiven:(BOOL)snapStairGiven {
    _snapStairGiven = !snapStairGiven;
    [self arcadeSystemInferCellSymbolsScannerLabel:self];
}

- (void)scalarDolbyMastersSymbolKind:(UITapGestureRecognizer *)panWaxPair {
    BirthMidAddLabel *label = (BirthMidAddLabel *)panWaxPair.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 rareEntries = [panWaxPair locationInView:label];
    CGRect usedRect = [layoutManager usedRectForTextContainer:textContainer];
    CGPoint cleanupGermanRemainderSenseContent = CGPointMake(
        (label.bounds.size.width - usedRect.size.width) / 2,   
        (label.bounds.size.height - usedRect.size.height) / 2  
    );
    
    
    CGPoint parallelYetFlexibleTryBezelSin = CGPointMake(
        rareEntries.x - cleanupGermanRemainderSenseContent.x,
        rareEntries.y - cleanupGermanRemainderSenseContent.y
    );
    
    
    __block BOOL brandNotPrint = 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 yellowFour;
            [layoutManager glyphRangeForCharacterRange:range actualCharacterRange:&yellowFour];
            
            
            CGRect blinkRect = [layoutManager boundingRectForGlyphRange:yellowFour
                                                      inTextContainer:textContainer];
            
            
            CGRect clearOrangeRect = CGRectOffset(blinkRect, cleanupGermanRemainderSenseContent.x, cleanupGermanRemainderSenseContent.y);
            
            
            if (CGRectContainsPoint(clearOrangeRect, rareEntries)) {
                brandNotPrint = YES;
                *stop = YES;
            }
        }
    }];
    
    if (brandNotPrint) {
        
        
        [self arcadeSystemInferCellSymbolsScannerLabel:label];
        return;
    }
    
    
    NSUInteger characterIndex = [layoutManager characterIndexForPoint:parallelYetFlexibleTryBezelSin
                                                    inTextContainer:textContainer
                           fractionOfDistanceBetweenInsertionPoints:NULL];
    
    NSString *zoneText = label.attributedText.string;
    NSRange ironWaxRedAxes = [zoneText rangeOfString:HexDiscrete.twistSheWasWin.bitRateSafeSum];
    
    if (characterIndex != NSNotFound && NSLocationInRange(characterIndex, ironWaxRedAxes)) {
        
        
        if (self.youMinorRowMenuProgressJust) {
            self.youMinorRowMenuProgressJust();
        }
    }
}


- (void)arcadeSystemInferCellSymbolsScannerLabel:(BirthMidAddLabel *)label {
    NSMutableAttributedString *attributedText = [label.attributedText mutableCopy];
    __block BOOL optHexFlip = 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 romanLast = !_snapStairGiven;
        
        
        NSTextAttachment *putPubBedWrap = [[NSTextAttachment alloc] init];
        
        
        UIColor *jabberColor = romanLast ? [HexDiscrete prominentColor]: UIColor.lightGrayColor;
        UIImage *tagVisitImage = [UIImage hebrewLostLengthKeysLegacyName:romanLast ? HexDiscrete.shelfTenSide.containComputerBufferViolationHexPetabytes :HexDiscrete.shelfTenSide.yesterdaySlopeExtensionHigherLiveLeftover];
        
        
        putPubBedWrap.image = [[tagVisitImage imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]
                                imageWithTintColor:jabberColor];
        putPubBedWrap.bounds = oldAttachment.bounds;
        
        
        [attributedText removeAttribute:NSAttachmentAttributeName range:range];
        [attributedText addAttribute:NSAttachmentAttributeName value:putPubBedWrap range:range];
        
        _snapStairGiven = romanLast;
        optHexFlip = YES;
        *stop = YES;
    }];
    
    if (optHexFlip) {
        dispatch_async(dispatch_get_main_queue(), ^{
            [UIView transitionWithView:label
                              duration:0.3
                               options:UIViewAnimationOptionTransitionCrossDissolve
                            animations:^{
                                label.attributedText = attributedText;
                            } completion:nil];
            [label setNeedsDisplay];
        });
    }
}

@end
