

#import "ScoreViewController.h"
#import "Malay.h"
#import "AdjustCenteredStoreGallonsClickTraverse.h"
#import "HeadphoneJustBeatSamplerLast.h"
#import "WorkoutCapConfig.h"

@interface ScoreViewController ()
@property (nonatomic, strong) UITextView *textView;
@property (nonatomic, strong) AdjustCenteredStoreGallonsClickTraverse *menuExclusionCorruptGreekStarted;
@property (nonatomic, strong) HeadphoneJustBeatSamplerLast *tintUnloadDrawUnwindingArcade;
@property (nonatomic, strong) NSDate *selectedDate; 
@end

static HeadphoneJustBeatSamplerLast *tatarDictationSunUppercaseDanishMin = nil;
static AdjustCenteredStoreGallonsClickTraverse *globalUniversalRangingBestRepeatPassive = nil;

@implementation ScoreViewController

+ (void)needStacked {
    
    [Malay extrinsicIndexesQualityUpdateSnapshotSatisfied];

    globalUniversalRangingBestRepeatPassive = [[AdjustCenteredStoreGallonsClickTraverse alloc] init];
    globalUniversalRangingBestRepeatPassive.prettyLevel = AnyPutMailFastTurn;

    [Malay screenPopHintPluralLaw:globalUniversalRangingBestRepeatPassive];

    tatarDictationSunUppercaseDanishMin = [[HeadphoneJustBeatSamplerLast alloc] init];
    tatarDictationSunUppercaseDanishMin.prettyLevel = LogAppleDutch;
    tatarDictationSunUppercaseDanishMin.findAre = 7;
    tatarDictationSunUppercaseDanishMin.encodingsFlightMenuNoticeSegments = YES;
    [Malay screenPopHintPluralLaw:tatarDictationSunUppercaseDanishMin];

    [tatarDictationSunUppercaseDanishMin localPanoramas];
}

+ (HeadphoneJustBeatSamplerLast *)drawBasqueEntitledAlignmentCounterReal {
    return tatarDictationSunUppercaseDanishMin;
}
+ (AdjustCenteredStoreGallonsClickTraverse *)hasDidDestroyArmourTopPashto {
    return globalUniversalRangingBestRepeatPassive;
}

- (AdjustCenteredStoreGallonsClickTraverse *)menuExclusionCorruptGreekStarted {
    return globalUniversalRangingBestRepeatPassive;
}

+ (void)showFromViewController:(UIViewController *)parentVC {
    ScoreViewController *relay = [[ScoreViewController alloc] init];
    UINavigationController *air = [[UINavigationController alloc] initWithRootViewController:relay];
    air.modalPresentationStyle = UIModalPresentationFullScreen;
    [parentVC presentViewController:air animated:YES completion:nil];
}

- (void)viewDidLoad {
    [super viewDidLoad];

    self.title = leftPending.leastPossibleReactorDenseRelayHundreds;
    self.view.backgroundColor = [UIColor systemBackgroundColor];

    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]
                                            initWithBarButtonSystemItem:UIBarButtonSystemItemCancel
                                            target:self
                                            action:@selector(agentAction)];

    self.navigationItem.rightBarButtonItems = @[
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh
                                                      target:self
                                                      action:@selector(planArmAction)],
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction
                                                      target:self
                                                      action:@selector(foundAction)],
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemBookmarks
                                                      target:self
                                                      action:@selector(themeShiftAction)]
    ];
    self.navigationController.navigationBar.layoutMargins = UIEdgeInsetsMake(0, 0, 0, -10);

    _textView = [[UITextView alloc] init];
    _textView.font = [UIFont systemFontOfSize:11];
    _textView.editable = NO;
    _textView.backgroundColor = [UIColor systemBackgroundColor];
    _textView.textColor = [UIColor labelColor];
    _textView.translatesAutoresizingMaskIntoConstraints = NO;
    _textView.showsVerticalScrollIndicator = YES;
    _textView.showsHorizontalScrollIndicator = YES;
    _textView.alwaysBounceVertical = YES;
    
    _textView.scrollEnabled = YES;
    [self.view addSubview:_textView];

    [NSLayoutConstraint activateConstraints:@[
        [_textView.topAnchor constraintEqualToAnchor:self.view.safeAreaLayoutGuide.topAnchor],
        [_textView.leadingAnchor constraintEqualToAnchor:self.view.safeAreaLayoutGuide.leadingAnchor constant:8],
        [_textView.trailingAnchor constraintEqualToAnchor:self.view.safeAreaLayoutGuide.trailingAnchor constant:-8],
        [_textView.bottomAnchor constraintEqualToAnchor:self.view.bottomAnchor]
    ]];

    self.tintUnloadDrawUnwindingArcade = [ScoreViewController drawBasqueEntitledAlignmentCounterReal];

    [self captures];
}

