

#import "HeartViewController.h"
#import "Elder.h"
#import "RoleCreationLinerEighteenYetPortal.h"
#import "LicenseLazyAdjectiveYetEnvelope.h"
#import "FlatDayFitConfig.h"

@interface HeartViewController ()
@property (nonatomic, strong) UITextView *textView;
@property (nonatomic, strong) RoleCreationLinerEighteenYetPortal *outsideManAppearsAndLoad;
@property (nonatomic, strong) LicenseLazyAdjectiveYetEnvelope *basqueArrangerKeysEngineHex;
@property (nonatomic, strong) NSDate *selectedDate; 
@end

static LicenseLazyAdjectiveYetEnvelope *preventPenFloatReservedAnchoringBoth = nil;
static RoleCreationLinerEighteenYetPortal *additiveDesignerSplatRouterCapsAdvances = nil;

@implementation HeartViewController

+ (void)equalAmpere {
    
    [Elder artworkTabEighteenTempPositionsIntegrity];

    additiveDesignerSplatRouterCapsAdvances = [[RoleCreationLinerEighteenYetPortal alloc] init];
    additiveDesignerSplatRouterCapsAdvances.logCupLevel = WaitExposeSelectionLearnedSpine;

    [Elder challengeFileRawBagFinishing:additiveDesignerSplatRouterCapsAdvances];

    preventPenFloatReservedAnchoringBoth = [[LicenseLazyAdjectiveYetEnvelope alloc] init];
    preventPenFloatReservedAnchoringBoth.logCupLevel = DueFitPassive;
    preventPenFloatReservedAnchoringBoth.goalFat = 7;
    preventPenFloatReservedAnchoringBoth.revealedPublisherRematchCollapseBend = YES;
    [Elder challengeFileRawBagFinishing:preventPenFloatReservedAnchoringBoth];

    [preventPenFloatReservedAnchoringBoth upsideSequence];
}

+ (LicenseLazyAdjectiveYetEnvelope *)terahertzScreenActiveCropLocalizesSetup {
    return preventPenFloatReservedAnchoringBoth;
}
+ (RoleCreationLinerEighteenYetPortal *)planNumeratorEraAmharicFocalDark {
    return additiveDesignerSplatRouterCapsAdvances;
}

- (RoleCreationLinerEighteenYetPortal *)outsideManAppearsAndLoad {
    return additiveDesignerSplatRouterCapsAdvances;
}

+ (void)segueOneViewController:(UIViewController *)parentVC {
    HeartViewController *tight = [[HeartViewController alloc] init];
    UINavigationController *hit = [[UINavigationController alloc] initWithRootViewController:tight];
    hit.modalPresentationStyle = UIModalPresentationFullScreen;
    [parentVC presentViewController:hit animated:YES completion:nil];
}

- (void)viewDidLoad {
    [super viewDidLoad];

    self.title = moleRateAll.sessionSetupModuleLinearDustAllocated;
    self.view.backgroundColor = [UIColor systemBackgroundColor];

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

    self.navigationItem.rightBarButtonItems = @[
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh
                                                      target:self
                                                      action:@selector(confirmAction)],
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction
                                                      target:self
                                                      action:@selector(sigmaAction)],
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemBookmarks
                                                      target:self
                                                      action:@selector(timeBinEraAction)]
    ];
    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.basqueArrangerKeysEngineHex = [HeartViewController terahertzScreenActiveCropLocalizesSetup];

    [self humanPut];
}

- (void)humanPut {
    if (!self.basqueArrangerKeysEngineHex) {
        _textView.text = moleRateAll.momentRegisterSpeechCornersInsetMetabolic;
        return;
    }

    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        NSString *logs;
        if (self.selectedDate) {
            logs = [self.basqueArrangerKeysEngineHex sobWasChinaDate:self.selectedDate];
        } else {
            logs = [self.basqueArrangerKeysEngineHex magicCousin];
        }

        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 = moleRateAll.sharingPassivelyStiffnessModifierCallClosest;
            }

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

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

- (void)confirmAction {
    [self humanPut];
}

- (void)updateTitle {
    if (self.selectedDate) {
        NSDateFormatter *tabAssert = [[NSDateFormatter alloc] init];
        tabAssert.dateFormat = moleRateAll.intervalsHexMolarBoldfaceLibraryDestroyPan;
        NSString *boxSnapRun = [tabAssert stringFromDate:self.selectedDate];

        NSCalendar *calendar = [NSCalendar currentCalendar];
        if ([calendar isDateInToday:self.selectedDate]) {
            self.title = moleRateAll.copperRankUploadResizingLaotianMay;
        } else if ([calendar isDateInYesterday:self.selectedDate]) {
            self.title = moleRateAll.englishGrantingBleedSnapshotVitalComponentMute;
        } else {
            self.title = boxSnapRun;
        }
    } else {
        self.title = moleRateAll.mixMaintainDeliverWinShowOpposite;
    }
}

