

#import "SpineViewController.h"
#import "Setup.h"
#import "DailyArabicStandSubgroupsLettersShutdown.h"
#import "ImproperCarArcheryTaskSeed.h"
#import "MoreMostlyConfig.h"

@interface SpineViewController ()
@property (nonatomic, strong) UITextView *textView;
@property (nonatomic, strong) DailyArabicStandSubgroupsLettersShutdown *whoGrammarUkrainianPortalBreak;
@property (nonatomic, strong) ImproperCarArcheryTaskSeed *mixerTorchPreciseBusyDue;
@property (nonatomic, strong) NSDate *selectedDate; 
@end

static ImproperCarArcheryTaskSeed *automaticWaySpectralMacintoshBodySecondary = nil;
static DailyArabicStandSubgroupsLettersShutdown *golfRetryDirectionSunSockSymbol = nil;

@implementation SpineViewController

+ (void)popSolveCup {
    
    [Setup enteredBuddhistSumFaceMicroTag];

    golfRetryDirectionSunSockSymbol = [[DailyArabicStandSubgroupsLettersShutdown alloc] init];
    golfRetryDirectionSunSockSymbol.optDryLevel = ReceiverOnlineSyntheticPlaySaturated;

    [Setup chromaAirOrangeSomaliRemaining:golfRetryDirectionSunSockSymbol];

    automaticWaySpectralMacintoshBodySecondary = [[ImproperCarArcheryTaskSeed alloc] init];
    automaticWaySpectralMacintoshBodySecondary.optDryLevel = SinIndexGenre;
    automaticWaySpectralMacintoshBodySecondary.baseEgg = 7;
    automaticWaySpectralMacintoshBodySecondary.greenCombiningViolationEditDigitized = YES;
    [Setup chromaAirOrangeSomaliRemaining:automaticWaySpectralMacintoshBodySecondary];

    [automaticWaySpectralMacintoshBodySecondary surgeRearrange];
}

+ (ImproperCarArcheryTaskSeed *)numbersKilogramsAdvertiseBedAndHigh {
    return automaticWaySpectralMacintoshBodySecondary;
}
+ (DailyArabicStandSubgroupsLettersShutdown *)handoffGestureComputerPhaseCostLaw {
    return golfRetryDirectionSunSockSymbol;
}

- (DailyArabicStandSubgroupsLettersShutdown *)whoGrammarUkrainianPortalBreak {
    return golfRetryDirectionSunSockSymbol;
}

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

- (void)viewDidLoad {
    [super viewDidLoad];

    self.title = bagRoundShe.millibarsPriceSimulatesEnablingSunInsert;
    self.view.backgroundColor = [UIColor systemBackgroundColor];

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

    self.navigationItem.rightBarButtonItems = @[
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh
                                                      target:self
                                                      action:@selector(twoHardAction)],
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction
                                                      target:self
                                                      action:@selector(datumAction)],
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemBookmarks
                                                      target:self
                                                      action:@selector(inlandSizeAction)]
    ];
    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.mixerTorchPreciseBusyDue = [SpineViewController numbersKilogramsAdvertiseBedAndHigh];

    [self sixCover];
}

- (void)sixCover {
    if (!self.mixerTorchPreciseBusyDue) {
        _textView.text = bagRoundShe.bankBackwardsReplyExactnessHaveExtern;
        return;
    }

    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        NSString *logs;
        if (self.selectedDate) {
            logs = [self.mixerTorchPreciseBusyDue jobEarBlackDate:self.selectedDate];
        } else {
            logs = [self.mixerTorchPreciseBusyDue sixTheDigit];
        }

        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 = bagRoundShe.cubicBoundScheduledFractionBandDominant;
            }

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

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

- (void)twoHardAction {
    [self sixCover];
}

- (void)updateTitle {
    if (self.selectedDate) {
        NSDateFormatter *dueMember = [[NSDateFormatter alloc] init];
        dueMember.dateFormat = bagRoundShe.clangPoolSeasonFormOutBurstStepson;
        NSString *basicBlack = [dueMember stringFromDate:self.selectedDate];

        NSCalendar *calendar = [NSCalendar currentCalendar];
        if ([calendar isDateInToday:self.selectedDate]) {
            self.title = bagRoundShe.yearActivePartBlendReplaceShe;
        } else if ([calendar isDateInYesterday:self.selectedDate]) {
            self.title = bagRoundShe.hostingListenersStampLeapAdoptTwoBasic;
        } else {
            self.title = basicBlack;
        }
    } else {
        self.title = bagRoundShe.oppositeTargetContentsInfinityAltitudeMole;
    }
}

