

#import "CaretViewController.h"
#import "Cross.h"
#import "ComposeProfilesRecentlyPartlyDependentPub.h"
#import "DetailedCanUbiquityCroppingRemaining.h"
#import "ArteryPlugConfig.h"

@interface CaretViewController ()
@property (nonatomic, strong) UITextView *textView;
@property (nonatomic, strong) ComposeProfilesRecentlyPartlyDependentPub *cycleSoloistLayerAdditionsRespond;
@property (nonatomic, strong) DetailedCanUbiquityCroppingRemaining *unwindingHeartbeatSugarExecConstruct;
@property (nonatomic, strong) NSDate *selectedDate; 
@end

static DetailedCanUbiquityCroppingRemaining *previewRainCellphoneTagBridgedLose = nil;
static ComposeProfilesRecentlyPartlyDependentPub *currencyStrictlyShutdownVideoTrashProgress = nil;

@implementation CaretViewController

+ (void)pulseAction {
    
    [Cross slidingRoundFirmwarePacketBookmarksFiltered];

    currencyStrictlyShutdownVideoTrashProgress = [[ComposeProfilesRecentlyPartlyDependentPub alloc] init];
    currencyStrictlyShutdownVideoTrashProgress.signalLevel = CapturesRelatedCarBehaviorsPencil;

    [Cross napDarwinAllergyContentsFree:currencyStrictlyShutdownVideoTrashProgress];

    previewRainCellphoneTagBridgedLose = [[DetailedCanUbiquityCroppingRemaining alloc] init];
    previewRainCellphoneTagBridgedLose.signalLevel = MiterCatalyst;
    previewRainCellphoneTagBridgedLose.songLog = 7;
    previewRainCellphoneTagBridgedLose.mustDependentTokenNicknameDegrees = YES;
    [Cross napDarwinAllergyContentsFree:previewRainCellphoneTagBridgedLose];

    [previewRainCellphoneTagBridgedLose liveTailSample];
}

+ (DetailedCanUbiquityCroppingRemaining *)paceProposalStormNapHasDismissed {
    return previewRainCellphoneTagBridgedLose;
}
+ (ComposeProfilesRecentlyPartlyDependentPub *)ascentRomanFloatingPubTagalogHello {
    return currencyStrictlyShutdownVideoTrashProgress;
}

- (ComposeProfilesRecentlyPartlyDependentPub *)cycleSoloistLayerAdditionsRespond {
    return currencyStrictlyShutdownVideoTrashProgress;
}

+ (void)hisFlashViewController:(UIViewController *)parentVC {
    CaretViewController *meter = [[CaretViewController alloc] init];
    UINavigationController *six = [[UINavigationController alloc] initWithRootViewController:meter];
    six.modalPresentationStyle = UIModalPresentationFullScreen;
    [parentVC presentViewController:six animated:YES completion:nil];
}

- (void)viewDidLoad {
    [super viewDidLoad];

    self.title = sourcesFont.sunMirroringConvertedInvitePhotoPeople;
    self.view.backgroundColor = [UIColor systemBackgroundColor];

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

    self.navigationItem.rightBarButtonItems = @[
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh
                                                      target:self
                                                      action:@selector(longHerAction)],
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction
                                                      target:self
                                                      action:@selector(foggyAction)],
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemBookmarks
                                                      target:self
                                                      action:@selector(eyePassiveAction)]
    ];
    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.unwindingHeartbeatSugarExecConstruct = [CaretViewController paceProposalStormNapHasDismissed];

    [self restPart];
}

- (void)restPart {
    if (!self.unwindingHeartbeatSugarExecConstruct) {
        _textView.text = sourcesFont.segmentManHandleSwipeSquaresStair;
        return;
    }

    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        NSString *logs;
        if (self.selectedDate) {
            logs = [self.unwindingHeartbeatSugarExecConstruct sonAirSplitDate:self.selectedDate];
        } else {
            logs = [self.unwindingHeartbeatSugarExecConstruct nameAdjusts];
        }

        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 = sourcesFont.deliveryDissolveServicesElapsedSystolicGeneric;
            }

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

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

- (void)longHerAction {
    [self restPart];
}

- (void)updateTitle {
    if (self.selectedDate) {
        NSDateFormatter *cameraPub = [[NSDateFormatter alloc] init];
        cameraPub.dateFormat = sourcesFont.angleSubsetTagsTreeThinSoftwareMap;
        NSString *lawUseFind = [cameraPub stringFromDate:self.selectedDate];

        NSCalendar *calendar = [NSCalendar currentCalendar];
        if ([calendar isDateInToday:self.selectedDate]) {
            self.title = sourcesFont.celsiusLegibleBoundaryDistantDeletingGolf;
        } else if ([calendar isDateInYesterday:self.selectedDate]) {
            self.title = sourcesFont.fiberLoveProfilesSparseHeightStreetLaunching;
        } else {
            self.title = lawUseFind;
        }
    } else {
        self.title = sourcesFont.applyFlattenKeyCancelAccountsPurchased;
    }
}

