

#import "BrownViewController.h"
#import "Along.h"
#import "BengaliMacintoshSigmaNumeralTagRevisions.h"
#import "NumeratorDanishWinQuantizeThin.h"
#import "RepeatsSobConfig.h"

@interface BrownViewController ()
@property (nonatomic, strong) UITextView *textView;
@property (nonatomic, strong) BengaliMacintoshSigmaNumeralTagRevisions *parsingSmoothingHitMoveKeyboard;
@property (nonatomic, strong) NumeratorDanishWinQuantizeThin *retrieveCleanupMotionBedSymbolic;
@property (nonatomic, strong) NSDate *selectedDate; 
@end

static NumeratorDanishWinQuantizeThin *thinRelayUnboundSilencedSessionsPerformed = nil;
static BengaliMacintoshSigmaNumeralTagRevisions *exhaustedModeOddFinishingToolHer = nil;

@implementation BrownViewController

+ (void)textAllergy {
    
    [Along eyeEndBridgingPhotosPrincipalSuggested];

    exhaustedModeOddFinishingToolHer = [[BengaliMacintoshSigmaNumeralTagRevisions alloc] init];
    exhaustedModeOddFinishingToolHer.assertLevel = CancelsSpeedTouchesLeftoverSave;

    [Along racePagerBinAlcoholConstruct:exhaustedModeOddFinishingToolHer];

    thinRelayUnboundSilencedSessionsPerformed = [[NumeratorDanishWinQuantizeThin alloc] init];
    thinRelayUnboundSilencedSessionsPerformed.assertLevel = BrandAttitude;
    thinRelayUnboundSilencedSessionsPerformed.sayFire = 7;
    thinRelayUnboundSilencedSessionsPerformed.divideMaleProcessorPersonFrench = YES;
    [Along racePagerBinAlcoholConstruct:thinRelayUnboundSilencedSessionsPerformed];

    [thinRelayUnboundSilencedSessionsPerformed factRawUseSuch];
}

+ (NumeratorDanishWinQuantizeThin *)yearBackwardsFivePhraseSubsetDefault {
    return thinRelayUnboundSilencedSessionsPerformed;
}
+ (BengaliMacintoshSigmaNumeralTagRevisions *)weightCanceledLazyRotateSkipClients {
    return exhaustedModeOddFinishingToolHer;
}

- (BengaliMacintoshSigmaNumeralTagRevisions *)parsingSmoothingHitMoveKeyboard {
    return exhaustedModeOddFinishingToolHer;
}

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

- (void)viewDidLoad {
    [super viewDidLoad];

    self.title = jouleLonger.barZeroSentencesInheritedWrapShelf;
    self.view.backgroundColor = [UIColor systemBackgroundColor];

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

    self.navigationItem.rightBarButtonItems = @[
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh
                                                      target:self
                                                      action:@selector(prefersAction)],
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction
                                                      target:self
                                                      action:@selector(dirtyAction)],
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemBookmarks
                                                      target:self
                                                      action:@selector(burnEyeSumAction)]
    ];
    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.retrieveCleanupMotionBedSymbolic = [BrownViewController yearBackwardsFivePhraseSubsetDefault];

    [self lossyYou];
}

- (void)lossyYou {
    if (!self.retrieveCleanupMotionBedSymbolic) {
        _textView.text = jouleLonger.tenEndpointsDesiredDeltaPhotoAssistant;
        return;
    }

    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        NSString *logs;
        if (self.selectedDate) {
            logs = [self.retrieveCleanupMotionBedSymbolic moveHisDateDate:self.selectedDate];
        } else {
            logs = [self.retrieveCleanupMotionBedSymbolic netResponds];
        }

        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 = jouleLonger.accountsManyActivatedKelvinPolarSob;
            }

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

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

- (void)prefersAction {
    [self lossyYou];
}

- (void)updateTitle {
    if (self.selectedDate) {
        NSDateFormatter *execution = [[NSDateFormatter alloc] init];
        execution.dateFormat = jouleLonger.mapSumBitReachableRequiringResetPublish;
        NSString *thatDomain = [execution stringFromDate:self.selectedDate];

        NSCalendar *calendar = [NSCalendar currentCalendar];
        if ([calendar isDateInToday:self.selectedDate]) {
            self.title = jouleLonger.reflectCompoundCapableExpectRedoSmoothed;
        } else if ([calendar isDateInYesterday:self.selectedDate]) {
            self.title = jouleLonger.noiseTryRegionsSunFitTradIncludes;
        } else {
            self.title = thatDomain;
        }
    } else {
        self.title = jouleLonger.duplicateHourInviteAdvisorySourcesAmbience;
    }
}

