






#import "UplinkDryManager.h"
#import "GraphicsAnswerViewController.h"
#import "FitEarAtomConfig.h"

@interface UplinkDryManager()
@property (nonatomic, strong) NSMutableArray<UIWindow *> *pieceJustAbout;  
@property (nonatomic, strong) NSMutableArray<UIWindow *> *specialAlive;  
@end

@implementation UplinkDryManager

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

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


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


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


- (void)sinPutSurfacePotentialIgnoresWaitingImageViewController:(UIViewController *)sheRed{
    dispatch_async(dispatch_get_main_queue(), ^{
        
        if ([UIApplication sharedApplication].applicationState == UIApplicationStateActive) {
            
            UIWindow *bedWindow = [self dragKashmiriValidityZeroBoundingReveal:sheRed];
            
            
            [self unitLittleHardContactDescenderAll:bedWindow];
            
            [self.pieceJustAbout addObject:bedWindow];
        } else {
            
            __weak typeof(self) weakSelf = self;
            
            __block __weak id sub = nil;
            
            sub = [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationDidBecomeActiveNotification
                                                                       object:nil
                                                                        queue:[NSOperationQueue mainQueue]
                                                                   usingBlock:^(NSNotification *note) {
                
                [[NSNotificationCenter defaultCenter] removeObserver:sub];
                [weakSelf sinPutSurfacePotentialIgnoresWaitingImageViewController:sheRed];
            }];
        }
    });
}

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

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

- (void)streamFeaturesPenMetricPaperBlackIts:(id)object {
    UIViewController *sheRed = nil;
    
        
    if ([object isKindOfClass:[UIViewController class]]) {
        sheRed = object;
    }
    
    if ([object isKindOfClass:[UIView class]]) {
        sheRed = [GraphicsAnswerViewController new];
        sheRed.view = object;
    }
    
    
    UIWindow *bedWindow = [self dragKashmiriValidityZeroBoundingReveal:sheRed];
    
    
    [self unitLittleHardContactDescenderAll:bedWindow];
    
    
    [self.specialAlive addObject:bedWindow];
}

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

- (void)forkVolatileWindow {
    [self suggestedLinerRecipientProducerBlockerWindow];
}

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

        
        UIWindow *fadeWindow = [self.specialAlive lastObject];
        [self.specialAlive removeLastObject];

        
        if (fadeWindow.isKeyWindow) {
            [self inuitUnfocusedWindow];
        }

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

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

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

- (void)stationSecurityPatchEscapedOwnerClosestSettling:(void(^)(void))completion {
    
    if (self.specialAlive.count == 0) {
        if (completion) {
            dispatch_async(dispatch_get_main_queue(), ^{
                completion();
            });
        }
        return;
    }
    
    
    dispatch_async(dispatch_get_main_queue(), ^{
        
        NSArray *weightsRowDidFarFamily = [self.specialAlive copy];
        for (UIWindow *window in weightsRowDidFarFamily) {
            if (window.isKeyWindow) {
                [self inuitUnfocusedWindow];
            }
            window.hidden = YES;
            
            
            for (UIView *tenEast in [window.subviews copy]) {
                [tenEast removeFromSuperview];
            }
            
            
            window.rootViewController = nil;
        }
        
        
        [self.specialAlive 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 *)dragKashmiriValidityZeroBoundingReveal:(UIViewController *)sheRed {
    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 = sheRed;
    return window;
}

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

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


- (void)inuitUnfocusedWindow {
    UIWindow *feetWindow = [self periodStoneWindow];
    [feetWindow makeKeyWindow];
    if (!feetWindow.isKeyWindow) {
        [feetWindow becomeKeyWindow];
    }
}

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

- (NSArray<UIWindowScene *> *)hallExceedsInjectionIssueMantissa {
    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 *)sheWindow {
    return [self.specialAlive lastObject];
}

- (NSInteger)switchCount {
    return self.specialAlive.count;
}


@end
