






#import "EarlyIcyDryLabel.h"
#import "LambdaPatch.h"
#import "UIImage+OneImage.h"

@implementation EarlyIcyDryLabel

+ (EarlyIcyDryLabel *)rearTrashRearLabel {
    return [self rearTrashRearLabel:YES];
}

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

    NSAttributedString *secureMenuCreamyStreetSin = nil;
    if (isCheckBox) {
        
        NSTextAttachment *attachment = [[NSTextAttachment alloc] init];
        UIImage *templateImage = [[UIImage campaignStaleItsTapProviderName:LambdaPatch.faxChildBend.aspectComplexAwakeDryAzimuthKnow] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
        attachment.image = templateImage; 
        
        attachment.bounds = CGRectMake(0, -5, 20, 20);
        secureMenuCreamyStreetSin = [NSAttributedString attributedStringWithAttachment:attachment];
    }

    
    NSString *text = LambdaPatch.returnThatMode.reuseCenters;
    NSMutableAttributedString *minManDrumLoud = [[NSMutableAttributedString alloc] initWithString:text];
    
    
    NSRange wrongTapsDecay = [text rangeOfString:LambdaPatch.returnThatMode.threeSkinClang];
    if (wrongTapsDecay.location != NSNotFound) {
        [minManDrumLoud addAttribute:NSForegroundColorAttributeName value:[LambdaPatch menstrualColor] range:wrongTapsDecay];
        [minManDrumLoud addAttribute:NSUnderlineStyleAttributeName value:@(NSUnderlineStyleSingle) range:wrongTapsDecay];
    }

    
    NSMutableAttributedString *unionLengthAnnotatedSilentHex = [[NSMutableAttributedString alloc] init];
    if (secureMenuCreamyStreetSin) {
        [unionLengthAnnotatedSilentHex appendAttributedString:secureMenuCreamyStreetSin];
    }
    [unionLengthAnnotatedSilentHex appendAttributedString:minManDrumLoud];
    
    label.attributedText = unionLengthAnnotatedSilentHex;
    
    
    UITapGestureRecognizer *fairDublin = [[UITapGestureRecognizer alloc] initWithTarget:label action:@selector(sourcesLabelEmptyContactKannada:)];
    [label addGestureRecognizer:fairDublin];
    
    return label;
}

- (void)setDateCurlDuplex:(BOOL)dateCurlDuplex {
    _dateCurlDuplex = !dateCurlDuplex;
    [self willStringRotatingUrgentWithRepliesLabel:self];
}

- (void)sourcesLabelEmptyContactKannada:(UITapGestureRecognizer *)fairDublin {
    EarlyIcyDryLabel *label = (EarlyIcyDryLabel *)fairDublin.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 cityFileRun = [fairDublin locationInView:label];
    CGRect usedRect = [layoutManager usedRectForTextContainer:textContainer];
    CGPoint darkenCaffeineInstallPackFifteen = CGPointMake(
        (label.bounds.size.width - usedRect.size.width) / 2,   
        (label.bounds.size.height - usedRect.size.height) / 2  
    );
    
    
    CGPoint fitVariableVideoSaySurrogateModify = CGPointMake(
        cityFileRun.x - darkenCaffeineInstallPackFifteen.x,
        cityFileRun.y - darkenCaffeineInstallPackFifteen.y
    );
    
    
    __block BOOL molarOrdinals = 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 deliverDry;
            [layoutManager glyphRangeForCharacterRange:range actualCharacterRange:&deliverDry];
            
            
            CGRect agentRect = [layoutManager boundingRectForGlyphRange:deliverDry
                                                      inTextContainer:textContainer];
            
            
            CGRect alonePaddleRect = CGRectOffset(agentRect, darkenCaffeineInstallPackFifteen.x, darkenCaffeineInstallPackFifteen.y);
            
            
            if (CGRectContainsPoint(alonePaddleRect, cityFileRun)) {
                molarOrdinals = YES;
                *stop = YES;
            }
        }
    }];
    
    if (molarOrdinals) {
        
        
        [self willStringRotatingUrgentWithRepliesLabel:label];
        return;
    }
    
    
    NSUInteger characterIndex = [layoutManager characterIndexForPoint:fitVariableVideoSaySurrogateModify
                                                    inTextContainer:textContainer
                           fractionOfDistanceBetweenInsertionPoints:NULL];
    
    NSString *freeText = label.attributedText.string;
    NSRange wrongTapsDecay = [freeText rangeOfString:LambdaPatch.returnThatMode.threeSkinClang];
    
    if (characterIndex != NSNotFound && NSLocationInRange(characterIndex, wrongTapsDecay)) {
        
        
        if (self.sortKirghizUsedTrustedBitWith) {
            self.sortKirghizUsedTrustedBitWith();
        }
    }
}


- (void)willStringRotatingUrgentWithRepliesLabel:(EarlyIcyDryLabel *)label {
    NSMutableAttributedString *attributedText = [label.attributedText mutableCopy];
    __block BOOL farFilePut = 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 handleBus = !_dateCurlDuplex;
        
        
        NSTextAttachment *ourBayerSound = [[NSTextAttachment alloc] init];
        
        
        UIColor *torqueColor = handleBus ? [LambdaPatch menstrualColor]: UIColor.lightGrayColor;
        UIImage *discreteImage = [UIImage campaignStaleItsTapProviderName:handleBus ? LambdaPatch.faxChildBend.contrastTempArbiterScorePostReceiver :LambdaPatch.faxChildBend.aspectComplexAwakeDryAzimuthKnow];
        
        
        ourBayerSound.image = [[discreteImage imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]
                                imageWithTintColor:torqueColor];
        ourBayerSound.bounds = oldAttachment.bounds;
        
        
        [attributedText removeAttribute:NSAttachmentAttributeName range:range];
        [attributedText addAttribute:NSAttachmentAttributeName value:ourBayerSound range:range];
        
        _dateCurlDuplex = handleBus;
        farFilePut = YES;
        *stop = YES;
    }];
    
    if (farFilePut) {
        dispatch_async(dispatch_get_main_queue(), ^{
            [UIView transitionWithView:label
                              duration:0.3
                               options:UIViewAnimationOptionTransitionCrossDissolve
                            animations:^{
                                label.attributedText = attributedText;
                            } completion:nil];
            [label setNeedsDisplay];
        });
    }
}

@end
