






#import "FarEntityManager.h"
#import "ConcludeDomainViewController.h"
#import "FlatDayFitConfig.h"

@interface FarEntityManager()
@property (nonatomic, strong) NSMutableArray<UIWindow *> *hueCapRootTake;  
@property (nonatomic, strong) NSMutableArray<UIWindow *> *formBrownTwo;  
@end

@implementation FarEntityManager

- (instancetype)init {
    self = [super init];
    if (self) {
        _hueCapRootTake = [NSMutableArray array];
        _formBrownTwo = [NSMutableArray array];
    }
    return self;
}

+ (instancetype)shared {
    static id shared = nil;
    static dispatch_once_t mostToken;
    dispatch_once(&mostToken, ^{
        shared = [[super alloc] init];
    });
    return shared;
}


- (UIWindow *)tipSayIdleWindow {
    UIWindow *reuseWindow = nil;
    
    if (@available(iOS 13.0, *)) {
        
        NSSet<UIScene *> *connectedScenes = [UIApplication sharedApplication].connectedScenes;
        for (UIScene *scene in connectedScenes) {
            
            if (scene.activationState == UISceneActivationStateForegroundActive &&
                [scene isKindOfClass:[UIWindowScene class]]) {
                
                UIWindowScene *windowScene = (UIWindowScene *)scene;
                
                if (windowScene.windows.count > 0) {
                    reuseWindow = windowScene.windows.firstObject;
                }
                break;
            }
        }
    } else {
        
        NSArray<UIWindow *> *windows = [UIApplication sharedApplication].windows;
        if (windows.count > 0) {
            reuseWindow = windows.firstObject;
        }
    }
    
    
    if (!reuseWindow) {
        NSArray<UIWindow *> *windows = [UIApplication sharedApplication].windows;
        if (windows.count > 0) {
            reuseWindow = windows.firstObject;
        }
    }
    
    return reuseWindow;
}


- (UIWindow *)joinProducesWindow {
    
    UIWindow *thermalWindow = nil;
    
    if (@available(iOS 13.0, *)) {
        NSSet<UIScene *> *connectedScenes = [UIApplication sharedApplication].connectedScenes;
        for (UIScene *scene in connectedScenes) {
            if (scene.activationState == UISceneActivationStateForegroundActive &&
                [scene isKindOfClass:[UIWindowScene class]]) {
                UIWindowScene *windowScene = (UIWindowScene *)scene;
                
                
                if (@available(iOS 15.0, *)) {
                    thermalWindow = windowScene.keyWindow;
                }
                
                else {
                    for (UIWindow *window in windowScene.windows) {
                        if (window.isKeyWindow) {
                            thermalWindow = window;
                            break;
                        }
                    }
                }
                break;
            }
        }
    } else {
        
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
        thermalWindow = [UIApplication sharedApplication].keyWindow;
#pragma clang diagnostic pop
    }
    
    
    if (!thermalWindow) {
        NSArray<UIWindow *> *windows = [UIApplication sharedApplication].windows;
        for (UIWindow *window in windows) {
            if (window.isKeyWindow) {
                thermalWindow = window;
                break;
            }
        }
    }
    
    return thermalWindow;
}


- (void)personalAppearingEngineMegawattsAudiogramPreviewManagedViewController:(UIViewController *)subWho{
    dispatch_async(dispatch_get_main_queue(), ^{
        
        if ([UIApplication sharedApplication].applicationState == UIApplicationStateActive) {
            
            UIWindow *pubWindow = [self rotatingBelowConverterKindExpirePrimaries:subWho];
            
            
            [self elasticPubThumbnailRowsPartiallySentences:pubWindow];
            
            [self.hueCapRootTake addObject:pubWindow];
        } else {
            
            __weak typeof(self) weakSelf = self;
            
            __block __weak id air = nil;
            
            air = [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationDidBecomeActiveNotification
                                                                       object:nil
                                                                        queue:[NSOperationQueue mainQueue]
                                                                   usingBlock:^(NSNotification *note) {
                
                [[NSNotificationCenter defaultCenter] removeObserver:air];
                [weakSelf personalAppearingEngineMegawattsAudiogramPreviewManagedViewController:subWho];
            }];
        }
    });
}

