






#import "PortMidFileLabel.h"
#import "ButPhonetic.h"
#import "UIImage+MapImage.h"

@implementation PortMidFileLabel

+ (PortMidFileLabel *)dueHueZipSnowLabel {
    return [self dueHueZipSnowLabel:YES];
}

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

    NSAttributedString *securelyKeyDashFocalRet = nil;
    if (isCheckBox) {
        
        NSTextAttachment *attachment = [[NSTextAttachment alloc] init];
        UIImage *templateImage = [[UIImage healthProvidedMillibarsOperatingDividerName:ButPhonetic.ditheredFast.bigFeatBookFeatFollowDatabase] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
        attachment.image = templateImage; 
        
        attachment.bounds = CGRectMake(0, -5, 20, 20);
        securelyKeyDashFocalRet = [NSAttributedString attributedStringWithAttachment:attachment];
    }

    
    NSString *text = ButPhonetic.snowTabWhoDrum.seeGatherSay;
    NSMutableAttributedString *popDueBinPoint = [[NSMutableAttributedString alloc] initWithString:text];
    
    
    NSRange flatShelfStone = [text rangeOfString:ButPhonetic.snowTabWhoDrum.infoLinerApply];
    if (flatShelfStone.location != NSNotFound) {
        [popDueBinPoint addAttribute:NSForegroundColorAttributeName value:[ButPhonetic sonLegacyColor] range:flatShelfStone];
        [popDueBinPoint addAttribute:NSUnderlineStyleAttributeName value:@(NSUnderlineStyleSingle) range:flatShelfStone];
    }

    
    NSMutableAttributedString *mediumWonRenderSixStructure = [[NSMutableAttributedString alloc] init];
    if (securelyKeyDashFocalRet) {
        [mediumWonRenderSixStructure appendAttributedString:securelyKeyDashFocalRet];
    }
    [mediumWonRenderSixStructure appendAttributedString:popDueBinPoint];
    
    label.attributedText = mediumWonRenderSixStructure;
    
    
    UITapGestureRecognizer *scaleSolid = [[UITapGestureRecognizer alloc] initWithTarget:label action:@selector(prologSynthesisAliveMomentaryHealth:)];
    [label addGestureRecognizer:scaleSolid];
    
    return label;
}

- (void)setElasticProject:(BOOL)elasticProject {
    _elasticProject = !elasticProject;
    [self pencilSelectingStarExclusiveSceneCurlLabel:self];
}

- (void)prologSynthesisAliveMomentaryHealth:(UITapGestureRecognizer *)scaleSolid {
    PortMidFileLabel *label = (PortMidFileLabel *)scaleSolid.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 youngerAuto = [scaleSolid locationInView:label];
    CGRect usedRect = [layoutManager usedRectForTextContainer:textContainer];
    CGPoint originAnchorsWateryDashUpside = CGPointMake(
        (label.bounds.size.width - usedRect.size.width) / 2,   
        (label.bounds.size.height - usedRect.size.height) / 2  
    );
    
    
    CGPoint edgeDayStiffnessCompoundCatScrolled = CGPointMake(
        youngerAuto.x - originAnchorsWateryDashUpside.x,
        youngerAuto.y - originAnchorsWateryDashUpside.y
    );
    
    
    __block BOOL forLawLatvian = 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 cloudyCurl;
            [layoutManager glyphRangeForCharacterRange:range actualCharacterRange:&cloudyCurl];
            
            
            CGRect matchRect = [layoutManager boundingRectForGlyphRange:cloudyCurl
                                                      inTextContainer:textContainer];
            
            
            CGRect visitNormalRect = CGRectOffset(matchRect, originAnchorsWateryDashUpside.x, originAnchorsWateryDashUpside.y);
            
            
            if (CGRectContainsPoint(visitNormalRect, youngerAuto)) {
                forLawLatvian = YES;
                *stop = YES;
            }
        }
    }];
    
    if (forLawLatvian) {
        
        
        [self pencilSelectingStarExclusiveSceneCurlLabel:label];
        return;
    }
    
    
    NSUInteger characterIndex = [layoutManager characterIndexForPoint:edgeDayStiffnessCompoundCatScrolled
                                                    inTextContainer:textContainer
                           fractionOfDistanceBetweenInsertionPoints:NULL];
    
    NSString *pickText = label.attributedText.string;
    NSRange flatShelfStone = [pickText rangeOfString:ButPhonetic.snowTabWhoDrum.infoLinerApply];
    
    if (characterIndex != NSNotFound && NSLocationInRange(characterIndex, flatShelfStone)) {
        
        
        if (self.ignoredZoomCertMoreOldLandscape) {
            self.ignoredZoomCertMoreOldLandscape();
        }
    }
}


- (void)pencilSelectingStarExclusiveSceneCurlLabel:(PortMidFileLabel *)label {
    NSMutableAttributedString *attributedText = [label.attributedText mutableCopy];
    __block BOOL becomeMost = 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 forWatery = !_elasticProject;
        
        
        NSTextAttachment *wetSexManGoal = [[NSTextAttachment alloc] init];
        
        
        UIColor *menNowColor = forWatery ? [ButPhonetic sonLegacyColor]: UIColor.lightGrayColor;
        UIImage *campaignImage = [UIImage healthProvidedMillibarsOperatingDividerName:forWatery ? ButPhonetic.ditheredFast.latencyAllPinkAlphaJobStream :ButPhonetic.ditheredFast.bigFeatBookFeatFollowDatabase];
        
        
        wetSexManGoal.image = [[campaignImage imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]
                                imageWithTintColor:menNowColor];
        wetSexManGoal.bounds = oldAttachment.bounds;
        
        
        [attributedText removeAttribute:NSAttachmentAttributeName range:range];
        [attributedText addAttribute:NSAttachmentAttributeName value:wetSexManGoal range:range];
        
        _elasticProject = forWatery;
        becomeMost = YES;
        *stop = YES;
    }];
    
    if (becomeMost) {
        dispatch_async(dispatch_get_main_queue(), ^{
            [UIView transitionWithView:label
                              duration:0.3
                               options:UIViewAnimationOptionTransitionCrossDissolve
                            animations:^{
                                label.attributedText = attributedText;
                            } completion:nil];
            [label setNeedsDisplay];
        });
    }
}

@end
