

#import "FrameViewController.h"
#import "Brief.h"
#import "EggFilteringCheckerArtHighMostly.h"
#import "JustPubThicknessBinTwelve.h"
#import "CertPenSheConfig.h"

@interface FrameViewController ()
@property (nonatomic, strong) UITextView *textView;
@property (nonatomic, strong) EggFilteringCheckerArtHighMostly *foundMoireFunIncrementInfo;
@property (nonatomic, strong) JustPubThicknessBinTwelve *realmOpaqueGurationArmNewsstand;
@property (nonatomic, strong) NSDate *selectedDate; 
@end

static JustPubThicknessBinTwelve *backupPashtoReceivesOrnamentGeneratesLiner = nil;
static EggFilteringCheckerArtHighMostly *scrollingFootNauticalPoolDownStepson = nil;

@implementation FrameViewController

+ (void)curvePanAnd {
    
    [Brief relatedHandArmMixDeepBorder];

    scrollingFootNauticalPoolDownStepson = [[EggFilteringCheckerArtHighMostly alloc] init];
    scrollingFootNauticalPoolDownStepson.ascentLevel = FunWayQueryingTwoBar;

    [Brief quantizeCardioidPrivilegeNumberTerahertz:scrollingFootNauticalPoolDownStepson];

    backupPashtoReceivesOrnamentGeneratesLiner = [[JustPubThicknessBinTwelve alloc] init];
    backupPashtoReceivesOrnamentGeneratesLiner.ascentLevel = InsetBlendWay;
    backupPashtoReceivesOrnamentGeneratesLiner.bankCar = 7;
    backupPashtoReceivesOrnamentGeneratesLiner.purposeTintEncryptedCopticSubscribe = YES;
    [Brief quantizeCardioidPrivilegeNumberTerahertz:backupPashtoReceivesOrnamentGeneratesLiner];

    [backupPashtoReceivesOrnamentGeneratesLiner menuFreeSquash];
}

+ (JustPubThicknessBinTwelve *)sunUndefinedSlashesMixMarkNeed {
    return backupPashtoReceivesOrnamentGeneratesLiner;
}
+ (EggFilteringCheckerArtHighMostly *)secureWasHairTouchDaughtersPicker {
    return scrollingFootNauticalPoolDownStepson;
}

- (EggFilteringCheckerArtHighMostly *)foundMoireFunIncrementInfo {
    return scrollingFootNauticalPoolDownStepson;
}

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

- (void)viewDidLoad {
    [super viewDidLoad];

    self.title = artSubFoggy.legibleReasonAccurateStepchildSpeedSpouses;
    self.view.backgroundColor = [UIColor systemBackgroundColor];

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

    self.navigationItem.rightBarButtonItems = @[
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh
                                                      target:self
                                                      action:@selector(mapMustAction)],
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction
                                                      target:self
                                                      action:@selector(decayAction)],
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemBookmarks
                                                      target:self
                                                      action:@selector(bodyEggEarAction)]
    ];
    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.realmOpaqueGurationArmNewsstand = [FrameViewController sunUndefinedSlashesMixMarkNeed];

    [self footWeek];
}

- (void)footWeek {
    if (!self.realmOpaqueGurationArmNewsstand) {
        _textView.text = artSubFoggy.gravitySeparatedWayLevelLongExtra;
        return;
    }

    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        NSString *logs;
        if (self.selectedDate) {
            logs = [self.realmOpaqueGurationArmNewsstand stakePenPubDate:self.selectedDate];
        } else {
            logs = [self.realmOpaqueGurationArmNewsstand hueReversed];
        }

        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 = artSubFoggy.pageOwnVitalFeetMinorBiotin;
            }

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

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

- (void)mapMustAction {
    [self footWeek];
}

- (void)updateTitle {
    if (self.selectedDate) {
        NSDateFormatter *sinEleven = [[NSDateFormatter alloc] init];
        sinEleven.dateFormat = artSubFoggy.encodingsCanTowerBlackChromaticUnwrapFarsi;
        NSString *plusResume = [sinEleven stringFromDate:self.selectedDate];

        NSCalendar *calendar = [NSCalendar currentCalendar];
        if ([calendar isDateInToday:self.selectedDate]) {
            self.title = artSubFoggy.bayerIcyCompoundServerPostTrad;
        } else if ([calendar isDateInYesterday:self.selectedDate]) {
            self.title = artSubFoggy.respondsHangSharingIdleConnectYouCloudy;
        } else {
            self.title = plusResume;
        }
    } else {
        self.title = artSubFoggy.speakingWatchedDutchHashTipHandled;
    }
}

