






#import "InlandDidManager.h"
#import "SafeCityTagSixViewController.h"
#import "SubRingEyeConfig.h"

@interface InlandDidManager()
@property (nonatomic, strong) NSMutableArray<UIWindow *> *powerException;  
@property (nonatomic, strong) NSMutableArray<UIWindow *> *pullGlyphMap;  
@end

@implementation InlandDidManager

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

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


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


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


- (void)noncePinchSwitchSkinDegreeDiscardCostViewController:(UIViewController *)fitHex{
    dispatch_async(dispatch_get_main_queue(), ^{
        
        if ([UIApplication sharedApplication].applicationState == UIApplicationStateActive) {
            
            UIWindow *yetWindow = [self hisMenChatNineCollapsedSix:fitHex];
            
            
            [self descendedFetchRearrangeGenericCubeMin:yetWindow];
            
            [self.powerException addObject:yetWindow];
        } else {
            
            __weak typeof(self) weakSelf = self;
            
            __block __weak id sex = nil;
            
            sex = [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationDidBecomeActiveNotification
                                                                       object:nil
                                                                        queue:[NSOperationQueue mainQueue]
                                                                   usingBlock:^(NSNotification *note) {
                
                [[NSNotificationCenter defaultCenter] removeObserver:sex];
                [weakSelf noncePinchSwitchSkinDegreeDiscardCostViewController:fitHex];
            }];
        }
    });
}

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

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

- (void)unlockedGroupGuaraniLargePinPreviousCover:(id)object {
    UIViewController *fitHex = nil;
    
        
    if ([object isKindOfClass:[UIViewController class]]) {
        fitHex = object;
    }
    
    if ([object isKindOfClass:[UIView class]]) {
        fitHex = [SafeCityTagSixViewController new];
        fitHex.view = object;
    }
    
    
    UIWindow *yetWindow = [self hisMenChatNineCollapsedSix:fitHex];
    
    
    [self descendedFetchRearrangeGenericCubeMin:yetWindow];
    
    
    [self.pullGlyphMap addObject:yetWindow];
}

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

- (void)sourceSquareWindow {
    [self refusedProfileAuthorsAlignBusWindow];
}

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

        
        UIWindow *moodWindow = [self.pullGlyphMap lastObject];
        [self.pullGlyphMap removeLastObject];

        
        if (moodWindow.isKeyWindow) {
            [self offerCertResetWindow];
        }

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

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

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

- (void)jobUnableConvergedNetAloneFetchedGraceful:(void(^)(void))completion {
    
    if (self.pullGlyphMap.count == 0) {
        if (completion) {
            dispatch_async(dispatch_get_main_queue(), ^{
                completion();
            });
        }
        return;
    }
    
    
    dispatch_async(dispatch_get_main_queue(), ^{
        
        NSArray *signerArmBeaconZeroHighlight = [self.pullGlyphMap copy];
        for (UIWindow *window in signerArmBeaconZeroHighlight) {
            if (window.isKeyWindow) {
                [self offerCertResetWindow];
            }
            window.hidden = YES;
            
            
            for (UIView *enhance in [window.subviews copy]) {
                [enhance removeFromSuperview];
            }
            
            
            window.rootViewController = nil;
        }
        
        
        [self.pullGlyphMap 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 *)hisMenChatNineCollapsedSix:(UIViewController *)fitHex {
    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 = fitHex;
    return window;
}

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

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


- (void)offerCertResetWindow {
    UIWindow *linkWindow = [self foggyAllHexWindow];
    [linkWindow makeKeyWindow];
    if (!linkWindow.isKeyWindow) {
        [linkWindow becomeKeyWindow];
    }
}

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

- (NSArray<UIWindowScene *> *)expandSunRemainingDiscardedAlways {
    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 *)dueWindow {
    return [self.pullGlyphMap lastObject];
}

- (NSInteger)fourthCount {
    return self.pullGlyphMap.count;
}


@end
