

#import "StillViewController.h"
#import "Rebus.h"
#import "BoundSecretSayScanningLevelName.h"
#import "LocalDismissedPrivilegeStoodDefines.h"
#import "CutYoungerConfig.h"

@interface StillViewController ()
@property (nonatomic, strong) UITextView *textView;
@property (nonatomic, strong) BoundSecretSayScanningLevelName *centeredWrappingRemoveInsertedFar;
@property (nonatomic, strong) LocalDismissedPrivilegeStoodDefines *urgencyDiskPrototypeBlurBrush;
@property (nonatomic, strong) NSDate *selectedDate; 
@end

static LocalDismissedPrivilegeStoodDefines *caretYearsPrototypeTeaspoonsCatalystPostcard = nil;
static BoundSecretSayScanningLevelName *workspaceSeeRunDecibelYoungestAngular = nil;

@implementation StillViewController

+ (void)memberPiece {
    
    [Rebus chromaVisualSpanEchoPassSampling];

    workspaceSeeRunDecibelYoungestAngular = [[BoundSecretSayScanningLevelName alloc] init];
    workspaceSeeRunDecibelYoungestAngular.recentLevel = ScrollingCertFactEnvelopeNewtons;

    [Rebus dryOrdinalsHeightReversingContains:workspaceSeeRunDecibelYoungestAngular];

    caretYearsPrototypeTeaspoonsCatalystPostcard = [[LocalDismissedPrivilegeStoodDefines alloc] init];
    caretYearsPrototypeTeaspoonsCatalystPostcard.recentLevel = HasHexCompare;
    caretYearsPrototypeTeaspoonsCatalystPostcard.itsMenu = 7;
    caretYearsPrototypeTeaspoonsCatalystPostcard.coalesceHueFisheyeTatarDepth = YES;
    [Rebus dryOrdinalsHeightReversingContains:caretYearsPrototypeTeaspoonsCatalystPostcard];

    [caretYearsPrototypeTeaspoonsCatalystPostcard dateHomeEffort];
}

+ (LocalDismissedPrivilegeStoodDefines *)preciseChooseLeapAmbiguousLinerUpper {
    return caretYearsPrototypeTeaspoonsCatalystPostcard;
}
+ (BoundSecretSayScanningLevelName *)clampedMetabolicDidStreamedHindiToo {
    return workspaceSeeRunDecibelYoungestAngular;
}

- (BoundSecretSayScanningLevelName *)centeredWrappingRemoveInsertedFar {
    return workspaceSeeRunDecibelYoungestAngular;
}

+ (void)vibrancyViewController:(UIViewController *)parentVC {
    StillViewController *serif = [[StillViewController alloc] init];
    UINavigationController *son = [[UINavigationController alloc] initWithRootViewController:serif];
    son.modalPresentationStyle = UIModalPresentationFullScreen;
    [parentVC presentViewController:son animated:YES completion:nil];
}

- (void)viewDidLoad {
    [super viewDidLoad];

    self.title = wrapFlipEar.quickOwnershipJumpNativeAlongsideLift;
    self.view.backgroundColor = [UIColor systemBackgroundColor];

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

    self.navigationItem.rightBarButtonItems = @[
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh
                                                      target:self
                                                      action:@selector(zeroWinAction)],
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction
                                                      target:self
                                                      action:@selector(smileAction)],
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemBookmarks
                                                      target:self
                                                      action:@selector(readAndHerAction)]
    ];
    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.urgencyDiskPrototypeBlurBrush = [StillViewController preciseChooseLeapAmbiguousLinerUpper];

    [self pasteArm];
}

- (void)pasteArm {
    if (!self.urgencyDiskPrototypeBlurBrush) {
        _textView.text = wrapFlipEar.enhancedDescentLossCyclingPrefixesEncodings;
        return;
    }

    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        NSString *logs;
        if (self.selectedDate) {
            logs = [self.urgencyDiskPrototypeBlurBrush adaptivePopDate:self.selectedDate];
        } else {
            logs = [self.urgencyDiskPrototypeBlurBrush blackPanMid];
        }

        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 = wrapFlipEar.relationBeganCaseUpperSameNibbles;
            }

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

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

- (void)zeroWinAction {
    [self pasteArm];
}

- (void)updateTitle {
    if (self.selectedDate) {
        NSDateFormatter *floorPass = [[NSDateFormatter alloc] init];
        floorPass.dateFormat = wrapFlipEar.whoSubQuitPlateTowerRoundRejection;
        NSString *blackBelow = [floorPass stringFromDate:self.selectedDate];

        NSCalendar *calendar = [NSCalendar currentCalendar];
        if ([calendar isDateInToday:self.selectedDate]) {
            self.title = wrapFlipEar.mongolianFigureFlipDegreeGetSymptom;
        } else if ([calendar isDateInYesterday:self.selectedDate]) {
            self.title = wrapFlipEar.movementOverageWidthChatCarbonPhraseFilters;
        } else {
            self.title = blackBelow;
        }
    } else {
        self.title = wrapFlipEar.spatialOutsidePackBoldfaceSlopeInteract;
    }
}

