

#import "OccurViewController.h"
#import "Mouth.h"
#import "MaskReachedAfterNominalBitAdvisory.h"
#import "HiddenPresentedConstantsHurricaneTouches.h"
#import "PopPoloAddConfig.h"

@interface OccurViewController ()
@property (nonatomic, strong) UITextView *textView;
@property (nonatomic, strong) MaskReachedAfterNominalBitAdvisory *baseExecDigitizedSpeakingParticle;
@property (nonatomic, strong) HiddenPresentedConstantsHurricaneTouches *emailArrangerConflictsEncryptedStatic;
@property (nonatomic, strong) NSDate *selectedDate; 
@end

static HiddenPresentedConstantsHurricaneTouches *scatteredNameLawOpaqueSexSpatial = nil;
static MaskReachedAfterNominalBitAdvisory *modePrematureFrameBeenBadWork = nil;

@implementation OccurViewController

+ (void)layerAnyKin {
    
    [Mouth itsRelationsSmileStepPowerChannels];

    modePrematureFrameBeenBadWork = [[MaskReachedAfterNominalBitAdvisory alloc] init];
    modePrematureFrameBeenBadWork.fillerLevel = ForDynamicSeparateAttempterPreset;

    [Mouth cousinFailDismissDissolveUnsafe:modePrematureFrameBeenBadWork];

    scatteredNameLawOpaqueSexSpatial = [[HiddenPresentedConstantsHurricaneTouches alloc] init];
    scatteredNameLawOpaqueSexSpatial.fillerLevel = DoneSubmitted;
    scatteredNameLawOpaqueSexSpatial.pintToo = 7;
    scatteredNameLawOpaqueSexSpatial.rainMidBiometryFailingLow = YES;
    [Mouth cousinFailDismissDissolveUnsafe:scatteredNameLawOpaqueSexSpatial];

    [scatteredNameLawOpaqueSexSpatial bottomReliable];
}

+ (HiddenPresentedConstantsHurricaneTouches *)operandAlongSequenceThumbnailExactnessCommand {
    return scatteredNameLawOpaqueSexSpatial;
}
+ (MaskReachedAfterNominalBitAdvisory *)interiorHexSupportsTrustedEffortAppear {
    return modePrematureFrameBeenBadWork;
}

- (MaskReachedAfterNominalBitAdvisory *)baseExecDigitizedSpeakingParticle {
    return modePrematureFrameBeenBadWork;
}

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

- (void)viewDidLoad {
    [super viewDidLoad];

    self.title = nonceTwoEar.ownApplierChinaSmilePutCard;
    self.view.backgroundColor = [UIColor systemBackgroundColor];

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

    self.navigationItem.rightBarButtonItems = @[
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh
                                                      target:self
                                                      action:@selector(husbandAction)],
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction
                                                      target:self
                                                      action:@selector(threeAction)],
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemBookmarks
                                                      target:self
                                                      action:@selector(lostSixKitAction)]
    ];
    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.emailArrangerConflictsEncryptedStatic = [OccurViewController operandAlongSequenceThumbnailExactnessCommand];

    [self aboveNow];
}

- (void)aboveNow {
    if (!self.emailArrangerConflictsEncryptedStatic) {
        _textView.text = nonceTwoEar.additionDrizzleLacrosseEncodingsGermanGenerics;
        return;
    }

    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        NSString *logs;
        if (self.selectedDate) {
            logs = [self.emailArrangerConflictsEncryptedStatic runPubLegalDate:self.selectedDate];
        } else {
            logs = [self.emailArrangerConflictsEncryptedStatic sobRawClose];
        }

        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 = nonceTwoEar.catTwelveInjectionEventEditorsMin;
            }

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

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

- (void)husbandAction {
    [self aboveNow];
}

- (void)updateTitle {
    if (self.selectedDate) {
        NSDateFormatter *according = [[NSDateFormatter alloc] init];
        according.dateFormat = nonceTwoEar.privilegeWideItalicLingerCentersClampSentences;
        NSString *tightLemma = [according stringFromDate:self.selectedDate];

        NSCalendar *calendar = [NSCalendar currentCalendar];
        if ([calendar isDateInToday:self.selectedDate]) {
            self.title = nonceTwoEar.eraserPlaceRecentlyPresentedCombiningOne;
        } else if ([calendar isDateInYesterday:self.selectedDate]) {
            self.title = nonceTwoEar.croppingFixtureProcessChallengeAssetTextBig;
        } else {
            self.title = tightLemma;
        }
    } else {
        self.title = nonceTwoEar.magneticPartPersianHourlyAlongHour;
    }
}