- (void)eyePassiveAction {
    if (!self.unwindingHeartbeatSugarExecConstruct) {
        return;
    }

    NSArray<NSDate *> *loseInsertMore = [self.unwindingHeartbeatSugarExecConstruct offerArtist];
    if (loseInsertMore.count == 0) {
        UIAlertController *rebus = [UIAlertController alertControllerWithTitle:sourcesFont.eachPitchSigmoidInteractLongestAdjusts
                                                                       message:sourcesFont.deliveryDissolveServicesElapsedSystolicGeneric
                                                                preferredStyle:UIAlertControllerStyleAlert];
        [rebus addAction:[UIAlertAction actionWithTitle:sourcesFont.headphoneSizeCreatingSharePortRetained style:UIAlertActionStyleDefault handler:nil]];
        [self presentViewController:rebus animated:YES completion:nil];
        return;
    }

    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:sourcesFont.boxFlashIndicatorPassUnlikelyUnlockedDifferent
                                                                         message:nil
                                                                  preferredStyle:UIAlertControllerStyleActionSheet];

    [actionSheet addAction:[UIAlertAction actionWithTitle:sourcesFont.applyFlattenKeyCancelAccountsPurchased
                                                    style:UIAlertActionStyleDefault
                                                  handler:^(UIAlertAction *action) {
        self.selectedDate = nil;
        [self restPart];
    }]];

    NSDateFormatter *cameraPub = [[NSDateFormatter alloc] init];
    cameraPub.dateFormat = sourcesFont.angleSubsetTagsTreeThinSoftwareMap;

    NSCalendar *calendar = [NSCalendar currentCalendar];

    for (NSDate *date in loseInsertMore) {
        NSString *title;
        if ([calendar isDateInToday:date]) {
            title = sourcesFont.celsiusLegibleBoundaryDistantDeletingGolf;
        } else if ([calendar isDateInYesterday:date]) {
            title = sourcesFont.fiberLoveProfilesSparseHeightStreetLaunching;
        } else {
            title = [cameraPub stringFromDate:date];
        }

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

    [actionSheet addAction:[UIAlertAction actionWithTitle:sourcesFont.ubiquityExclusiveSceneExtentsSobSegue style:UIAlertActionStyleCancel handler:nil]];

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

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

- (void)foggyAction {
    if (!self.unwindingHeartbeatSugarExecConstruct) {
        return;
    }

    NSArray *rebusFit = [self.unwindingHeartbeatSugarExecConstruct activateBus];
    if (rebusFit.count == 0) {
        UIAlertController *rebus = [UIAlertController alertControllerWithTitle:sourcesFont.eachPitchSigmoidInteractLongestAdjusts
                                                                       message:sourcesFont.faceMatchMonotonicIntegerTwitterActive
                                                                preferredStyle:UIAlertControllerStyleAlert];
        [rebus addAction:[UIAlertAction actionWithTitle:sourcesFont.headphoneSizeCreatingSharePortRetained style:UIAlertActionStyleDefault handler:nil]];
        [self presentViewController:rebus animated:YES completion:nil];
        return;
    }

    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:sourcesFont.multipleTargetEnclosingEqualRespondsSinTruncates
                                                                         message:nil
                                                                  preferredStyle:UIAlertControllerStyleActionSheet];

    [actionSheet addAction:[UIAlertAction actionWithTitle:sourcesFont.eggRefreshedFrictionCatalanAnimatedBoyfriendExposure
                                                    style:UIAlertActionStyleDefault
                                                  handler:^(UIAlertAction *action) {
        [self leastWebpage];
    }]];

    for (NSURL *fileURL in rebusFit) {
        NSString *fileName = fileURL.lastPathComponent;
        [actionSheet addAction:[UIAlertAction actionWithTitle:[NSString stringWithFormat:sourcesFont.manIndigoExpertRootBufferPositionsHectares, fileName]
                                                        style:UIAlertActionStyleDefault
                                                      handler:^(UIAlertAction *action) {
            [self finalTwoFile:fileURL];
        }]];
    }

    [actionSheet addAction:[UIAlertAction actionWithTitle:sourcesFont.ubiquityExclusiveSceneExtentsSobSegue style:UIAlertActionStyleCancel handler:nil]];

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

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

- (void)leastWebpage {
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        
        NSString *spanHas = [self.unwindingHeartbeatSugarExecConstruct suggestPersist];

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

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

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

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

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

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

@end
