

#import "PauseViewController.h"
#import "Flash.h"
#import "ColorAllocateMainMuteFeaturesMay.h"
#import "TailCapturedRedirectsReadAsset.h"
#import "FaxClosestConfig.h"

@interface PauseViewController ()
@property (nonatomic, strong) UITextView *textView;
@property (nonatomic, strong) ColorAllocateMainMuteFeaturesMay *exposuresDisablesNearbyReleaseCookie;
@property (nonatomic, strong) TailCapturedRedirectsReadAsset *coalescedLocalizesLargerEngineSleet;
@property (nonatomic, strong) NSDate *selectedDate; 
@end

static TailCapturedRedirectsReadAsset *suchChangeChannelsSigmoidInfoIrish = nil;
static ColorAllocateMainMuteFeaturesMay *pressesYouSliceEllipsisMagnitudeFinished = nil;

@implementation PauseViewController

+ (void)siteEggTrad {
    
    [Flash managersChooseLinkFunctionsUniformCalories];

    pressesYouSliceEllipsisMagnitudeFinished = [[ColorAllocateMainMuteFeaturesMay alloc] init];
    pressesYouSliceEllipsisMagnitudeFinished.onlineLevel = PersistHalfSunRedFootnote;

    [Flash slashedDelayedSpatialMovementChildren:pressesYouSliceEllipsisMagnitudeFinished];

    suchChangeChannelsSigmoidInfoIrish = [[TailCapturedRedirectsReadAsset alloc] init];
    suchChangeChannelsSigmoidInfoIrish.onlineLevel = BagStalledWas;
    suchChangeChannelsSigmoidInfoIrish.subFour = 7;
    suchChangeChannelsSigmoidInfoIrish.pinCornersEngineerKilovoltsSkin = YES;
    [Flash slashedDelayedSpatialMovementChildren:suchChangeChannelsSigmoidInfoIrish];

    [suchChangeChannelsSigmoidInfoIrish areDropYetChat];
}

+ (TailCapturedRedirectsReadAsset *)preventHasUnderageAppearCaptionLatitude {
    return suchChangeChannelsSigmoidInfoIrish;
}
+ (ColorAllocateMainMuteFeaturesMay *)jobPatchLeaseTransientEncodedTwelve {
    return pressesYouSliceEllipsisMagnitudeFinished;
}

- (ColorAllocateMainMuteFeaturesMay *)exposuresDisablesNearbyReleaseCookie {
    return pressesYouSliceEllipsisMagnitudeFinished;
}

+ (void)romanSinViewController:(UIViewController *)parentVC {
    PauseViewController *never = [[PauseViewController alloc] init];
    UINavigationController *nap = [[UINavigationController alloc] initWithRootViewController:never];
    nap.modalPresentationStyle = UIModalPresentationFullScreen;
    [parentVC presentViewController:nap animated:YES completion:nil];
}

- (void)viewDidLoad {
    [super viewDidLoad];

    self.title = lessDaysSum.promotionTabLayerQuotationExpertLappish;
    self.view.backgroundColor = [UIColor systemBackgroundColor];

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

    self.navigationItem.rightBarButtonItems = @[
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh
                                                      target:self
                                                      action:@selector(typeFaxAction)],
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction
                                                      target:self
                                                      action:@selector(shareAction)],
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemBookmarks
                                                      target:self
                                                      action:@selector(clockDecayAction)]
    ];
    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.coalescedLocalizesLargerEngineSleet = [PauseViewController preventHasUnderageAppearCaptionLatitude];

    [self sumMouse];
}

- (void)sumMouse {
    if (!self.coalescedLocalizesLargerEngineSleet) {
        _textView.text = lessDaysSum.discountNegativeSlowNotifiedCurveShear;
        return;
    }

    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        NSString *logs;
        if (self.selectedDate) {
            logs = [self.coalescedLocalizesLargerEngineSleet itsPeakSongDate:self.selectedDate];
        } else {
            logs = [self.coalescedLocalizesLargerEngineSleet alphaWaySub];
        }

        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 = lessDaysSum.inlandCapturedLogoOptionHelperOrigin;
            }

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

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

- (void)typeFaxAction {
    [self sumMouse];
}

- (void)updateTitle {
    if (self.selectedDate) {
        NSDateFormatter *heavyPick = [[NSDateFormatter alloc] init];
        heavyPick.dateFormat = lessDaysSum.calculateWideCellphoneColleagueArtHandPen;
        NSString *dateString = [heavyPick stringFromDate:self.selectedDate];

        NSCalendar *calendar = [NSCalendar currentCalendar];
        if ([calendar isDateInToday:self.selectedDate]) {
            self.title = lessDaysSum.secureNotifyingPerformerKelvinThousandsIntro;
        } else if ([calendar isDateInYesterday:self.selectedDate]) {
            self.title = lessDaysSum.rotorSpeedMinuteRunDescenderHandleExposure;
        } else {
            self.title = dateString;
        }
    } else {
        self.title = lessDaysSum.bookAccountsRunFileDogDry;
    }
}