- (void)lostSixKitAction {
    if (!self.emailArrangerConflictsEncryptedStatic) {
        return;
    }

    NSArray<NSDate *> *switchWakeWait = [self.emailArrangerConflictsEncryptedStatic badgeAddRow];
    if (switchWakeWait.count == 0) {
        UIAlertController *china = [UIAlertController alertControllerWithTitle:nonceTwoEar.sceneActivatedFarsiZeroProxyObserving
                                                                       message:nonceTwoEar.catTwelveInjectionEventEditorsMin
                                                                preferredStyle:UIAlertControllerStyleAlert];
        [china addAction:[UIAlertAction actionWithTitle:nonceTwoEar.diacriticInstallsPenHellmanAxesQuerying style:UIAlertActionStyleDefault handler:nil]];
        [self presentViewController:china animated:YES completion:nil];
        return;
    }

    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:nonceTwoEar.dolbyEraserOwnHandDiscoverExistArabic
                                                                         message:nil
                                                                  preferredStyle:UIAlertControllerStyleActionSheet];

    [actionSheet addAction:[UIAlertAction actionWithTitle:nonceTwoEar.magneticPartPersianHourlyAlongHour
                                                    style:UIAlertActionStyleDefault
                                                  handler:^(UIAlertAction *action) {
        self.selectedDate = nil;
        [self aboveNow];
    }]];

    NSDateFormatter *according = [[NSDateFormatter alloc] init];
    according.dateFormat = nonceTwoEar.privilegeWideItalicLingerCentersClampSentences;

    NSCalendar *calendar = [NSCalendar currentCalendar];

    for (NSDate *date in switchWakeWait) {
        NSString *title;
        if ([calendar isDateInToday:date]) {
            title = nonceTwoEar.eraserPlaceRecentlyPresentedCombiningOne;
        } else if ([calendar isDateInYesterday:date]) {
            title = nonceTwoEar.croppingFixtureProcessChallengeAssetTextBig;
        } else {
            title = [according stringFromDate:date];
        }

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

    [actionSheet addAction:[UIAlertAction actionWithTitle:nonceTwoEar.askUplinkVolatileMoireKeysPreview style:UIAlertActionStyleCancel handler:nil]];

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

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

- (void)threeAction {
    if (!self.emailArrangerConflictsEncryptedStatic) {
        return;
    }

    NSArray *baseStar = [self.emailArrangerConflictsEncryptedStatic lowAwakeJob];
    if (baseStar.count == 0) {
        UIAlertController *china = [UIAlertController alertControllerWithTitle:nonceTwoEar.sceneActivatedFarsiZeroProxyObserving
                                                                       message:nonceTwoEar.dialogEqualityYetDuctilitySettingPotential
                                                                preferredStyle:UIAlertControllerStyleAlert];
        [china addAction:[UIAlertAction actionWithTitle:nonceTwoEar.diacriticInstallsPenHellmanAxesQuerying style:UIAlertActionStyleDefault handler:nil]];
        [self presentViewController:china animated:YES completion:nil];
        return;
    }

    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:nonceTwoEar.outcomeAmbientSaturatedPositionPrefersChunkyWhite
                                                                         message:nil
                                                                  preferredStyle:UIAlertControllerStyleActionSheet];

    [actionSheet addAction:[UIAlertAction actionWithTitle:nonceTwoEar.albanianConductorStackedMotionFactFitSaturated
                                                    style:UIAlertActionStyleDefault
                                                  handler:^(UIAlertAction *action) {
        [self matrixWasCat];
    }]];

    for (NSURL *fileURL in baseStar) {
        NSString *fileName = fileURL.lastPathComponent;
        [actionSheet addAction:[UIAlertAction actionWithTitle:[NSString stringWithFormat:nonceTwoEar.marginsMapCloseEnableSoftwareQuitAngle, fileName]
                                                        style:UIAlertActionStyleDefault
                                                      handler:^(UIAlertAction *action) {
            [self softFastFile:fileURL];
        }]];
    }

    [actionSheet addAction:[UIAlertAction actionWithTitle:nonceTwoEar.askUplinkVolatileMoireKeysPreview style:UIAlertActionStyleCancel handler:nil]];

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

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

- (void)matrixWasCat {
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        
        NSString *oldRule = [self.emailArrangerConflictsEncryptedStatic hybridBikeMore];

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

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

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

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

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

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

@end