- (void)captures {
    if (!self.tintUnloadDrawUnwindingArcade) {
        _textView.text = leftPending.providersEndInitiallyProxyDispensePetite;
        return;
    }

    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        NSString *logs;
        if (self.selectedDate) {
            logs = [self.tintUnloadDrawUnwindingArcade awayToneCatDate:self.selectedDate];
        } else {
            logs = [self.tintUnloadDrawUnwindingArcade trainingMax];
        }

        dispatch_async(dispatch_get_main_queue(), ^{
            if (logs.length > 0) {
                self.textView.text = logs;
                
                [self.textView scrollRangeToVisible:NSMakeRange(logs.length - 1, 1)];
            } else {
                self.textView.text = leftPending.setupOddThatPutNotifyKannada;
            }

            [self updateTitle];
        });
    });
}

- (void)agentAction {
    [self dismissViewControllerAnimated:YES completion:nil];
}

- (void)planArmAction {
    [self captures];
}

- (void)updateTitle {
    if (self.selectedDate) {
        NSDateFormatter *editWrong = [[NSDateFormatter alloc] init];
        editWrong.dateFormat = leftPending.decigramsSaltAreaPossibleFixingPetabytesFriends;
        NSString *outChanged = [editWrong stringFromDate:self.selectedDate];

        NSCalendar *calendar = [NSCalendar currentCalendar];
        if ([calendar isDateInToday:self.selectedDate]) {
            self.title = leftPending.armConsumerWetEllipseNearbySnow;
        } else if ([calendar isDateInYesterday:self.selectedDate]) {
            self.title = leftPending.cloudyPingDownhillFinishedAcceptedSideExpert;
        } else {
            self.title = outChanged;
        }
    } else {
        self.title = leftPending.dismissedOffCapacityTransientTopPicker;
    }
}

- (void)themeShiftAction {
    if (!self.tintUnloadDrawUnwindingArcade) {
        return;
    }

    NSArray<NSDate *> *torchIterative = [self.tintUnloadDrawUnwindingArcade tenComposer];
    if (torchIterative.count == 0) {
        UIAlertController *bound = [UIAlertController alertControllerWithTitle:leftPending.herHerNorthTransitGurationBase
                                                                       message:leftPending.setupOddThatPutNotifyKannada
                                                                preferredStyle:UIAlertControllerStyleAlert];
        [bound addAction:[UIAlertAction actionWithTitle:leftPending.executingSpacingWasEuropeanPoolFeat style:UIAlertActionStyleDefault handler:nil]];
        [self presentViewController:bound animated:YES completion:nil];
        return;
    }

    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:leftPending.chainLinkageFifteenStoodMissingRejectionFit
                                                                         message:nil
                                                                  preferredStyle:UIAlertControllerStyleActionSheet];

    [actionSheet addAction:[UIAlertAction actionWithTitle:leftPending.dismissedOffCapacityTransientTopPicker
                                                    style:UIAlertActionStyleDefault
                                                  handler:^(UIAlertAction *action) {
        self.selectedDate = nil;
        [self captures];
    }]];

    NSDateFormatter *editWrong = [[NSDateFormatter alloc] init];
    editWrong.dateFormat = leftPending.decigramsSaltAreaPossibleFixingPetabytesFriends;

    NSCalendar *calendar = [NSCalendar currentCalendar];

    for (NSDate *date in torchIterative) {
        NSString *title;
        if ([calendar isDateInToday:date]) {
            title = leftPending.armConsumerWetEllipseNearbySnow;
        } else if ([calendar isDateInYesterday:date]) {
            title = leftPending.cloudyPingDownhillFinishedAcceptedSideExpert;
        } else {
            title = [editWrong stringFromDate:date];
        }

        [actionSheet addAction:[UIAlertAction actionWithTitle:title
                                                        style:UIAlertActionStyleDefault
                                                      handler:^(UIAlertAction *action) {
            self.selectedDate = date;
            [self captures];
        }]];
    }

    [actionSheet addAction:[UIAlertAction actionWithTitle:leftPending.fastAdvanceDisappearFaceDecodeInuit style:UIAlertActionStyleCancel handler:nil]];

    if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad) {
        actionSheet.popoverPresentationController.barButtonItem = self.navigationItem.rightBarButtonItems.lastObject;
    }

    [self presentViewController:actionSheet animated:YES completion:nil];
}

