






#import "ShiftGaelicLabel.h"
#import "DiscardsOld.h"
#import "UIImage+AreImage.h"

@implementation ShiftGaelicLabel

+ (ShiftGaelicLabel *)crossDarkPongLabel {
    return [self crossDarkPongLabel:YES];
}

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

    NSAttributedString *eventSmileDownloadsAccessoryWin = nil;
    if (isCheckBox) {
        
        NSTextAttachment *attachment = [[NSTextAttachment alloc] init];
        UIImage *templateImage = [[UIImage interBandwidthBackJabberRatingsName:DiscardsOld.dogPongRoman.basicPresetPickSeparatedUpdatingLike] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
        attachment.image = templateImage; 
        
        attachment.bounds = CGRectMake(0, -5, 20, 20);
        eventSmileDownloadsAccessoryWin = [NSAttributedString attributedStringWithAttachment:attachment];
    }

    
    NSString *text = DiscardsOld.forceParameter.outWithinFor;
    NSMutableAttributedString *siteOptBarStay = [[NSMutableAttributedString alloc] initWithString:text];
    
    
    NSRange flushFunBitEra = [text rangeOfString:DiscardsOld.forceParameter.strictlySexual];
    if (flushFunBitEra.location != NSNotFound) {
        [siteOptBarStay addAttribute:NSForegroundColorAttributeName value:[DiscardsOld celticBusColor] range:flushFunBitEra];
        [siteOptBarStay addAttribute:NSUnderlineStyleAttributeName value:@(NSUnderlineStyleSingle) range:flushFunBitEra];
    }

    
    NSMutableAttributedString *producerSideTaskAgeJapanese = [[NSMutableAttributedString alloc] init];
    if (eventSmileDownloadsAccessoryWin) {
        [producerSideTaskAgeJapanese appendAttributedString:eventSmileDownloadsAccessoryWin];
    }
    [producerSideTaskAgeJapanese appendAttributedString:siteOptBarStay];
    
    label.attributedText = producerSideTaskAgeJapanese;
    
    
    UITapGestureRecognizer *mapMeanFar = [[UITapGestureRecognizer alloc] initWithTarget:label action:@selector(evaluateTopElderPinkMin:)];
    [label addGestureRecognizer:mapMeanFar];
    
    return label;
}

- (void)setWhileBagEggTwo:(BOOL)whileBagEggTwo {
    _whileBagEggTwo = !whileBagEggTwo;
    [self committedScalingZoomDroppedRowCellularLabel:self];
}

- (void)evaluateTopElderPinkMin:(UITapGestureRecognizer *)mapMeanFar {
    ShiftGaelicLabel *label = (ShiftGaelicLabel *)mapMeanFar.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 caretGerman = [mapMeanFar locationInView:label];
    CGRect usedRect = [layoutManager usedRectForTextContainer:textContainer];
    CGPoint capturedProceedDesiredShadowPurple = CGPointMake(
        (label.bounds.size.width - usedRect.size.width) / 2,   
        (label.bounds.size.height - usedRect.size.height) / 2  
    );
    
    
    CGPoint visionStartedExecutorReportCarbonBold = CGPointMake(
        caretGerman.x - capturedProceedDesiredShadowPurple.x,
        caretGerman.y - capturedProceedDesiredShadowPurple.y
    );
    
    
    __block BOOL napTowerClang = 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 whoNapWait;
            [layoutManager glyphRangeForCharacterRange:range actualCharacterRange:&whoNapWait];
            
            
            CGRect wrongRect = [layoutManager boundingRectForGlyphRange:whoNapWait
                                                      inTextContainer:textContainer];
            
            
            CGRect cleanEarFixRect = CGRectOffset(wrongRect, capturedProceedDesiredShadowPurple.x, capturedProceedDesiredShadowPurple.y);
            
            
            if (CGRectContainsPoint(cleanEarFixRect, caretGerman)) {
                napTowerClang = YES;
                *stop = YES;
            }
        }
    }];
    
    if (napTowerClang) {
        
        
        [self committedScalingZoomDroppedRowCellularLabel:label];
        return;
    }
    
    
    NSUInteger characterIndex = [layoutManager characterIndexForPoint:visionStartedExecutorReportCarbonBold
                                                    inTextContainer:textContainer
                           fractionOfDistanceBetweenInsertionPoints:NULL];
    
    NSString *viewText = label.attributedText.string;
    NSRange flushFunBitEra = [viewText rangeOfString:DiscardsOld.forceParameter.strictlySexual];
    
    if (characterIndex != NSNotFound && NSLocationInRange(characterIndex, flushFunBitEra)) {
        
        
        if (self.packKeyCapFragmentsParentAppend) {
            self.packKeyCapFragmentsParentAppend();
        }
    }
}


- (void)committedScalingZoomDroppedRowCellularLabel:(ShiftGaelicLabel *)label {
    NSMutableAttributedString *attributedText = [label.attributedText mutableCopy];
    __block BOOL funDisplay = 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 sinhalese = !_whileBagEggTwo;
        
        
        NSTextAttachment *bagFarPenSame = [[NSTextAttachment alloc] init];
        
        
        UIColor *itsAndColor = sinhalese ? [DiscardsOld celticBusColor]: UIColor.lightGrayColor;
        UIImage *trialOddImage = [UIImage interBandwidthBackJabberRatingsName:sinhalese ? DiscardsOld.dogPongRoman.sparseExpertLongestRetGestureDescend :DiscardsOld.dogPongRoman.basicPresetPickSeparatedUpdatingLike];
        
        
        bagFarPenSame.image = [[trialOddImage imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]
                                imageWithTintColor:itsAndColor];
        bagFarPenSame.bounds = oldAttachment.bounds;
        
        
        [attributedText removeAttribute:NSAttachmentAttributeName range:range];
        [attributedText addAttribute:NSAttachmentAttributeName value:bagFarPenSame range:range];
        
        _whileBagEggTwo = sinhalese;
        funDisplay = YES;
        *stop = YES;
    }];
    
    if (funDisplay) {
        dispatch_async(dispatch_get_main_queue(), ^{
            [UIView transitionWithView:label
                              duration:0.3
                               options:UIViewAnimationOptionTransitionCrossDissolve
                            animations:^{
                                label.attributedText = attributedText;
                            } completion:nil];
            [label setNeedsDisplay];
        });
    }
}

@end
