

#import "EulerViewController.h"
#import "Modal.h"
#import "MandarinBirthSleetCauseMenstrualFilter.h"
#import "OddTrackSigmaBigShort.h"
#import "WaxOlympusConfig.h"

@interface EulerViewController ()
@property (nonatomic, strong) UITextView *textView;
@property (nonatomic, strong) MandarinBirthSleetCauseMenstrualFilter *waistSurgeEvictSunPlayback;
@property (nonatomic, strong) OddTrackSigmaBigShort *ignoredDoubleWidgetVersionCanon;
@property (nonatomic, strong) NSDate *selectedDate; 
@end

static OddTrackSigmaBigShort *computerOutletSpecifyStakeClearUnlimited = nil;
static MandarinBirthSleetCauseMenstrualFilter *agePeerCoalescePintUrgencyReturns = nil;

@implementation EulerViewController

+ (void)rowQuantize {
    
    [Modal wasSigmoidLyricistDeviationInitiallyDarwin];

    agePeerCoalescePintUrgencyReturns = [[MandarinBirthSleetCauseMenstrualFilter alloc] init];
    agePeerCoalescePintUrgencyReturns.littleLevel = ProtocolsInviteInventoryPotentialDeletion;

    [Modal partlyEndMapRetriedRatio:agePeerCoalescePintUrgencyReturns];

    computerOutletSpecifyStakeClearUnlimited = [[OddTrackSigmaBigShort alloc] init];
    computerOutletSpecifyStakeClearUnlimited.littleLevel = EditorsAbsent;
    computerOutletSpecifyStakeClearUnlimited.penFeet = 7;
    computerOutletSpecifyStakeClearUnlimited.icyKindNodeStatementComments = YES;
    [Modal partlyEndMapRetriedRatio:computerOutletSpecifyStakeClearUnlimited];

    [computerOutletSpecifyStakeClearUnlimited bodyQueryBurst];
}

+ (OddTrackSigmaBigShort *)eyeRestoreWidthPreservedFunkLook {
    return computerOutletSpecifyStakeClearUnlimited;
}
+ (MandarinBirthSleetCauseMenstrualFilter *)backwardsIndicatorRetainLoadTapSolo {
    return agePeerCoalescePintUrgencyReturns;
}

- (MandarinBirthSleetCauseMenstrualFilter *)waistSurgeEvictSunPlayback {
    return agePeerCoalescePintUrgencyReturns;
}

+ (void)molarIcyViewController:(UIViewController *)parentVC {
    EulerViewController *space = [[EulerViewController alloc] init];
    UINavigationController *wax = [[UINavigationController alloc] initWithRootViewController:space];
    wax.modalPresentationStyle = UIModalPresentationFullScreen;
    [parentVC presentViewController:wax animated:YES completion:nil];
}

- (void)viewDidLoad {
    [super viewDidLoad];

    self.title = twoStrength.rolePolicyOldSeekingSubgroupProvided;
    self.view.backgroundColor = [UIColor systemBackgroundColor];

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

    self.navigationItem.rightBarButtonItems = @[
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh
                                                      target:self
                                                      action:@selector(slabAndAction)],
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction
                                                      target:self
                                                      action:@selector(digitAction)],
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemBookmarks
                                                      target:self
                                                      action:@selector(wonAirlineAction)]
    ];
    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.ignoredDoubleWidgetVersionCanon = [EulerViewController eyeRestoreWidthPreservedFunkLook];

    [self climbing];
}

- (void)climbing {
    if (!self.ignoredDoubleWidgetVersionCanon) {
        _textView.text = twoStrength.primaryInviteMarkDeferringFetchAtomic;
        return;
    }

    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        NSString *logs;
        if (self.selectedDate) {
            logs = [self.ignoredDoubleWidgetVersionCanon howOriginalDate:self.selectedDate];
        } else {
            logs = [self.ignoredDoubleWidgetVersionCanon cursorEvict];
        }

        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 = twoStrength.redefinedRemoteSpecificPubYouFork;
            }

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

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

- (void)slabAndAction {
    [self climbing];
}

- (void)updateTitle {
    if (self.selectedDate) {
        NSDateFormatter *plusSolid = [[NSDateFormatter alloc] init];
        plusSolid.dateFormat = twoStrength.inspiredOrganizeStateServerBigCreamyFaeroese;
        NSString *copticLate = [plusSolid stringFromDate:self.selectedDate];

        NSCalendar *calendar = [NSCalendar currentCalendar];
        if ([calendar isDateInToday:self.selectedDate]) {
            self.title = twoStrength.fastDisappearSubsetBeaconsReuseOverflow;
        } else if ([calendar isDateInYesterday:self.selectedDate]) {
            self.title = twoStrength.partMenTriggersBoundCiphersSnowSignaling;
        } else {
            self.title = copticLate;
        }
    } else {
        self.title = twoStrength.kilobytesBondExportForAlienLocations;
    }
}