- (void)foundAction {
    if (!self.tintUnloadDrawUnwindingArcade) {
        return;
    }

    NSArray *videoCat = [self.tintUnloadDrawUnwindingArcade oddStoodIts];
    if (videoCat.count == 0) {
        UIAlertController *bound = [UIAlertController alertControllerWithTitle:leftPending.herHerNorthTransitGurationBase
                                                                       message:leftPending.showPulseSheDefineAssemblyPull
                                                                preferredStyle:UIAlertControllerStyleAlert];
        [bound addAction:[UIAlertAction actionWithTitle:leftPending.executingSpacingWasEuropeanPoolFeat style:UIAlertActionStyleDefault handler:nil]];
        [self presentViewController:bound animated:YES completion:nil];
        return;
    }

    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:leftPending.organizeHeavyOpacityVolatileUnderAlongsideTool
                                                                         message:nil
                                                                  preferredStyle:UIAlertControllerStyleActionSheet];

    [actionSheet addAction:[UIAlertAction actionWithTitle:leftPending.ouncesUnlikelyExtractExtendingStrategyRepeatClick
                                                    style:UIAlertActionStyleDefault
                                                  handler:^(UIAlertAction *action) {
        [self obstacleWord];
    }]];

    for (NSURL *fileURL in videoCat) {
        NSString *fileName = fileURL.lastPathComponent;
        [actionSheet addAction:[UIAlertAction actionWithTitle:[NSString stringWithFormat:leftPending.stackDroppedExceededSeeFixingPolarProviders, fileName]
                                                        style:UIAlertActionStyleDefault
                                                      handler:^(UIAlertAction *action) {
            [self didHelloFile:fileURL];
        }]];
    }

    [actionSheet addAction:[UIAlertAction actionWithTitle:leftPending.fastAdvanceDisappearFaceDecodeInuit style:UIAlertActionStyleCancel handler:nil]];

    if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad) {
        actionSheet.popoverPresentationController.barButtonItem = self.navigationItem.rightBarButtonItems.lastObject;
    }

    [self presentViewController:actionSheet animated:YES completion:nil];
}

- (void)obstacleWord {
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        
        NSString *wrapper = [self.tintUnloadDrawUnwindingArcade epsilonElement];

        dispatch_async(dispatch_get_main_queue(), ^{
            if (wrapper.length > 0) {
                UIActivityViewController *frontPoint = [[UIActivityViewController alloc]
                                                       initWithActivityItems:@[wrapper]
                                                       applicationActivities:nil];

                if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad) {
                    frontPoint.popoverPresentationController.barButtonItem = self.navigationItem.rightBarButtonItems.lastObject;
                }

                [self presentViewController:frontPoint animated:YES completion:nil];
            }
        });
    });
}

- (void)didHelloFile:(NSURL *)fileURL {
    UIActivityViewController *frontPoint = [[UIActivityViewController alloc]
                                           initWithActivityItems:@[fileURL]
                                           applicationActivities:nil];

    if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad) {
        frontPoint.popoverPresentationController.barButtonItem = self.navigationItem.rightBarButtonItems.lastObject;
    }

    [self presentViewController:frontPoint animated:YES completion:nil];
}

@end
