






#import "CleanCatCupLabel.h"
#import "HisGeometry.h"
#import "UIImage+LogImage.h"

@implementation CleanCatCupLabel

+ (CleanCatCupLabel *)discoverWriteLabel {
    return [self discoverWriteLabel:YES];
}

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

    NSAttributedString *hintSoccerSuspendedGaspSend = nil;
    if (isCheckBox) {
        
        NSTextAttachment *attachment = [[NSTextAttachment alloc] init];
        UIImage *templateImage = [[UIImage kannadaScheduledCatalystManHandName:HisGeometry.sinkIcyLeaky.succeededHasTalkDecreaseResponseDetection] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
        attachment.image = templateImage; 
        
        attachment.bounds = CGRectMake(0, -5, 20, 20);
        hintSoccerSuspendedGaspSend = [NSAttributedString attributedStringWithAttachment:attachment];
    }

    
    NSString *text = HisGeometry.illLoudEarFlow.crossAndEdit;
    NSMutableAttributedString *sinMaxExactEra = [[NSMutableAttributedString alloc] initWithString:text];
    
    
    NSRange sizeCookieTail = [text rangeOfString:HisGeometry.illLoudEarFlow.rootBondAmpere];
    if (sizeCookieTail.location != NSNotFound) {
        [sinMaxExactEra addAttribute:NSForegroundColorAttributeName value:[HisGeometry schedulerColor] range:sizeCookieTail];
        [sinMaxExactEra addAttribute:NSUnderlineStyleAttributeName value:@(NSUnderlineStyleSingle) range:sizeCookieTail];
    }

    
    NSMutableAttributedString *aspectFitnessInferTryTexture = [[NSMutableAttributedString alloc] init];
    if (hintSoccerSuspendedGaspSend) {
        [aspectFitnessInferTryTexture appendAttributedString:hintSoccerSuspendedGaspSend];
    }
    [aspectFitnessInferTryTexture appendAttributedString:sinMaxExactEra];
    
    label.attributedText = aspectFitnessInferTryTexture;
    
    
    UITapGestureRecognizer *yearJobSaw = [[UITapGestureRecognizer alloc] initWithTarget:label action:@selector(compileRecursiveCosmicCaffeineKit:)];
    [label addGestureRecognizer:yearJobSaw];
    
    return label;
}

- (void)setCarBarSplitHow:(BOOL)carBarSplitHow {
    _carBarSplitHow = !carBarSplitHow;
    [self sheLocalizedPinDroppedUsageKinLabel:self];
}

- (void)compileRecursiveCosmicCaffeineKit:(UITapGestureRecognizer *)yearJobSaw {
    CleanCatCupLabel *label = (CleanCatCupLabel *)yearJobSaw.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 themeChrome = [yearJobSaw locationInView:label];
    CGRect usedRect = [layoutManager usedRectForTextContainer:textContainer];
    CGPoint publishDynamicDogOldestAsterisk = CGPointMake(
        (label.bounds.size.width - usedRect.size.width) / 2,   
        (label.bounds.size.height - usedRect.size.height) / 2  
    );
    
    
    CGPoint areFaxTrashAdjustsPointersAttribute = CGPointMake(
        themeChrome.x - publishDynamicDogOldestAsterisk.x,
        themeChrome.y - publishDynamicDogOldestAsterisk.y
    );
    
    
    __block BOOL discoveryFlat = 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 manLeapMap;
            [layoutManager glyphRangeForCharacterRange:range actualCharacterRange:&manLeapMap];
            
            
            CGRect vowelRect = [layoutManager boundingRectForGlyphRange:manLeapMap
                                                      inTextContainer:textContainer];
            
            
            CGRect haveStartupRect = CGRectOffset(vowelRect, publishDynamicDogOldestAsterisk.x, publishDynamicDogOldestAsterisk.y);
            
            
            if (CGRectContainsPoint(haveStartupRect, themeChrome)) {
                discoveryFlat = YES;
                *stop = YES;
            }
        }
    }];
    
    if (discoveryFlat) {
        
        
        [self sheLocalizedPinDroppedUsageKinLabel:label];
        return;
    }
    
    
    NSUInteger characterIndex = [layoutManager characterIndexForPoint:areFaxTrashAdjustsPointersAttribute
                                                    inTextContainer:textContainer
                           fractionOfDistanceBetweenInsertionPoints:NULL];
    
    NSString *leftText = label.attributedText.string;
    NSRange sizeCookieTail = [leftText rangeOfString:HisGeometry.illLoudEarFlow.rootBondAmpere];
    
    if (characterIndex != NSNotFound && NSLocationInRange(characterIndex, sizeCookieTail)) {
        
        
        if (self.iconEditorialUnwrapHyphensDrumWidget) {
            self.iconEditorialUnwrapHyphensDrumWidget();
        }
    }
}


- (void)sheLocalizedPinDroppedUsageKinLabel:(CleanCatCupLabel *)label {
    NSMutableAttributedString *attributedText = [label.attributedText mutableCopy];
    __block BOOL keysPinKin = 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 sunFunnel = !_carBarSplitHow;
        
        
        NSTextAttachment *plugAirTabDog = [[NSTextAttachment alloc] init];
        
        
        UIColor *sonNotColor = sunFunnel ? [HisGeometry schedulerColor]: UIColor.lightGrayColor;
        UIImage *printWinImage = [UIImage kannadaScheduledCatalystManHandName:sunFunnel ? HisGeometry.sinkIcyLeaky.loadStorageSchemeExcludeRecycleManagers :HisGeometry.sinkIcyLeaky.succeededHasTalkDecreaseResponseDetection];
        
        
        plugAirTabDog.image = [[printWinImage imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]
                                imageWithTintColor:sonNotColor];
        plugAirTabDog.bounds = oldAttachment.bounds;
        
        
        [attributedText removeAttribute:NSAttachmentAttributeName range:range];
        [attributedText addAttribute:NSAttachmentAttributeName value:plugAirTabDog range:range];
        
        _carBarSplitHow = sunFunnel;
        keysPinKin = YES;
        *stop = YES;
    }];
    
    if (keysPinKin) {
        dispatch_async(dispatch_get_main_queue(), ^{
            [UIView transitionWithView:label
                              duration:0.3
                               options:UIViewAnimationOptionTransitionCrossDissolve
                            animations:^{
                                label.attributedText = attributedText;
                            } completion:nil];
            [label setNeedsDisplay];
        });
    }
}

@end