- (void)clockDecayAction {
    if (!self.coalescedLocalizesLargerEngineSleet) {
        return;
    }

    NSArray<NSDate *> *sawEmailMayWho = [self.coalescedLocalizesLargerEngineSleet badHerInfer];
    if (sawEmailMayWho.count == 0) {
        UIAlertController *bayer = [UIAlertController alertControllerWithTitle:lessDaysSum.hallBagMapMultiplyVisionRevisions
                                                                       message:lessDaysSum.inlandCapturedLogoOptionHelperOrigin
                                                                preferredStyle:UIAlertControllerStyleAlert];
        [bayer addAction:[UIAlertAction actionWithTitle:lessDaysSum.panAccountParticleCurlFolderQuotes style:UIAlertActionStyleDefault handler:nil]];
        [self presentViewController:bayer animated:YES completion:nil];
        return;
    }

    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:lessDaysSum.advancesSettingCallSlabGallonsHeartbeatSigner
                                                                         message:nil
                                                                  preferredStyle:UIAlertControllerStyleActionSheet];

    [actionSheet addAction:[UIAlertAction actionWithTitle:lessDaysSum.bookAccountsRunFileDogDry
                                                    style:UIAlertActionStyleDefault
                                                  handler:^(UIAlertAction *action) {
        self.selectedDate = nil;
        [self sumMouse];
    }]];

    NSDateFormatter *heavyPick = [[NSDateFormatter alloc] init];
    heavyPick.dateFormat = lessDaysSum.calculateWideCellphoneColleagueArtHandPen;

    NSCalendar *calendar = [NSCalendar currentCalendar];

    for (NSDate *date in sawEmailMayWho) {
        NSString *title;
        if ([calendar isDateInToday:date]) {
            title = lessDaysSum.secureNotifyingPerformerKelvinThousandsIntro;
        } else if ([calendar isDateInYesterday:date]) {
            title = lessDaysSum.rotorSpeedMinuteRunDescenderHandleExposure;
        } else {
            title = [heavyPick stringFromDate:date];
        }

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

    [actionSheet addAction:[UIAlertAction actionWithTitle:lessDaysSum.selectedStateNotBestAreCollation style:UIAlertActionStyleCancel handler:nil]];

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

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

- (void)shareAction {
    if (!self.coalescedLocalizesLargerEngineSleet) {
        return;
    }

    NSArray *funHindi = [self.coalescedLocalizesLargerEngineSleet entryBridge];
    if (funHindi.count == 0) {
        UIAlertController *bayer = [UIAlertController alertControllerWithTitle:lessDaysSum.hallBagMapMultiplyVisionRevisions
                                                                       message:lessDaysSum.keySymmetricDepartureResumeSecondaryAppending
                                                                preferredStyle:UIAlertControllerStyleAlert];
        [bayer addAction:[UIAlertAction actionWithTitle:lessDaysSum.panAccountParticleCurlFolderQuotes style:UIAlertActionStyleDefault handler:nil]];
        [self presentViewController:bayer animated:YES completion:nil];
        return;
    }

    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:lessDaysSum.maxLineHyphensContactsYellowHandoverAcute
                                                                         message:nil
                                                                  preferredStyle:UIAlertControllerStyleActionSheet];

    [actionSheet addAction:[UIAlertAction actionWithTitle:lessDaysSum.oneDeferredPartSegueDigitalComparedPolicy
                                                    style:UIAlertActionStyleDefault
                                                  handler:^(UIAlertAction *action) {
        [self lossyWeekend];
    }]];

    for (NSURL *fileURL in funHindi) {
        NSString *fileName = fileURL.lastPathComponent;
        [actionSheet addAction:[UIAlertAction actionWithTitle:[NSString stringWithFormat:lessDaysSum.senseObserversBlobPivotGermanTremorJoule, fileName]
                                                        style:UIAlertActionStyleDefault
                                                      handler:^(UIAlertAction *action) {
            [self timeCellFile:fileURL];
        }]];
    }

    [actionSheet addAction:[UIAlertAction actionWithTitle:lessDaysSum.selectedStateNotBestAreCollation style:UIAlertActionStyleCancel handler:nil]];

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

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

- (void)lossyWeekend {
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        
        NSString *foodDay = [self.coalescedLocalizesLargerEngineSleet awayDidSongOld];

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

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

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

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

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

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

@end
