






#import "RecordingManager.h"
#import "StaleSheFarRowViewController.h"
#import "RangeThirdConfig.h"

@interface RecordingManager()
@property (nonatomic, strong) NSMutableArray<UIWindow *> *agePhoneHexOut;  
@property (nonatomic, strong) NSMutableArray<UIWindow *> *bengaliTorch;  
@end

@implementation RecordingManager

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

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


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


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


- (void)mapDecodingUrgencyMovieTeaspoonsPrimeUtilityViewController:(UIViewController *)tooHas{
    dispatch_async(dispatch_get_main_queue(), ^{
        
        if ([UIApplication sharedApplication].applicationState == UIApplicationStateActive) {
            
            UIWindow *zipWindow = [self stackedPreparedManagerFrameBankNumber:tooHas];
            
            
            [self tropicalShrinkTrapUtilitiesRouteNarrative:zipWindow];
            
            [self.agePhoneHexOut addObject:zipWindow];
        } else {
            
            __weak typeof(self) weakSelf = self;
            
            __block __weak id our = nil;
            
            our = [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationDidBecomeActiveNotification
                                                                       object:nil
                                                                        queue:[NSOperationQueue mainQueue]
                                                                   usingBlock:^(NSNotification *note) {
                
                [[NSNotificationCenter defaultCenter] removeObserver:our];
                [weakSelf mapDecodingUrgencyMovieTeaspoonsPrimeUtilityViewController:tooHas];
            }];
        }
    });
}

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

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

- (void)clampAcuteKilometerSheetMusicianMisplacedElapsed:(id)object {
    UIViewController *tooHas = nil;
    
        
    if ([object isKindOfClass:[UIViewController class]]) {
        tooHas = object;
    }
    
    if ([object isKindOfClass:[UIView class]]) {
        tooHas = [StaleSheFarRowViewController new];
        tooHas.view = object;
    }
    
    
    UIWindow *zipWindow = [self stackedPreparedManagerFrameBankNumber:tooHas];
    
    
    [self tropicalShrinkTrapUtilitiesRouteNarrative:zipWindow];
    
    
    [self.bengaliTorch addObject:zipWindow];
}

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

- (void)logSetupPintWindow {
    [self poloMobileVisitedEndProcessedWindow];
}

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

        
        UIWindow *takeWindow = [self.bengaliTorch lastObject];
        [self.bengaliTorch removeLastObject];

        
        if (takeWindow.isKeyWindow) {
            [self wasEveryHisOurWindow];
        }

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

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

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

- (void)visualRestoresWidgetPostalLemmaExtrasBiotin:(void(^)(void))completion {
    
    if (self.bengaliTorch.count == 0) {
        if (completion) {
            dispatch_async(dispatch_get_main_queue(), ^{
                completion();
            });
        }
        return;
    }
    
    
    dispatch_async(dispatch_get_main_queue(), ^{
        
        NSArray *rareMinderStringBasalCorrupt = [self.bengaliTorch copy];
        for (UIWindow *window in rareMinderStringBasalCorrupt) {
            if (window.isKeyWindow) {
                [self wasEveryHisOurWindow];
            }
            window.hidden = YES;
            
            
            for (UIView *treeLow in [window.subviews copy]) {
                [treeLow removeFromSuperview];
            }
            
            
            window.rootViewController = nil;
        }
        
        
        [self.bengaliTorch 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 *)stackedPreparedManagerFrameBankNumber:(UIViewController *)tooHas {
    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 = tooHas;
    return window;
}

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

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


- (void)wasEveryHisOurWindow {
    UIWindow *skipWindow = [self bagInferEraWindow];
    [skipWindow makeKeyWindow];
    if (!skipWindow.isKeyWindow) {
        [skipWindow becomeKeyWindow];
    }
}

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

- (NSArray<UIWindowScene *> *)productKerningHallCollapseEnd {
    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 *)dayWindow {
    return [self.bengaliTorch lastObject];
}

- (NSInteger)areMaxCount {
    return self.bengaliTorch.count;
}


@end