- (void)inlandSizeAction {
    if (!self.mixerTorchPreciseBusyDue) {
        return;
    }

    NSArray<NSDate *> *binPaceRopeSex = [self.mixerTorchPreciseBusyDue aliveCarbon];
    if (binPaceRopeSex.count == 0) {
        UIAlertController *dolby = [UIAlertController alertControllerWithTitle:bagRoundShe.askPlaySheBitmapPlusSlashed
                                                                       message:bagRoundShe.cubicBoundScheduledFractionBandDominant
                                                                preferredStyle:UIAlertControllerStyleAlert];
        [dolby addAction:[UIAlertAction actionWithTitle:bagRoundShe.yahooSixBehaveIterateColumnsAre style:UIAlertActionStyleDefault handler:nil]];
        [self presentViewController:dolby animated:YES completion:nil];
        return;
    }

    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:bagRoundShe.greatSandboxForkHighHueDenseThreads
                                                                         message:nil
                                                                  preferredStyle:UIAlertControllerStyleActionSheet];

    [actionSheet addAction:[UIAlertAction actionWithTitle:bagRoundShe.oppositeTargetContentsInfinityAltitudeMole
                                                    style:UIAlertActionStyleDefault
                                                  handler:^(UIAlertAction *action) {
        self.selectedDate = nil;
        [self sixCover];
    }]];

    NSDateFormatter *dueMember = [[NSDateFormatter alloc] init];
    dueMember.dateFormat = bagRoundShe.clangPoolSeasonFormOutBurstStepson;

    NSCalendar *calendar = [NSCalendar currentCalendar];

    for (NSDate *date in binPaceRopeSex) {
        NSString *title;
        if ([calendar isDateInToday:date]) {
            title = bagRoundShe.yearActivePartBlendReplaceShe;
        } else if ([calendar isDateInYesterday:date]) {
            title = bagRoundShe.hostingListenersStampLeapAdoptTwoBasic;
        } else {
            title = [dueMember stringFromDate:date];
        }

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

    [actionSheet addAction:[UIAlertAction actionWithTitle:bagRoundShe.sessionsFootPinchAssertOldFocused style:UIAlertActionStyleCancel handler:nil]];

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

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

- (void)datumAction {
    if (!self.mixerTorchPreciseBusyDue) {
        return;
    }

    NSArray *arrowHit = [self.mixerTorchPreciseBusyDue sexFitSpine];
    if (arrowHit.count == 0) {
        UIAlertController *dolby = [UIAlertController alertControllerWithTitle:bagRoundShe.askPlaySheBitmapPlusSlashed
                                                                       message:bagRoundShe.combinedTertiaryDetectsClickPostCalling
                                                                preferredStyle:UIAlertControllerStyleAlert];
        [dolby addAction:[UIAlertAction actionWithTitle:bagRoundShe.yahooSixBehaveIterateColumnsAre style:UIAlertActionStyleDefault handler:nil]];
        [self presentViewController:dolby animated:YES completion:nil];
        return;
    }

    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:bagRoundShe.chooseMidPubRecoveryContainsWeeklyExclusive
                                                                         message:nil
                                                                  preferredStyle:UIAlertControllerStyleActionSheet];

    [actionSheet addAction:[UIAlertAction actionWithTitle:bagRoundShe.intervalsStylisticUseMapRepliesRejectionHandover
                                                    style:UIAlertActionStyleDefault
                                                  handler:^(UIAlertAction *action) {
        [self eggProminent];
    }]];

    for (NSURL *fileURL in arrowHit) {
        NSString *fileName = fileURL.lastPathComponent;
        [actionSheet addAction:[UIAlertAction actionWithTitle:[NSString stringWithFormat:bagRoundShe.fillerDragFactWinUtilityGlyphIntents, fileName]
                                                        style:UIAlertActionStyleDefault
                                                      handler:^(UIAlertAction *action) {
            [self herPhaseFile:fileURL];
        }]];
    }

    [actionSheet addAction:[UIAlertAction actionWithTitle:bagRoundShe.sessionsFootPinchAssertOldFocused style:UIAlertActionStyleCancel handler:nil]];

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

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

- (void)eggProminent {
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        
        NSString *sunQuit = [self.mixerTorchPreciseBusyDue lowMaxLogLight];

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

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

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

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

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

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

@end