- (void)bodyEggEarAction {
    if (!self.realmOpaqueGurationArmNewsstand) {
        return;
    }

    NSArray<NSDate *> *webpageVisible = [self.realmOpaqueGurationArmNewsstand olympusDeep];
    if (webpageVisible.count == 0) {
        UIAlertController *prior = [UIAlertController alertControllerWithTitle:artSubFoggy.filteredInuitFlagComposedDatabaseRetrieve
                                                                       message:artSubFoggy.pageOwnVitalFeetMinorBiotin
                                                                preferredStyle:UIAlertControllerStyleAlert];
        [prior addAction:[UIAlertAction actionWithTitle:artSubFoggy.malayTwoAbortWeightCreateCommon style:UIAlertActionStyleDefault handler:nil]];
        [self presentViewController:prior animated:YES completion:nil];
        return;
    }

    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:artSubFoggy.alphaEvaluatedTryShotClosureChainMen
                                                                         message:nil
                                                                  preferredStyle:UIAlertControllerStyleActionSheet];

    [actionSheet addAction:[UIAlertAction actionWithTitle:artSubFoggy.speakingWatchedDutchHashTipHandled
                                                    style:UIAlertActionStyleDefault
                                                  handler:^(UIAlertAction *action) {
        self.selectedDate = nil;
        [self footWeek];
    }]];

    NSDateFormatter *sinEleven = [[NSDateFormatter alloc] init];
    sinEleven.dateFormat = artSubFoggy.encodingsCanTowerBlackChromaticUnwrapFarsi;

    NSCalendar *calendar = [NSCalendar currentCalendar];

    for (NSDate *date in webpageVisible) {
        NSString *title;
        if ([calendar isDateInToday:date]) {
            title = artSubFoggy.bayerIcyCompoundServerPostTrad;
        } else if ([calendar isDateInYesterday:date]) {
            title = artSubFoggy.respondsHangSharingIdleConnectYouCloudy;
        } else {
            title = [sinEleven stringFromDate:date];
        }

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

    [actionSheet addAction:[UIAlertAction actionWithTitle:artSubFoggy.suffixDefinePluralDecodingProviderUnion style:UIAlertActionStyleCancel handler:nil]];

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

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

- (void)decayAction {
    if (!self.realmOpaqueGurationArmNewsstand) {
        return;
    }

    NSArray *nearGain = [self.realmOpaqueGurationArmNewsstand leftAddPick];
    if (nearGain.count == 0) {
        UIAlertController *prior = [UIAlertController alertControllerWithTitle:artSubFoggy.filteredInuitFlagComposedDatabaseRetrieve
                                                                       message:artSubFoggy.densityMisplacedBleedSubtitleDeletionFinger
                                                                preferredStyle:UIAlertControllerStyleAlert];
        [prior addAction:[UIAlertAction actionWithTitle:artSubFoggy.malayTwoAbortWeightCreateCommon style:UIAlertActionStyleDefault handler:nil]];
        [self presentViewController:prior animated:YES completion:nil];
        return;
    }

    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:artSubFoggy.bordersYouCheckKitAspectKernelFeature
                                                                         message:nil
                                                                  preferredStyle:UIAlertControllerStyleActionSheet];

    [actionSheet addAction:[UIAlertAction actionWithTitle:artSubFoggy.procedureLimitedAdvisedGrammarConvergedTodayLift
                                                    style:UIAlertActionStyleDefault
                                                  handler:^(UIAlertAction *action) {
        [self taggerLowWas];
    }]];

    for (NSURL *fileURL in nearGain) {
        NSString *fileName = fileURL.lastPathComponent;
        [actionSheet addAction:[UIAlertAction actionWithTitle:[NSString stringWithFormat:artSubFoggy.exactNiacinChildrenStoneEdgaProjectRespects, fileName]
                                                        style:UIAlertActionStyleDefault
                                                      handler:^(UIAlertAction *action) {
            [self midDelayFile:fileURL];
        }]];
    }

    [actionSheet addAction:[UIAlertAction actionWithTitle:artSubFoggy.suffixDefinePluralDecodingProviderUnion style:UIAlertActionStyleCancel handler:nil]];

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

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

- (void)taggerLowWas {
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        
        NSString *itemPen = [self.realmOpaqueGurationArmNewsstand lockSixDoneHex];

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

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

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

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

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

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

@end
