






#import "ShearPeakManager.h"
#import "DecideDustShotViewController.h"
#import "TagBinRealConfig.h"

@interface ShearPeakManager()
@property (nonatomic, strong) NSMutableArray<UIWindow *> *chestDiastolic;  
@property (nonatomic, strong) NSMutableArray<UIWindow *> *oldTrashRate;  
@end

@implementation ShearPeakManager

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

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


- (UIWindow *)gainOldestWindow {
    UIWindow *titleWindow = 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) {
                    titleWindow = windowScene.windows.firstObject;
                }
                break;
            }
        }
    } else {
        
        NSArray<UIWindow *> *windows = [UIApplication sharedApplication].windows;
        if (windows.count > 0) {
            titleWindow = windows.firstObject;
        }
    }
    
    
    if (!titleWindow) {
        NSArray<UIWindow *> *windows = [UIApplication sharedApplication].windows;
        if (windows.count > 0) {
            titleWindow = windows.firstObject;
        }
    }
    
    return titleWindow;
}


- (UIWindow *)netTripleLawWindow {
    
    UIWindow *menuUseWindow = 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, *)) {
                    menuUseWindow = windowScene.keyWindow;
                }
                
                else {
                    for (UIWindow *window in windowScene.windows) {
                        if (window.isKeyWindow) {
                            menuUseWindow = window;
                            break;
                        }
                    }
                }
                break;
            }
        }
    } else {
        
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
        menuUseWindow = [UIApplication sharedApplication].keyWindow;
#pragma clang diagnostic pop
    }
    
    
    if (!menuUseWindow) {
        NSArray<UIWindow *> *windows = [UIApplication sharedApplication].windows;
        for (UIWindow *window in windows) {
            if (window.isKeyWindow) {
                menuUseWindow = window;
                break;
            }
        }
    }
    
    return menuUseWindow;
}


- (void)originalHerWritingEncodingStorylineDrizzleInstallViewController:(UIViewController *)bitSun{
    dispatch_async(dispatch_get_main_queue(), ^{
        
        if ([UIApplication sharedApplication].applicationState == UIApplicationStateActive) {
            
            UIWindow *theWindow = [self eyeSubFootballModernDraftCap:bitSun];
            
            
            [self digitLifetimeAttachInsteadTerminalRealm:theWindow];
            
            [self.chestDiastolic addObject:theWindow];
        } else {
            
            __weak typeof(self) weakSelf = self;
            
            __block __weak id opt = nil;
            
            opt = [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationDidBecomeActiveNotification
                                                                       object:nil
                                                                        queue:[NSOperationQueue mainQueue]
                                                                   usingBlock:^(NSNotification *note) {
                
                [[NSNotificationCenter defaultCenter] removeObserver:opt];
                [weakSelf originalHerWritingEncodingStorylineDrizzleInstallViewController:bitSun];
            }];
        }
    });
}

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

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

- (void)ourNapEscapingAtomicVolatileIndigoBuild:(id)object {
    UIViewController *bitSun = nil;
    
        
    if ([object isKindOfClass:[UIViewController class]]) {
        bitSun = object;
    }
    
    if ([object isKindOfClass:[UIView class]]) {
        bitSun = [DecideDustShotViewController new];
        bitSun.view = object;
    }
    
    
    UIWindow *theWindow = [self eyeSubFootballModernDraftCap:bitSun];
    
    
    [self digitLifetimeAttachInsteadTerminalRealm:theWindow];
    
    
    [self.oldTrashRate addObject:theWindow];
}

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

- (void)factSheetLawWindow {
    [self carbonMailForbiddenPolishNetWindow];
}

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

        
        UIWindow *keepWindow = [self.oldTrashRate lastObject];
        [self.oldTrashRate removeLastObject];

        
        if (keepWindow.isKeyWindow) {
            [self leastButPubMinWindow];
        }

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

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

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

- (void)periodBestFailureBehaveTableFlushRedefined:(void(^)(void))completion {
    
    if (self.oldTrashRate.count == 0) {
        if (completion) {
            dispatch_async(dispatch_get_main_queue(), ^{
                completion();
            });
        }
        return;
    }
    
    
    dispatch_async(dispatch_get_main_queue(), ^{
        
        NSArray *backArrangerRecentlyExporterComposite = [self.oldTrashRate copy];
        for (UIWindow *window in backArrangerRecentlyExporterComposite) {
            if (window.isKeyWindow) {
                [self leastButPubMinWindow];
            }
            window.hidden = YES;
            
            
            for (UIView *dispose in [window.subviews copy]) {
                [dispose removeFromSuperview];
            }
            
            
            window.rootViewController = nil;
        }
        
        
        [self.oldTrashRate 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 *)eyeSubFootballModernDraftCap:(UIViewController *)bitSun {
    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 = bitSun;
    return window;
}

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

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


- (void)leastButPubMinWindow {
    UIWindow *ironWindow = [self strategyOffWindow];
    [ironWindow makeKeyWindow];
    if (!ironWindow.isKeyWindow) {
        [ironWindow becomeKeyWindow];
    }
}

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

- (NSArray<UIWindowScene *> *)outdoorBitmapSolutionsCenterUploading {
    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 *)wayWindow {
    return [self.oldTrashRate lastObject];
}

- (NSInteger)bypassCount {
    return self.oldTrashRate.count;
}


@end
