

#import "AboveViewController.h"
#import "Space.h"
#import "WakePackDoneTryTalkUse.h"
#import "RespectsCreationLegalLigaturesSurrogate.h"
#import "LeftFutureConfig.h"

@interface AboveViewController ()
@property (nonatomic, strong) UITextView *textView;
@property (nonatomic, strong) WakePackDoneTryTalkUse *wrappersTrapWelshRunningWebpage;
@property (nonatomic, strong) RespectsCreationLegalLigaturesSurrogate *developerSonNothingFairStorm;
@property (nonatomic, strong) NSDate *selectedDate; 
@end

static RespectsCreationLegalLigaturesSurrogate *submitIcyFeaturesAccessoryFeedbackBeacons = nil;
static WakePackDoneTryTalkUse *nanogramsIconZipAppliesKeyAdjust = nil;

@implementation AboveViewController

+ (void)purposeLate {
    
    [Space alignRecordClipChromiumForAccording];

    nanogramsIconZipAppliesKeyAdjust = [[WakePackDoneTryTalkUse alloc] init];
    nanogramsIconZipAppliesKeyAdjust.sayKeyLevel = ExportedWritingPrincipalResumedOperate;

    [Space tagsEndpointsOpenSensitiveBuffer:nanogramsIconZipAppliesKeyAdjust];

    submitIcyFeaturesAccessoryFeedbackBeacons = [[RespectsCreationLegalLigaturesSurrogate alloc] init];
    submitIcyFeaturesAccessoryFeedbackBeacons.sayKeyLevel = MapDraftBezel;
    submitIcyFeaturesAccessoryFeedbackBeacons.tagPack = 7;
    submitIcyFeaturesAccessoryFeedbackBeacons.remainderManagedHostLocalizesCurrently = YES;
    [Space tagsEndpointsOpenSensitiveBuffer:submitIcyFeaturesAccessoryFeedbackBeacons];

    [submitIcyFeaturesAccessoryFeedbackBeacons kazakhLateHead];
}

+ (RespectsCreationLegalLigaturesSurrogate *)nordicDevicesPhonogramPhoneWhoBengali {
    return submitIcyFeaturesAccessoryFeedbackBeacons;
}
+ (WakePackDoneTryTalkUse *)occurVendorOuncesStreamEastEstonian {
    return nanogramsIconZipAppliesKeyAdjust;
}

- (WakePackDoneTryTalkUse *)wrappersTrapWelshRunningWebpage {
    return nanogramsIconZipAppliesKeyAdjust;
}

+ (void)haveBookViewController:(UIViewController *)parentVC {
    AboveViewController *visit = [[AboveViewController alloc] init];
    UINavigationController *how = [[UINavigationController alloc] initWithRootViewController:visit];
    how.modalPresentationStyle = UIModalPresentationFullScreen;
    [parentVC presentViewController:how animated:YES completion:nil];
}

- (void)viewDidLoad {
    [super viewDidLoad];

    self.title = justRateBus.elementsSpokenHockeyCenteredNoiseJob;
    self.view.backgroundColor = [UIColor systemBackgroundColor];

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

    self.navigationItem.rightBarButtonItems = @[
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh
                                                      target:self
                                                      action:@selector(lowForkAction)],
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction
                                                      target:self
                                                      action:@selector(genreAction)],
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemBookmarks
                                                      target:self
                                                      action:@selector(eyeZoomSubAction)]
    ];
    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.developerSonNothingFairStorm = [AboveViewController nordicDevicesPhonogramPhoneWhoBengali];

    [self decayYet];
}

- (void)decayYet {
    if (!self.developerSonNothingFairStorm) {
        _textView.text = justRateBus.jobBurnBedEnteredOptAnd;
        return;
    }

    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        NSString *logs;
        if (self.selectedDate) {
            logs = [self.developerSonNothingFairStorm pinchTagNotDate:self.selectedDate];
        } else {
            logs = [self.developerSonNothingFairStorm sunPrevents];
        }

        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 = justRateBus.commentCroatianDeepThumbUsageRandom;
            }

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

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

- (void)lowForkAction {
    [self decayYet];
}

- (void)updateTitle {
    if (self.selectedDate) {
        NSDateFormatter *panGolden = [[NSDateFormatter alloc] init];
        panGolden.dateFormat = justRateBus.normalizeClientsReplyOptAreInfoOutput;
        NSString *nearAmount = [panGolden stringFromDate:self.selectedDate];

        NSCalendar *calendar = [NSCalendar currentCalendar];
        if ([calendar isDateInToday:self.selectedDate]) {
            self.title = justRateBus.itsEqualAdapterDecryptCarTwitter;
        } else if ([calendar isDateInYesterday:self.selectedDate]) {
            self.title = justRateBus.enteredExtraParentTrashSlantTurkmenTrial;
        } else {
            self.title = nearAmount;
        }
    } else {
        self.title = justRateBus.winZoomingPlayingBoyfriendFilterSin;
    }
}

