






#import "KeysVoiceManager.h"
#import "FormatNextBurnViewController.h"
#import "RedoTabFarConfig.h"

@interface KeysVoiceManager()
@property (nonatomic, strong) NSMutableArray<UIWindow *> *goalStaticList;  
@property (nonatomic, strong) NSMutableArray<UIWindow *> *hairEjectOut;  
@end

@implementation KeysVoiceManager

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

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


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


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


- (void)rareCellFollowBinaryFaeroeseFisheyeAudiencesViewController:(UIViewController *)mayThe{
    dispatch_async(dispatch_get_main_queue(), ^{
        
        if ([UIApplication sharedApplication].applicationState == UIApplicationStateActive) {
            
            UIWindow *sumWindow = [self rateSeedSparseAffineAssertionIts:mayThe];
            
            
            [self hectaresRouterLastDrainSlantOwn:sumWindow];
            
            [self.goalStaticList addObject:sumWindow];
        } else {
            
            __weak typeof(self) weakSelf = self;
            
            __block __weak id car = nil;
            
            car = [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationDidBecomeActiveNotification
                                                                       object:nil
                                                                        queue:[NSOperationQueue mainQueue]
                                                                   usingBlock:^(NSNotification *note) {
                
                [[NSNotificationCenter defaultCenter] removeObserver:car];
                [weakSelf rareCellFollowBinaryFaeroeseFisheyeAudiencesViewController:mayThe];
            }];
        }
    });
}

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

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

- (void)alongRestartListenStillOuterAudiencesRoot:(id)object {
    UIViewController *mayThe = nil;
    
        
    if ([object isKindOfClass:[UIViewController class]]) {
        mayThe = object;
    }
    
    if ([object isKindOfClass:[UIView class]]) {
        mayThe = [FormatNextBurnViewController new];
        mayThe.view = object;
    }
    
    
    UIWindow *sumWindow = [self rateSeedSparseAffineAssertionIts:mayThe];
    
    
    [self hectaresRouterLastDrainSlantOwn:sumWindow];
    
    
    [self.hairEjectOut addObject:sumWindow];
}

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

- (void)hailTargetedWindow {
    [self beatFisheyeUrgentShearModelWindow];
}

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

        
        UIWindow *tradWindow = [self.hairEjectOut lastObject];
        [self.hairEjectOut removeLastObject];

        
        if (tradWindow.isKeyWindow) {
            [self bufferedHockeyWindow];
        }

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

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

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

- (void)spectralSenseCopyrightClimbedDragRaceCar:(void(^)(void))completion {
    
    if (self.hairEjectOut.count == 0) {
        if (completion) {
            dispatch_async(dispatch_get_main_queue(), ^{
                completion();
            });
        }
        return;
    }
    
    
    dispatch_async(dispatch_get_main_queue(), ^{
        
        NSArray *clockCroatianSliceNowFull = [self.hairEjectOut copy];
        for (UIWindow *window in clockCroatianSliceNowFull) {
            if (window.isKeyWindow) {
                [self bufferedHockeyWindow];
            }
            window.hidden = YES;
            
            
            for (UIView *teamCan in [window.subviews copy]) {
                [teamCan removeFromSuperview];
            }
            
            
            window.rootViewController = nil;
        }
        
        
        [self.hairEjectOut 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 *)rateSeedSparseAffineAssertionIts:(UIViewController *)mayThe {
    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 = mayThe;
    return window;
}

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

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


- (void)bufferedHockeyWindow {
    UIWindow *rateWindow = [self menCurlSinkWindow];
    [rateWindow makeKeyWindow];
    if (!rateWindow.isKeyWindow) {
        [rateWindow becomeKeyWindow];
    }
}

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

- (NSArray<UIWindowScene *> *)sayOverwriteClangOurWrap {
    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 *)fitWindow {
    return [self.hairEjectOut lastObject];
}

- (NSInteger)sexPinCount {
    return self.hairEjectOut.count;
}


@end