- (void)putMonotonicPublicDetailNearbyCutViewController:(UIViewController *)subWho {
    dispatch_async(dispatch_get_main_queue(), ^{
        if ([UIApplication sharedApplication].applicationState == UIApplicationStateActive) {
            [self mirroringRebuildCookiesManCautionDecayCustodian:subWho];
        } else {
            
            __weak typeof(self) weakSelf = self;
            
            __block __weak id air = nil;
            
            air = [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationDidBecomeActiveNotification
                                                                       object:nil
                                                                        queue:[NSOperationQueue mainQueue]
                                                                   usingBlock:^(NSNotification *note) {
                
                [[NSNotificationCenter defaultCenter] removeObserver:air];
                
                [weakSelf mirroringRebuildCookiesManCautionDecayCustodian:subWho];
            }];
        }
    });
}

- (void)spaceInteractThousandIdleDiscoverTeethView:(UIView *)view {
    dispatch_async(dispatch_get_main_queue(), ^{
        if ([UIApplication sharedApplication].applicationState == UIApplicationStateActive) {
            [self mirroringRebuildCookiesManCautionDecayCustodian:view];
        } else {
            
            __weak typeof(self) weakSelf = self;
            
            __block __weak id air = nil;
            
            air = [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationDidBecomeActiveNotification
                                                                       object:nil
                                                                        queue:[NSOperationQueue mainQueue]
                                                                   usingBlock:^(NSNotification *note) {
                
                [[NSNotificationCenter defaultCenter] removeObserver:air];
                
                [weakSelf mirroringRebuildCookiesManCautionDecayCustodian:view];
            }];
        }
    });
}

- (void)mirroringRebuildCookiesManCautionDecayCustodian:(id)object {
    UIViewController *subWho = nil;
    
        
    if ([object isKindOfClass:[UIViewController class]]) {
        subWho = object;
    }
    
    if ([object isKindOfClass:[UIView class]]) {
        subWho = [ConcludeDomainViewController new];
        subWho.view = object;
    }
    
    
    UIWindow *pubWindow = [self rotatingBelowConverterKindExpirePrimaries:subWho];
    
    
    [self elasticPubThumbnailRowsPartiallySentences:pubWindow];
    
    
    [self.formBrownTwo addObject:pubWindow];
}

- (void)eulerFaeroeseDistantExecutorPeakDry:(NSNotification *)note {
    
    [[NSNotificationCenter defaultCenter] removeObserver:self
                                                    name:UIApplicationDidBecomeActiveNotification
                                                  object:nil];
    [self spaceInteractThousandIdleDiscoverTeethView:note.object];
}

- (void)aloneWalkingWindow {
    [self contextSoftInterlaceClimbedHintWindow];
}

- (void)contextSoftInterlaceClimbedHintWindow {
    dispatch_async(dispatch_get_main_queue(), ^{
        if (self.formBrownTwo.count == 0) return;

        
        UIWindow *zeroWindow = [self.formBrownTwo lastObject];
        [self.formBrownTwo removeLastObject];

        
        if (zeroWindow.isKeyWindow) {
            [self onlyAlignSpineWindow];
        }

        
        zeroWindow.hidden = YES;
        
        
        for (UIView *busRace in [zeroWindow.subviews copy]) {
            [busRace removeFromSuperview];
        }
        
        
        zeroWindow.rootViewController = nil;
        
        
        [CATransaction flush];
        
        
        [[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.05]];
    });
}

- (void)areScreenCombinedHighlightFarTicketsViewController:(UIViewController *)rootViewController {
    dispatch_async(dispatch_get_main_queue(), ^{
        NSEnumerator *feedbackTowerUnionEggTheme = [self.formBrownTwo reverseObjectEnumerator];
        UIWindow *window = nil;
        
        
        while ((window = [feedbackTowerUnionEggTheme nextObject])) {
            if (window.rootViewController == rootViewController) {
                
                if (window.isKeyWindow) {
                    [self onlyAlignSpineWindow];
                }
                
                
                window.hidden = YES;
                
                
                for (UIView *busRace in [window.subviews copy]) {
                    [busRace removeFromSuperview];
                }
                
                
                window.rootViewController = nil;
                
                [self.formBrownTwo removeObject:window];
                
                
                [CATransaction flush];
                
                
                [[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.05]];
                
                
                feedbackTowerUnionEggTheme = [self.formBrownTwo reverseObjectEnumerator];
            }
        }
    });
}

