






#import "FixObjectManager.h"
#import "LookupToneHashViewController.h"
#import "YearsShiftConfig.h"

@interface FixObjectManager()
@property (nonatomic, strong) NSMutableArray<UIWindow *> *towerSlabAlone;  
@property (nonatomic, strong) NSMutableArray<UIWindow *> *postRoundNet;  
@end

@implementation FixObjectManager

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

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


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


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


- (void)sentinelStylisticGesturePrinterRevealChatterAppendedViewController:(UIViewController *)kitMan{
    dispatch_async(dispatch_get_main_queue(), ^{
        
        if ([UIApplication sharedApplication].applicationState == UIApplicationStateActive) {
            
            UIWindow *faxWindow = [self systolicChildrenTintRareChainRed:kitMan];
            
            
            [self expectedSenseSameDiscoverAdapterResponder:faxWindow];
            
            [self.towerSlabAlone addObject:faxWindow];
        } else {
            
            __weak typeof(self) weakSelf = self;
            
            __block __weak id car = nil;
            
            car = [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationDidBecomeActiveNotification
                                                                       object:nil
                                                                        queue:[NSOperationQueue mainQueue]
                                                                   usingBlock:^(NSNotification *note) {
                
                [[NSNotificationCenter defaultCenter] removeObserver:car];
                [weakSelf sentinelStylisticGesturePrinterRevealChatterAppendedViewController:kitMan];
            }];
        }
    });
}

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

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

- (void)friendsFinishedMaxShelfPunjabiJumpBegan:(id)object {
    UIViewController *kitMan = nil;
    
        
    if ([object isKindOfClass:[UIViewController class]]) {
        kitMan = object;
    }
    
    if ([object isKindOfClass:[UIView class]]) {
        kitMan = [LookupToneHashViewController new];
        kitMan.view = object;
    }
    
    
    UIWindow *faxWindow = [self systolicChildrenTintRareChainRed:kitMan];
    
    
    [self expectedSenseSameDiscoverAdapterResponder:faxWindow];
    
    
    [self.postRoundNet addObject:faxWindow];
}

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

- (void)endUnfocusedWindow {
    [self warpCatalogCovariantRegistrySiteWindow];
}

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

        
        UIWindow *sameWindow = [self.postRoundNet lastObject];
        [self.postRoundNet removeLastObject];

        
        if (sameWindow.isKeyWindow) {
            [self butLooseBoxAndWindow];
        }

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

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

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

- (void)bedLetterRareDayRetrieveFaeroeseDrive:(void(^)(void))completion {
    
    if (self.postRoundNet.count == 0) {
        if (completion) {
            dispatch_async(dispatch_get_main_queue(), ^{
                completion();
            });
        }
        return;
    }
    
    
    dispatch_async(dispatch_get_main_queue(), ^{
        
        NSArray *helpersArmourWaitNewtonsProminent = [self.postRoundNet copy];
        for (UIWindow *window in helpersArmourWaitNewtonsProminent) {
            if (window.isKeyWindow) {
                [self butLooseBoxAndWindow];
            }
            window.hidden = YES;
            
            
            for (UIView *adjusts in [window.subviews copy]) {
                [adjusts removeFromSuperview];
            }
            
            
            window.rootViewController = nil;
        }
        
        
        [self.postRoundNet 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 *)systolicChildrenTintRareChainRed:(UIViewController *)kitMan {
    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 = kitMan;
    return window;
}

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

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


- (void)butLooseBoxAndWindow {
    UIWindow *pickWindow = [self treeFindTabWindow];
    [pickWindow makeKeyWindow];
    if (!pickWindow.isKeyWindow) {
        [pickWindow becomeKeyWindow];
    }
}

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

- (NSArray<UIWindowScene *> *)insertingRecoveredBondThroughMove {
    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 *)hexWindow {
    return [self.postRoundNet lastObject];
}

- (NSInteger)fixCarCount {
    return self.postRoundNet.count;
}


@end
