






#import "ExtendingManager.h"
#import "AlarmRadixKnowViewController.h"
#import "PinDueListConfig.h"

@interface ExtendingManager()
@property (nonatomic, strong) NSMutableArray<UIWindow *> *anyAirNapBegan;  
@property (nonatomic, strong) NSMutableArray<UIWindow *> *mouthRedMark;  
@end

@implementation ExtendingManager

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

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


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


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


- (void)notifyingFailSpanSingularResizingThirteenCursorsViewController:(UIViewController *)mapNow{
    dispatch_async(dispatch_get_main_queue(), ^{
        
        if ([UIApplication sharedApplication].applicationState == UIApplicationStateActive) {
            
            UIWindow *cutWindow = [self useCancelsDiscardsRelevancePaletteDigital:mapNow];
            
            
            [self rangingActivityLogEditorsMightDiscrete:cutWindow];
            
            [self.anyAirNapBegan addObject:cutWindow];
        } else {
            
            __weak typeof(self) weakSelf = self;
            
            __block __weak id six = nil;
            
            six = [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationDidBecomeActiveNotification
                                                                       object:nil
                                                                        queue:[NSOperationQueue mainQueue]
                                                                   usingBlock:^(NSNotification *note) {
                
                [[NSNotificationCenter defaultCenter] removeObserver:six];
                [weakSelf notifyingFailSpanSingularResizingThirteenCursorsViewController:mapNow];
            }];
        }
    });
}

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

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

- (void)zipVectorFaxBuildGeneralDefaultsRouter:(id)object {
    UIViewController *mapNow = nil;
    
        
    if ([object isKindOfClass:[UIViewController class]]) {
        mapNow = object;
    }
    
    if ([object isKindOfClass:[UIView class]]) {
        mapNow = [AlarmRadixKnowViewController new];
        mapNow.view = object;
    }
    
    
    UIWindow *cutWindow = [self useCancelsDiscardsRelevancePaletteDigital:mapNow];
    
    
    [self rangingActivityLogEditorsMightDiscrete:cutWindow];
    
    
    [self.mouthRedMark addObject:cutWindow];
}

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

- (void)caretPanAreaWindow {
    [self dogFreezingSegmentsUniformAccessingWindow];
}

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

        
        UIWindow *partWindow = [self.mouthRedMark lastObject];
        [self.mouthRedMark removeLastObject];

        
        if (partWindow.isKeyWindow) {
            [self ownNetBoldMustWindow];
        }

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

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

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

- (void)catPostcardSignalingWalkingTwistSoftballElements:(void(^)(void))completion {
    
    if (self.mouthRedMark.count == 0) {
        if (completion) {
            dispatch_async(dispatch_get_main_queue(), ^{
                completion();
            });
        }
        return;
    }
    
    
    dispatch_async(dispatch_get_main_queue(), ^{
        
        NSArray *zeroFocalPlaneItsSlow = [self.mouthRedMark copy];
        for (UIWindow *window in zeroFocalPlaneItsSlow) {
            if (window.isKeyWindow) {
                [self ownNetBoldMustWindow];
            }
            window.hidden = YES;
            
            
            for (UIView *workSay in [window.subviews copy]) {
                [workSay removeFromSuperview];
            }
            
            
            window.rootViewController = nil;
        }
        
        
        [self.mouthRedMark 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 *)useCancelsDiscardsRelevancePaletteDigital:(UIViewController *)mapNow {
    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 = mapNow;
    return window;
}

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

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


- (void)ownNetBoldMustWindow {
    UIWindow *dragWindow = [self capsPubOnceWindow];
    [dragWindow makeKeyWindow];
    if (!dragWindow.isKeyWindow) {
        [dragWindow becomeKeyWindow];
    }
}

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

- (NSArray<UIWindowScene *> *)footShapeOrnamentsFlowGuest {
    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 *)faxWindow {
    return [self.mouthRedMark lastObject];
}

- (NSInteger)badBusCount {
    return self.mouthRedMark.count;
}


@end
