

#import "DriveViewController.h"
#import "Alpha.h"
#import "FeatFlemishAngularSystolicShakeMember.h"
#import "ViabilityNextRadixCenteringPackage.h"
#import "FadeWaxBinConfig.h"

@interface DriveViewController ()
@property (nonatomic, strong) UITextView *textView;
@property (nonatomic, strong) FeatFlemishAngularSystolicShakeMember *onlyTempIslamicMiterPinch;
@property (nonatomic, strong) ViabilityNextRadixCenteringPackage *factoriesWonRecordSpeakerCalorie;
@property (nonatomic, strong) NSDate *selectedDate; 
@end

static ViabilityNextRadixCenteringPackage *mixTotalNaturalAuditPendingShake = nil;
static FeatFlemishAngularSystolicShakeMember *campaignPutAirReturnedPutSpa = nil;

@implementation DriveViewController

+ (void)fastWarning {
    
    [Alpha toleranceReportsInstallWarpArrivalFreestyle];

    campaignPutAirReturnedPutSpa = [[FeatFlemishAngularSystolicShakeMember alloc] init];
    campaignPutAirReturnedPutSpa.cutGetLevel = GainDeclineTalkMaleSink;

    [Alpha diskArtCommentMetalMatrix:campaignPutAirReturnedPutSpa];

    mixTotalNaturalAuditPendingShake = [[ViabilityNextRadixCenteringPackage alloc] init];
    mixTotalNaturalAuditPendingShake.cutGetLevel = BankPinYetTwo;
    mixTotalNaturalAuditPendingShake.armSink = 7;
    mixTotalNaturalAuditPendingShake.showingCatInsulinBaseLog = YES;
    [Alpha diskArtCommentMetalMatrix:mixTotalNaturalAuditPendingShake];

    [mixTotalNaturalAuditPendingShake bringCountLazy];
}

+ (ViabilityNextRadixCenteringPackage *)stayCountedTouchCommandFloorDivider {
    return mixTotalNaturalAuditPendingShake;
}
+ (FeatFlemishAngularSystolicShakeMember *)greaterExchangesYouForRawDisabled {
    return campaignPutAirReturnedPutSpa;
}

- (FeatFlemishAngularSystolicShakeMember *)onlyTempIslamicMiterPinch {
    return campaignPutAirReturnedPutSpa;
}

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

- (void)viewDidLoad {
    [super viewDidLoad];

    self.title = tapAddition.intervalsRingDarwinReversedNotifiedRandom;
    self.view.backgroundColor = [UIColor systemBackgroundColor];

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

    self.navigationItem.rightBarButtonItems = @[
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh
                                                      target:self
                                                      action:@selector(sayTintAction)],
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction
                                                      target:self
                                                      action:@selector(ejectAction)],
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemBookmarks
                                                      target:self
                                                      action:@selector(visitorBedAction)]
    ];
    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.factoriesWonRecordSpeakerCalorie = [DriveViewController stayCountedTouchCommandFloorDivider];

    [self foldShot];
}

- (void)foldShot {
    if (!self.factoriesWonRecordSpeakerCalorie) {
        _textView.text = tapAddition.pubZoomingMissingNineWalkingRenewing;
        return;
    }

    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        NSString *logs;
        if (self.selectedDate) {
            logs = [self.factoriesWonRecordSpeakerCalorie givenWayCupDate:self.selectedDate];
        } else {
            logs = [self.factoriesWonRecordSpeakerCalorie hairTabular];
        }

        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 = tapAddition.polishCompletedCascadeKoreanSendLost;
            }

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

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

- (void)sayTintAction {
    [self foldShot];
}

- (void)updateTitle {
    if (self.selectedDate) {
        NSDateFormatter *rainThick = [[NSDateFormatter alloc] init];
        rainThick.dateFormat = tapAddition.cutoffFunLatvianNetscapeDuePlacePlane;
        NSString *subsetTeam = [rainThick stringFromDate:self.selectedDate];

        NSCalendar *calendar = [NSCalendar currentCalendar];
        if ([calendar isDateInToday:self.selectedDate]) {
            self.title = tapAddition.pullLayeringTwitterArchivedSeeEach;
        } else if ([calendar isDateInYesterday:self.selectedDate]) {
            self.title = tapAddition.outdoorHindiCarbonAirStaleRadioNumber;
        } else {
            self.title = subsetTeam;
        }
    } else {
        self.title = tapAddition.pubLanguagesAttempterHasDanceInvisible;
    }
}