- (void)timeBinEraAction {
    if (!self.basqueArrangerKeysEngineHex) {
        return;
    }

    NSArray<NSDate *> *ropeTenAddMenu = [self.basqueArrangerKeysEngineHex foldOutside];
    if (ropeTenAddMenu.count == 0) {
        UIAlertController *entry = [UIAlertController alertControllerWithTitle:moleRateAll.auditedUnsignedNorwegianPartiallySlightMedia
                                                                       message:moleRateAll.sharingPassivelyStiffnessModifierCallClosest
                                                                preferredStyle:UIAlertControllerStyleAlert];
        [entry addAction:[UIAlertAction actionWithTitle:moleRateAll.circleStackEvaluatedInviteeBarrierOffer style:UIAlertActionStyleDefault handler:nil]];
        [self presentViewController:entry animated:YES completion:nil];
        return;
    }

    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:moleRateAll.workspaceDiagnoseThermalDuctilityAlignPriorityLambda
                                                                         message:nil
                                                                  preferredStyle:UIAlertControllerStyleActionSheet];

    [actionSheet addAction:[UIAlertAction actionWithTitle:moleRateAll.mixMaintainDeliverWinShowOpposite
                                                    style:UIAlertActionStyleDefault
                                                  handler:^(UIAlertAction *action) {
        self.selectedDate = nil;
        [self humanPut];
    }]];

    NSDateFormatter *tabAssert = [[NSDateFormatter alloc] init];
    tabAssert.dateFormat = moleRateAll.intervalsHexMolarBoldfaceLibraryDestroyPan;

    NSCalendar *calendar = [NSCalendar currentCalendar];

    for (NSDate *date in ropeTenAddMenu) {
        NSString *title;
        if ([calendar isDateInToday:date]) {
            title = moleRateAll.copperRankUploadResizingLaotianMay;
        } else if ([calendar isDateInYesterday:date]) {
            title = moleRateAll.englishGrantingBleedSnapshotVitalComponentMute;
        } else {
            title = [tabAssert stringFromDate:date];
        }

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

    [actionSheet addAction:[UIAlertAction actionWithTitle:moleRateAll.pongFrequencyDecigramsMinimizeTintReadable style:UIAlertActionStyleCancel handler:nil]];

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

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

- (void)sigmaAction {
    if (!self.basqueArrangerKeysEngineHex) {
        return;
    }

    NSArray *eggLemma = [self.basqueArrangerKeysEngineHex topDuePrior];
    if (eggLemma.count == 0) {
        UIAlertController *entry = [UIAlertController alertControllerWithTitle:moleRateAll.auditedUnsignedNorwegianPartiallySlightMedia
                                                                       message:moleRateAll.illDisablesStereoEulerAllergyCrop
                                                                preferredStyle:UIAlertControllerStyleAlert];
        [entry addAction:[UIAlertAction actionWithTitle:moleRateAll.circleStackEvaluatedInviteeBarrierOffer style:UIAlertActionStyleDefault handler:nil]];
        [self presentViewController:entry animated:YES completion:nil];
        return;
    }

    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:moleRateAll.profilesTwoRollSuggestedPresentBufferStar
                                                                         message:nil
                                                                  preferredStyle:UIAlertControllerStyleActionSheet];

    [actionSheet addAction:[UIAlertAction actionWithTitle:moleRateAll.yahooStackOperandRenewAffiliateVolumeNow
                                                    style:UIAlertActionStyleDefault
                                                  handler:^(UIAlertAction *action) {
        [self eastWinFarsi];
    }]];

    for (NSURL *fileURL in eggLemma) {
        NSString *fileName = fileURL.lastPathComponent;
        [actionSheet addAction:[UIAlertAction actionWithTitle:[NSString stringWithFormat:moleRateAll.currentlyIcyDecreaseKilometerMoireThumbnailFun, fileName]
                                                        style:UIAlertActionStyleDefault
                                                      handler:^(UIAlertAction *action) {
            [self quitBothFile:fileURL];
        }]];
    }

    [actionSheet addAction:[UIAlertAction actionWithTitle:moleRateAll.pongFrequencyDecigramsMinimizeTintReadable style:UIAlertActionStyleCancel handler:nil]];

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

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

- (void)eastWinFarsi {
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        
        NSString *sobItem = [self.basqueArrangerKeysEngineHex badTipSpineBar];

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

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

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

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

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

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

@end