- (void)wonAirlineAction {
    if (!self.ignoredDoubleWidgetVersionCanon) {
        return;
    }

    NSArray<NSDate *> *repairContents = [self.ignoredDoubleWidgetVersionCanon canReversed];
    if (repairContents.count == 0) {
        UIAlertController *maker = [UIAlertController alertControllerWithTitle:twoStrength.decryptedMountedSleepBuilderDeliveryLog
                                                                       message:twoStrength.redefinedRemoteSpecificPubYouFork
                                                                preferredStyle:UIAlertControllerStyleAlert];
        [maker addAction:[UIAlertAction actionWithTitle:twoStrength.protocolsTransportRevealChainFocusProtected style:UIAlertActionStyleDefault handler:nil]];
        [self presentViewController:maker animated:YES completion:nil];
        return;
    }

    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:twoStrength.cursorEntitledExpectedRetryLiftSwahiliLegible
                                                                         message:nil
                                                                  preferredStyle:UIAlertControllerStyleActionSheet];

    [actionSheet addAction:[UIAlertAction actionWithTitle:twoStrength.kilobytesBondExportForAlienLocations
                                                    style:UIAlertActionStyleDefault
                                                  handler:^(UIAlertAction *action) {
        self.selectedDate = nil;
        [self climbing];
    }]];

    NSDateFormatter *plusSolid = [[NSDateFormatter alloc] init];
    plusSolid.dateFormat = twoStrength.inspiredOrganizeStateServerBigCreamyFaeroese;

    NSCalendar *calendar = [NSCalendar currentCalendar];

    for (NSDate *date in repairContents) {
        NSString *title;
        if ([calendar isDateInToday:date]) {
            title = twoStrength.fastDisappearSubsetBeaconsReuseOverflow;
        } else if ([calendar isDateInYesterday:date]) {
            title = twoStrength.partMenTriggersBoundCiphersSnowSignaling;
        } else {
            title = [plusSolid stringFromDate:date];
        }

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

    [actionSheet addAction:[UIAlertAction actionWithTitle:twoStrength.persianHisRootAnotherActivityTerminate style:UIAlertActionStyleCancel handler:nil]];

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

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

- (void)digitAction {
    if (!self.ignoredDoubleWidgetVersionCanon) {
        return;
    }

    NSArray *eggWrite = [self.ignoredDoubleWidgetVersionCanon spellRedBus];
    if (eggWrite.count == 0) {
        UIAlertController *maker = [UIAlertController alertControllerWithTitle:twoStrength.decryptedMountedSleepBuilderDeliveryLog
                                                                       message:twoStrength.preventsSeventeenViolationSundaneseAwayWill
                                                                preferredStyle:UIAlertControllerStyleAlert];
        [maker addAction:[UIAlertAction actionWithTitle:twoStrength.protocolsTransportRevealChainFocusProtected style:UIAlertActionStyleDefault handler:nil]];
        [self presentViewController:maker animated:YES completion:nil];
        return;
    }

    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:twoStrength.boyfriendAmbientOurCurlPieceChromePitch
                                                                         message:nil
                                                                  preferredStyle:UIAlertControllerStyleActionSheet];

    [actionSheet addAction:[UIAlertAction actionWithTitle:twoStrength.storeAreaTapProximitySpaCinematicSplit
                                                    style:UIAlertActionStyleDefault
                                                  handler:^(UIAlertAction *action) {
        [self briefSexBlue];
    }]];

    for (NSURL *fileURL in eggWrite) {
        NSString *fileName = fileURL.lastPathComponent;
        [actionSheet addAction:[UIAlertAction actionWithTitle:[NSString stringWithFormat:twoStrength.presentBeganWasSaturateLeapEstonianMemory, fileName]
                                                        style:UIAlertActionStyleDefault
                                                      handler:^(UIAlertAction *action) {
            [self wonValueFile:fileURL];
        }]];
    }

    [actionSheet addAction:[UIAlertAction actionWithTitle:twoStrength.persianHisRootAnotherActivityTerminate style:UIAlertActionStyleCancel handler:nil]];

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

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

- (void)briefSexBlue {
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        
        NSString *certAre = [self.ignoredDoubleWidgetVersionCanon hairRevertSide];

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

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

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

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

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

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

@end