- (void)readAndHerAction {
    if (!self.urgencyDiskPrototypeBlurBrush) {
        return;
    }

    NSArray<NSDate *> *arcadeLifetime = [self.urgencyDiskPrototypeBlurBrush rowsInfoTen];
    if (arcadeLifetime.count == 0) {
        UIAlertController *third = [UIAlertController alertControllerWithTitle:wrapFlipEar.requestedFriendsLettishDaysEchoPetite
                                                                       message:wrapFlipEar.relationBeganCaseUpperSameNibbles
                                                                preferredStyle:UIAlertControllerStyleAlert];
        [third addAction:[UIAlertAction actionWithTitle:wrapFlipEar.linkProgressTicketsThreadedUnderDouble style:UIAlertActionStyleDefault handler:nil]];
        [self presentViewController:third animated:YES completion:nil];
        return;
    }

    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:wrapFlipEar.prefixedDolbyProtocolsHigherAnchorsRankNow
                                                                         message:nil
                                                                  preferredStyle:UIAlertControllerStyleActionSheet];

    [actionSheet addAction:[UIAlertAction actionWithTitle:wrapFlipEar.spatialOutsidePackBoldfaceSlopeInteract
                                                    style:UIAlertActionStyleDefault
                                                  handler:^(UIAlertAction *action) {
        self.selectedDate = nil;
        [self pasteArm];
    }]];

    NSDateFormatter *floorPass = [[NSDateFormatter alloc] init];
    floorPass.dateFormat = wrapFlipEar.whoSubQuitPlateTowerRoundRejection;

    NSCalendar *calendar = [NSCalendar currentCalendar];

    for (NSDate *date in arcadeLifetime) {
        NSString *title;
        if ([calendar isDateInToday:date]) {
            title = wrapFlipEar.mongolianFigureFlipDegreeGetSymptom;
        } else if ([calendar isDateInYesterday:date]) {
            title = wrapFlipEar.movementOverageWidthChatCarbonPhraseFilters;
        } else {
            title = [floorPass stringFromDate:date];
        }

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

    [actionSheet addAction:[UIAlertAction actionWithTitle:wrapFlipEar.drainEachRetSmoothSchoolBend style:UIAlertActionStyleCancel handler:nil]];

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

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

- (void)smileAction {
    if (!self.urgencyDiskPrototypeBlurBrush) {
        return;
    }

    NSArray *wireless = [self.urgencyDiskPrototypeBlurBrush appendedSix];
    if (wireless.count == 0) {
        UIAlertController *third = [UIAlertController alertControllerWithTitle:wrapFlipEar.requestedFriendsLettishDaysEchoPetite
                                                                       message:wrapFlipEar.transposeVariablesLineWayLayeringPen
                                                                preferredStyle:UIAlertControllerStyleAlert];
        [third addAction:[UIAlertAction actionWithTitle:wrapFlipEar.linkProgressTicketsThreadedUnderDouble style:UIAlertActionStyleDefault handler:nil]];
        [self presentViewController:third animated:YES completion:nil];
        return;
    }

    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:wrapFlipEar.addContextsUnsignedZipPreferredJobPartly
                                                                         message:nil
                                                                  preferredStyle:UIAlertControllerStyleActionSheet];

    [actionSheet addAction:[UIAlertAction actionWithTitle:wrapFlipEar.affineRopeTransitEntropyFourMidNepali
                                                    style:UIAlertActionStyleDefault
                                                  handler:^(UIAlertAction *action) {
        [self hoverSixGray];
    }]];

    for (NSURL *fileURL in wireless) {
        NSString *fileName = fileURL.lastPathComponent;
        [actionSheet addAction:[UIAlertAction actionWithTitle:[NSString stringWithFormat:wrapFlipEar.shapeMostlyMethodIntentContainMercurySudden, fileName]
                                                        style:UIAlertActionStyleDefault
                                                      handler:^(UIAlertAction *action) {
            [self projectsFile:fileURL];
        }]];
    }

    [actionSheet addAction:[UIAlertAction actionWithTitle:wrapFlipEar.drainEachRetSmoothSchoolBend style:UIAlertActionStyleCancel handler:nil]];

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

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

- (void)hoverSixGray {
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        
        NSString *smaller = [self.urgencyDiskPrototypeBlurBrush doneDidWorkOut];

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

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

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

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

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

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

@end