- (void)visitorBedAction {
    if (!self.factoriesWonRecordSpeakerCalorie) {
        return;
    }

    NSArray<NSDate *> *softFollowAtom = [self.factoriesWonRecordSpeakerCalorie useChecking];
    if (softFollowAtom.count == 0) {
        UIAlertController *dense = [UIAlertController alertControllerWithTitle:tapAddition.ascentCutoffPutLiteralTransitConstant
                                                                       message:tapAddition.polishCompletedCascadeKoreanSendLost
                                                                preferredStyle:UIAlertControllerStyleAlert];
        [dense addAction:[UIAlertAction actionWithTitle:tapAddition.tipDescribeOrnamentBlackHasOrange style:UIAlertActionStyleDefault handler:nil]];
        [self presentViewController:dense animated:YES completion:nil];
        return;
    }

    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:tapAddition.localCollapsesCountryJustResizeStartedCreator
                                                                         message:nil
                                                                  preferredStyle:UIAlertControllerStyleActionSheet];

    [actionSheet addAction:[UIAlertAction actionWithTitle:tapAddition.pubLanguagesAttempterHasDanceInvisible
                                                    style:UIAlertActionStyleDefault
                                                  handler:^(UIAlertAction *action) {
        self.selectedDate = nil;
        [self foldShot];
    }]];

    NSDateFormatter *rainThick = [[NSDateFormatter alloc] init];
    rainThick.dateFormat = tapAddition.cutoffFunLatvianNetscapeDuePlacePlane;

    NSCalendar *calendar = [NSCalendar currentCalendar];

    for (NSDate *date in softFollowAtom) {
        NSString *title;
        if ([calendar isDateInToday:date]) {
            title = tapAddition.pullLayeringTwitterArchivedSeeEach;
        } else if ([calendar isDateInYesterday:date]) {
            title = tapAddition.outdoorHindiCarbonAirStaleRadioNumber;
        } else {
            title = [rainThick stringFromDate:date];
        }

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

    [actionSheet addAction:[UIAlertAction actionWithTitle:tapAddition.distantAttempterNetscapeCelsiusOurOff style:UIAlertActionStyleCancel handler:nil]];

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

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

- (void)ejectAction {
    if (!self.factoriesWonRecordSpeakerCalorie) {
        return;
    }

    NSArray *indirect = [self.factoriesWonRecordSpeakerCalorie hourSeekAsk];
    if (indirect.count == 0) {
        UIAlertController *dense = [UIAlertController alertControllerWithTitle:tapAddition.ascentCutoffPutLiteralTransitConstant
                                                                       message:tapAddition.profileForwardsInitialPutGramDays
                                                                preferredStyle:UIAlertControllerStyleAlert];
        [dense addAction:[UIAlertAction actionWithTitle:tapAddition.tipDescribeOrnamentBlackHasOrange style:UIAlertActionStyleDefault handler:nil]];
        [self presentViewController:dense animated:YES completion:nil];
        return;
    }

    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:tapAddition.detectorPagerReplyFactoriesCourseArrowLexicon
                                                                         message:nil
                                                                  preferredStyle:UIAlertControllerStyleActionSheet];

    [actionSheet addAction:[UIAlertAction actionWithTitle:tapAddition.topScreenPointBypassParseCheckoutUnlocked
                                                    style:UIAlertActionStyleDefault
                                                  handler:^(UIAlertAction *action) {
        [self reportEscape];
    }]];

    for (NSURL *fileURL in indirect) {
        NSString *fileName = fileURL.lastPathComponent;
        [actionSheet addAction:[UIAlertAction actionWithTitle:[NSString stringWithFormat:tapAddition.eventSpeakersCopyrightArmenianGenericsHailChapter, fileName]
                                                        style:UIAlertActionStyleDefault
                                                      handler:^(UIAlertAction *action) {
            [self fatClaimFile:fileURL];
        }]];
    }

    [actionSheet addAction:[UIAlertAction actionWithTitle:tapAddition.distantAttempterNetscapeCelsiusOurOff style:UIAlertActionStyleCancel handler:nil]];

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

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

- (void)reportEscape {
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        
        NSString *mercury = [self.factoriesWonRecordSpeakerCalorie metalRollSolve];

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

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

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

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

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

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

@end
