






#import "ResetCurlManager.h"
#import "BrownInputThatViewController.h"
#import "ItsBankersConfig.h"

@interface ResetCurlManager()
@property (nonatomic, strong) NSMutableArray<UIWindow *> *keysFrenchZero;  
@property (nonatomic, strong) NSMutableArray<UIWindow *> *reuseRetried;  
@end

@implementation ResetCurlManager

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

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


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


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


- (void)manyFoggyKeyboardTopBookBloodSinViewController:(UIViewController *)itsOut{
    dispatch_async(dispatch_get_main_queue(), ^{
        
        if ([UIApplication sharedApplication].applicationState == UIApplicationStateActive) {
            
            UIWindow *cutWindow = [self rangeCurveImplicitDiscardsSchedulerSignature:itsOut];
            
            
            [self oceanObserversAuditDragSubMay:cutWindow];
            
            [self.keysFrenchZero addObject:cutWindow];
        } else {
            
            __weak typeof(self) weakSelf = self;
            
            __block __weak id egg = nil;
            
            egg = [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationDidBecomeActiveNotification
                                                                       object:nil
                                                                        queue:[NSOperationQueue mainQueue]
                                                                   usingBlock:^(NSNotification *note) {
                
                [[NSNotificationCenter defaultCenter] removeObserver:egg];
                [weakSelf manyFoggyKeyboardTopBookBloodSinViewController:itsOut];
            }];
        }
    });
}

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

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

- (void)tabIdentifyBusDeviationRedirectsCyrillicPrevented:(id)object {
    UIViewController *itsOut = nil;
    
        
    if ([object isKindOfClass:[UIViewController class]]) {
        itsOut = object;
    }
    
    if ([object isKindOfClass:[UIView class]]) {
        itsOut = [BrownInputThatViewController new];
        itsOut.view = object;
    }
    
    
    UIWindow *cutWindow = [self rangeCurveImplicitDiscardsSchedulerSignature:itsOut];
    
    
    [self oceanObserversAuditDragSubMay:cutWindow];
    
    
    [self.reuseRetried addObject:cutWindow];
}

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

- (void)milesLogRedoWindow {
    [self restInstallDisplaySquareTextualWindow];
}

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

        
        UIWindow *plusWindow = [self.reuseRetried lastObject];
        [self.reuseRetried removeLastObject];

        
        if (plusWindow.isKeyWindow) {
            [self mostMeanEffectWindow];
        }

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

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

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

- (void)renewalLargestPushAwakeSmallestTelephonyKannada:(void(^)(void))completion {
    
    if (self.reuseRetried.count == 0) {
        if (completion) {
            dispatch_async(dispatch_get_main_queue(), ^{
                completion();
            });
        }
        return;
    }
    
    
    dispatch_async(dispatch_get_main_queue(), ^{
        
        NSArray *suggestedSheAxesExistentRestored = [self.reuseRetried copy];
        for (UIWindow *window in suggestedSheAxesExistentRestored) {
            if (window.isKeyWindow) {
                [self mostMeanEffectWindow];
            }
            window.hidden = YES;
            
            
            for (UIView *maxNote in [window.subviews copy]) {
                [maxNote removeFromSuperview];
            }
            
            
            window.rootViewController = nil;
        }
        
        
        [self.reuseRetried 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 *)rangeCurveImplicitDiscardsSchedulerSignature:(UIViewController *)itsOut {
    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 = itsOut;
    return window;
}

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

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


- (void)mostMeanEffectWindow {
    UIWindow *fairWindow = [self patchIcyAllWindow];
    [fairWindow makeKeyWindow];
    if (!fairWindow.isKeyWindow) {
        [fairWindow becomeKeyWindow];
    }
}

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

- (NSArray<UIWindowScene *> *)siteAddDetachingTagStrictly {
    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 *)retWindow {
    return [self.reuseRetried lastObject];
}

- (NSInteger)bedEarCount {
    return self.reuseRetried.count;
}


@end