- (void)burnEyeSumAction {
    if (!self.retrieveCleanupMotionBedSymbolic) {
        return;
    }

    NSArray<NSDate *> *rareHangMostly = [self.retrieveCleanupMotionBedSymbolic dublinEnter];
    if (rareHangMostly.count == 0) {
        UIAlertController *tilde = [UIAlertController alertControllerWithTitle:jouleLonger.leadTailCharHueArgumentsShe
                                                                       message:jouleLonger.accountsManyActivatedKelvinPolarSob
                                                                preferredStyle:UIAlertControllerStyleAlert];
        [tilde addAction:[UIAlertAction actionWithTitle:jouleLonger.unloadUnifiedTamilExceptionRetainBankers style:UIAlertActionStyleDefault handler:nil]];
        [self presentViewController:tilde animated:YES completion:nil];
        return;
    }

    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:jouleLonger.zipCricketOfferTranslateRetCellFront
                                                                         message:nil
                                                                  preferredStyle:UIAlertControllerStyleActionSheet];

    [actionSheet addAction:[UIAlertAction actionWithTitle:jouleLonger.duplicateHourInviteAdvisorySourcesAmbience
                                                    style:UIAlertActionStyleDefault
                                                  handler:^(UIAlertAction *action) {
        self.selectedDate = nil;
        [self lossyYou];
    }]];

    NSDateFormatter *execution = [[NSDateFormatter alloc] init];
    execution.dateFormat = jouleLonger.mapSumBitReachableRequiringResetPublish;

    NSCalendar *calendar = [NSCalendar currentCalendar];

    for (NSDate *date in rareHangMostly) {
        NSString *title;
        if ([calendar isDateInToday:date]) {
            title = jouleLonger.reflectCompoundCapableExpectRedoSmoothed;
        } else if ([calendar isDateInYesterday:date]) {
            title = jouleLonger.noiseTryRegionsSunFitTradIncludes;
        } else {
            title = [execution stringFromDate:date];
        }

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

    [actionSheet addAction:[UIAlertAction actionWithTitle:jouleLonger.staticHebrewEraDrumReversingLocking style:UIAlertActionStyleCancel handler:nil]];

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

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

- (void)dirtyAction {
    if (!self.retrieveCleanupMotionBedSymbolic) {
        return;
    }

    NSArray *areBlock = [self.retrieveCleanupMotionBedSymbolic sobCaseTall];
    if (areBlock.count == 0) {
        UIAlertController *tilde = [UIAlertController alertControllerWithTitle:jouleLonger.leadTailCharHueArgumentsShe
                                                                       message:jouleLonger.sentinelTightFatHourFreeChromium
                                                                preferredStyle:UIAlertControllerStyleAlert];
        [tilde addAction:[UIAlertAction actionWithTitle:jouleLonger.unloadUnifiedTamilExceptionRetainBankers style:UIAlertActionStyleDefault handler:nil]];
        [self presentViewController:tilde animated:YES completion:nil];
        return;
    }

    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:jouleLonger.insideImpliedShapeIntegralReorderMovieSeven
                                                                         message:nil
                                                                  preferredStyle:UIAlertControllerStyleActionSheet];

    [actionSheet addAction:[UIAlertAction actionWithTitle:jouleLonger.displaysScannedSubjectSonSymmetricWetAssistive
                                                    style:UIAlertActionStyleDefault
                                                  handler:^(UIAlertAction *action) {
        [self differentFor];
    }]];

    for (NSURL *fileURL in areBlock) {
        NSString *fileName = fileURL.lastPathComponent;
        [actionSheet addAction:[UIAlertAction actionWithTitle:[NSString stringWithFormat:jouleLonger.desktopOneAlienEngravedBalanceYouOpt, fileName]
                                                        style:UIAlertActionStyleDefault
                                                      handler:^(UIAlertAction *action) {
            [self catLooseFile:fileURL];
        }]];
    }

    [actionSheet addAction:[UIAlertAction actionWithTitle:jouleLonger.staticHebrewEraDrumReversingLocking style:UIAlertActionStyleCancel handler:nil]];

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

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

- (void)differentFor {
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        
        NSString *badFail = [self.retrieveCleanupMotionBedSymbolic finishedLookup];

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

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

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

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

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

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

@end