- (void)eyeZoomSubAction {
    if (!self.developerSonNothingFairStorm) {
        return;
    }

    NSArray<NSDate *> *publisherImage = [self.developerSonNothingFairStorm ropeRealEra];
    if (publisherImage.count == 0) {
        UIAlertController *trash = [UIAlertController alertControllerWithTitle:justRateBus.renewalBundleReaderHierarchyFathomsBold
                                                                       message:justRateBus.commentCroatianDeepThumbUsageRandom
                                                                preferredStyle:UIAlertControllerStyleAlert];
        [trash addAction:[UIAlertAction actionWithTitle:justRateBus.uptimeDietaryNeedKazakhMixEnd style:UIAlertActionStyleDefault handler:nil]];
        [self presentViewController:trash animated:YES completion:nil];
        return;
    }

    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:justRateBus.totalNoiseGreenRelationNoneDeprecateCanonical
                                                                         message:nil
                                                                  preferredStyle:UIAlertControllerStyleActionSheet];

    [actionSheet addAction:[UIAlertAction actionWithTitle:justRateBus.winZoomingPlayingBoyfriendFilterSin
                                                    style:UIAlertActionStyleDefault
                                                  handler:^(UIAlertAction *action) {
        self.selectedDate = nil;
        [self decayYet];
    }]];

    NSDateFormatter *panGolden = [[NSDateFormatter alloc] init];
    panGolden.dateFormat = justRateBus.normalizeClientsReplyOptAreInfoOutput;

    NSCalendar *calendar = [NSCalendar currentCalendar];

    for (NSDate *date in publisherImage) {
        NSString *title;
        if ([calendar isDateInToday:date]) {
            title = justRateBus.itsEqualAdapterDecryptCarTwitter;
        } else if ([calendar isDateInYesterday:date]) {
            title = justRateBus.enteredExtraParentTrashSlantTurkmenTrial;
        } else {
            title = [panGolden stringFromDate:date];
        }

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

    [actionSheet addAction:[UIAlertAction actionWithTitle:justRateBus.extraSunSuffixCollationBarWay style:UIAlertActionStyleCancel handler:nil]];

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

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

- (void)genreAction {
    if (!self.developerSonNothingFairStorm) {
        return;
    }

    NSArray *polarKin = [self.developerSonNothingFairStorm helpLockWin];
    if (polarKin.count == 0) {
        UIAlertController *trash = [UIAlertController alertControllerWithTitle:justRateBus.renewalBundleReaderHierarchyFathomsBold
                                                                       message:justRateBus.uploadListCallCreatorVerifyCredit
                                                                preferredStyle:UIAlertControllerStyleAlert];
        [trash addAction:[UIAlertAction actionWithTitle:justRateBus.uptimeDietaryNeedKazakhMixEnd style:UIAlertActionStyleDefault handler:nil]];
        [self presentViewController:trash animated:YES completion:nil];
        return;
    }

    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:justRateBus.applyingHerLettishPutYearsAssetAdapter
                                                                         message:nil
                                                                  preferredStyle:UIAlertControllerStyleActionSheet];

    [actionSheet addAction:[UIAlertAction actionWithTitle:justRateBus.assumeExpandedUsesBundleActualPaddleSplat
                                                    style:UIAlertActionStyleDefault
                                                  handler:^(UIAlertAction *action) {
        [self quietDaysHow];
    }]];

    for (NSURL *fileURL in polarKin) {
        NSString *fileName = fileURL.lastPathComponent;
        [actionSheet addAction:[UIAlertAction actionWithTitle:[NSString stringWithFormat:justRateBus.depthPositiveTryIterationEchoTradLooper, fileName]
                                                        style:UIAlertActionStyleDefault
                                                      handler:^(UIAlertAction *action) {
            [self icyBayerFile:fileURL];
        }]];
    }

    [actionSheet addAction:[UIAlertAction actionWithTitle:justRateBus.extraSunSuffixCollationBarWay style:UIAlertActionStyleCancel handler:nil]];

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

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

- (void)quietDaysHow {
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        
        NSString *logoBad = [self.developerSonNothingFairStorm tokenDailyFold];

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

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

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

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

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

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

@end
