






#import "UploadWhoManager.h"
#import "SunDayRedRenewViewController.h"
#import "SubmitWireConfig.h"

@interface UploadWhoManager()
@property (nonatomic, strong) NSMutableArray<UIWindow *> *editTeethMolar;  
@property (nonatomic, strong) NSMutableArray<UIWindow *> *popCatDialog;  
@end

@implementation UploadWhoManager

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

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


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


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


- (void)dueIncludingTheDrivenThickTailPutViewController:(UIViewController *)online{
    dispatch_async(dispatch_get_main_queue(), ^{
        
        if ([UIApplication sharedApplication].applicationState == UIApplicationStateActive) {
            
            UIWindow *wetWindow = [self formLogInferAltitudeBezelNegative:online];
            
            
            [self patientHusbandPanArbiterSixVelocity:wetWindow];
            
            [self.editTeethMolar addObject:wetWindow];
        } else {
            
            __weak typeof(self) weakSelf = self;
            
            __block __weak id dry = nil;
            
            dry = [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationDidBecomeActiveNotification
                                                                       object:nil
                                                                        queue:[NSOperationQueue mainQueue]
                                                                   usingBlock:^(NSNotification *note) {
                
                [[NSNotificationCenter defaultCenter] removeObserver:dry];
                [weakSelf dueIncludingTheDrivenThickTailPutViewController:online];
            }];
        }
    });
}

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

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

- (void)kinArtGoalBeginHitExpertLinear:(id)object {
    UIViewController *online = nil;
    
        
    if ([object isKindOfClass:[UIViewController class]]) {
        online = object;
    }
    
    if ([object isKindOfClass:[UIView class]]) {
        online = [SunDayRedRenewViewController new];
        online.view = object;
    }
    
    
    UIWindow *wetWindow = [self formLogInferAltitudeBezelNegative:online];
    
    
    [self patientHusbandPanArbiterSixVelocity:wetWindow];
    
    
    [self.popCatDialog addObject:wetWindow];
}

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

- (void)windowMayCapWindow {
    [self symptomStepperFixRevokedBufferingWindow];
}

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

        
        UIWindow *listWindow = [self.popCatDialog lastObject];
        [self.popCatDialog removeLastObject];

        
        if (listWindow.isKeyWindow) {
            [self cellTightStillWindow];
        }

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

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

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

- (void)enhancedFarWaxEachCervicalCinematicEdge:(void(^)(void))completion {
    
    if (self.popCatDialog.count == 0) {
        if (completion) {
            dispatch_async(dispatch_get_main_queue(), ^{
                completion();
            });
        }
        return;
    }
    
    
    dispatch_async(dispatch_get_main_queue(), ^{
        
        NSArray *hailVectorCocoaStarScroll = [self.popCatDialog copy];
        for (UIWindow *window in hailVectorCocoaStarScroll) {
            if (window.isKeyWindow) {
                [self cellTightStillWindow];
            }
            window.hidden = YES;
            
            
            for (UIView *whoBody in [window.subviews copy]) {
                [whoBody removeFromSuperview];
            }
            
            
            window.rootViewController = nil;
        }
        
        
        [self.popCatDialog 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 *)formLogInferAltitudeBezelNegative:(UIViewController *)online {
    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 = online;
    return window;
}

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

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


- (void)cellTightStillWindow {
    UIWindow *flagWindow = [self canSeparateWindow];
    [flagWindow makeKeyWindow];
    if (!flagWindow.isKeyWindow) {
        [flagWindow becomeKeyWindow];
    }
}

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

- (NSArray<UIWindowScene *> *)hueRequestInfoYearsModify {
    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 *)minWindow {
    return [self.popCatDialog lastObject];
}

- (NSInteger)peopleCount {
    return self.popCatDialog.count;
}


@end