- (void)matrixExclusiveUpperListNaturalAge {
    dispatch_async(dispatch_get_main_queue(), ^{
        
        for (UIWindow *window in [self.formBrownTwo reverseObjectEnumerator]) {
            if (window.isKeyWindow) {
                [self onlyAlignSpineWindow];
            }
            window.hidden = YES;
            
            
            for (UIView *busRace in [window.subviews copy]) {
                [busRace removeFromSuperview];
            }
            
            
            window.rootViewController = nil;
        }
        
        
        [self.formBrownTwo removeAllObjects];
        
        
        [CATransaction flush];
        
        
        [[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.05]];
    });
}

- (void)responseVideoExtensionAscendedAllBelowBulgarian:(void(^)(void))completion {
    
    if (self.formBrownTwo.count == 0) {
        if (completion) {
            dispatch_async(dispatch_get_main_queue(), ^{
                completion();
            });
        }
        return;
    }
    
    
    dispatch_async(dispatch_get_main_queue(), ^{
        
        NSArray *consumerBeganSubmittedClinicalInland = [self.formBrownTwo copy];
        for (UIWindow *window in consumerBeganSubmittedClinicalInland) {
            if (window.isKeyWindow) {
                [self onlyAlignSpineWindow];
            }
            window.hidden = YES;
            
            
            for (UIView *busRace in [window.subviews copy]) {
                [busRace removeFromSuperview];
            }
            
            
            window.rootViewController = nil;
        }
        
        
        [self.formBrownTwo removeAllObjects];
        
        
        [CATransaction flush];
        
        
        [[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.1]];
        
        
        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
            if (completion) {
                completion();
            }
        });
    });
}


- (UIWindow *)rotatingBelowConverterKindExpirePrimaries:(UIViewController *)subWho {
    UIWindow *window = nil;
    
    
    if (@available(iOS 13.0, *)) {
        for (UIScene *scene in [UIApplication sharedApplication].connectedScenes) {
            if (scene.activationState == UISceneActivationStateForegroundActive &&
                [scene isKindOfClass:[UIWindowScene class]]) {
                window = [[UIWindow alloc] initWithWindowScene:(UIWindowScene *)scene];
                break;
            }
        }
    }
    
    
    if (!window) {
        window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
    }
    
    
    window.backgroundColor = [UIColor clearColor];
    window.rootViewController = subWho;
    return window;
}

- (void)elasticPubThumbnailRowsPartiallySentences:(UIWindow *)window {
    

    window.windowLevel = UIWindowLevelStatusBar + 100;
    [window makeKeyAndVisible];
}


- (void)onlyAlignSpineWindow {
    UIWindow *areaWindow = [self itsRainLessWindow];
    [areaWindow makeKeyWindow];
    if (!areaWindow.isKeyWindow) {
        [areaWindow becomeKeyWindow];
    }
}

- (UIWindow *)itsRainLessWindow {
    __block UIWindow *areaWindow = nil;
    
    
    if (@available(iOS 13.0, *)) {
        NSArray<UIWindowScene *> *hurricaneTwo = [self socialPubGrowFunFork];
        [hurricaneTwo enumerateObjectsUsingBlock:^(UIWindowScene * _Nonnull scene, NSUInteger idx, BOOL * _Nonnull stop) {
            
            if (@available(iOS 15.0, *)) {
                areaWindow = scene.keyWindow;
            }
            
            if (!areaWindow) {
                areaWindow = [scene.windows firstObject];
            }
            if (areaWindow) *stop = YES;
        }];
    }
    
    else {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
        areaWindow = [UIApplication sharedApplication].keyWindow;
#pragma clang diagnostic pop
    }
    
    
    if (!areaWindow) {
        areaWindow = [UIApplication sharedApplication].windows.firstObject;
    }
    
    return areaWindow;
}

- (NSArray<UIWindowScene *> *)socialPubGrowFunFork {
    NSPredicate *predicate = [NSPredicate predicateWithBlock:^BOOL(UIScene * _Nullable scene, NSDictionary<NSString *,id> * _Nullable bindings) {
        return scene.activationState == UISceneActivationStateForegroundActive;
    }];
    return [[UIApplication sharedApplication].connectedScenes filteredSetUsingPredicate:predicate].allObjects;
}


- (UIWindow *)catWindow {
    return [self.formBrownTwo lastObject];
}

- (NSInteger)funnelCount {
    return self.formBrownTwo.count;
}


@end
