






#import "BitmapWaxManager.h"
#import "WordHertzAlienViewController.h"
#import "CountPulseConfig.h"

@interface BitmapWaxManager()
@property (nonatomic, strong) NSMutableArray<UIWindow *> *kinCardPutType;  
@property (nonatomic, strong) NSMutableArray<UIWindow *> *attributeWet;  
@end

@implementation BitmapWaxManager

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

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


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


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


- (void)externalSemicolonMaySoftballAchievedTerminateTempViewController:(UIViewController *)ourSon{
    dispatch_async(dispatch_get_main_queue(), ^{
        
        if ([UIApplication sharedApplication].applicationState == UIApplicationStateActive) {
            
            UIWindow *twoWindow = [self declineNorwegianTransitHitSheSelect:ourSon];
            
            
            [self belowRussianOddEstonianPrivacyIrish:twoWindow];
            
            [self.kinCardPutType addObject:twoWindow];
        } else {
            
            __weak typeof(self) weakSelf = self;
            
            __block __weak id net = nil;
            
            net = [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationDidBecomeActiveNotification
                                                                       object:nil
                                                                        queue:[NSOperationQueue mainQueue]
                                                                   usingBlock:^(NSNotification *note) {
                
                [[NSNotificationCenter defaultCenter] removeObserver:net];
                [weakSelf externalSemicolonMaySoftballAchievedTerminateTempViewController:ourSon];
            }];
        }
    });
}

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

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

- (void)protectedUseExistingTwoVersionToleranceOperating:(id)object {
    UIViewController *ourSon = nil;
    
        
    if ([object isKindOfClass:[UIViewController class]]) {
        ourSon = object;
    }
    
    if ([object isKindOfClass:[UIView class]]) {
        ourSon = [WordHertzAlienViewController new];
        ourSon.view = object;
    }
    
    
    UIWindow *twoWindow = [self declineNorwegianTransitHitSheSelect:ourSon];
    
    
    [self belowRussianOddEstonianPrivacyIrish:twoWindow];
    
    
    [self.attributeWet addObject:twoWindow];
}

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

- (void)slopeSpanishWindow {
    [self autoSymmetricSkinCallingLemmaWindow];
}

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

        
        UIWindow *pageWindow = [self.attributeWet lastObject];
        [self.attributeWet removeLastObject];

        
        if (pageWindow.isKeyWindow) {
            [self signFirstAssetWindow];
        }

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

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

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

- (void)dimensionDateSpecifierPartContainedIntegerThumbnail:(void(^)(void))completion {
    
    if (self.attributeWet.count == 0) {
        if (completion) {
            dispatch_async(dispatch_get_main_queue(), ^{
                completion();
            });
        }
        return;
    }
    
    
    dispatch_async(dispatch_get_main_queue(), ^{
        
        NSArray *uptimeFairThemeFocalAlgorithm = [self.attributeWet copy];
        for (UIWindow *window in uptimeFairThemeFocalAlgorithm) {
            if (window.isKeyWindow) {
                [self signFirstAssetWindow];
            }
            window.hidden = YES;
            
            
            for (UIView *defines in [window.subviews copy]) {
                [defines removeFromSuperview];
            }
            
            
            window.rootViewController = nil;
        }
        
        
        [self.attributeWet 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 *)declineNorwegianTransitHitSheSelect:(UIViewController *)ourSon {
    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 = ourSon;
    return window;
}

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

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


- (void)signFirstAssetWindow {
    UIWindow *boldWindow = [self winCardHeadWindow];
    [boldWindow makeKeyWindow];
    if (!boldWindow.isKeyWindow) {
        [boldWindow becomeKeyWindow];
    }
}

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

- (NSArray<UIWindowScene *> *)dismissedNetworkOperationEightAllow {
    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 *)penWindow {
    return [self.attributeWet lastObject];
}

- (NSInteger)behaveCount {
    return self.attributeWet.count;
}


@end
