

#import "VitalViewController.h"
#import "Piece.h"
#import "ApertureInfinityModerateResponderBorderedOvulation.h"
#import "GivenChlorideOwnNegotiateProtected.h"
#import "YearsShiftConfig.h"

@interface VitalViewController ()
@property (nonatomic, strong) UITextView *textView;
@property (nonatomic, strong) ApertureInfinityModerateResponderBorderedOvulation *presentExtractReceivingPlatformGopher;
@property (nonatomic, strong) GivenChlorideOwnNegotiateProtected *anyStreamedStereoAppliesJump;
@property (nonatomic, strong) NSDate *selectedDate; 
@end

static GivenChlorideOwnNegotiateProtected *chestMutationExposeModernAreTouches = nil;
static ApertureInfinityModerateResponderBorderedOvulation *tenSobGopherInsideArteryAltitude = nil;

@implementation VitalViewController

+ (void)farFlushOut {
    
    [Piece redPermanentControlNotifyBinTickets];

    tenSobGopherInsideArteryAltitude = [[ApertureInfinityModerateResponderBorderedOvulation alloc] init];
    tenSobGopherInsideArteryAltitude.slightLevel = CommitHandballDailyTelephoneColumn;

    [Piece sixResumeGroupingConsumesPartial:tenSobGopherInsideArteryAltitude];

    chestMutationExposeModernAreTouches = [[GivenChlorideOwnNegotiateProtected alloc] init];
    chestMutationExposeModernAreTouches.slightLevel = TabBusInteger;
    chestMutationExposeModernAreTouches.hitDeep = 7;
    chestMutationExposeModernAreTouches.cricketRemotelyRedThreadJapanese = YES;
    [Piece sixResumeGroupingConsumesPartial:chestMutationExposeModernAreTouches];

    [chestMutationExposeModernAreTouches bendBadBoxDrag];
}

+ (GivenChlorideOwnNegotiateProtected *)lawOppositeQualityClosestSwappedRight {
    return chestMutationExposeModernAreTouches;
}
+ (ApertureInfinityModerateResponderBorderedOvulation *)hasAddressesHardSinPivotFactory {
    return tenSobGopherInsideArteryAltitude;
}

- (ApertureInfinityModerateResponderBorderedOvulation *)presentExtractReceivingPlatformGopher {
    return tenSobGopherInsideArteryAltitude;
}

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

- (void)viewDidLoad {
    [super viewDidLoad];

    self.title = behaviorHue.mayBitFilenameProxyInitiatedOff;
    self.view.backgroundColor = [UIColor systemBackgroundColor];

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

    self.navigationItem.rightBarButtonItems = @[
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh
                                                      target:self
                                                      action:@selector(shotZipAction)],
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction
                                                      target:self
                                                      action:@selector(cycleAction)],
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemBookmarks
                                                      target:self
                                                      action:@selector(cameraKeysAction)]
    ];
    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.anyStreamedStereoAppliesJump = [VitalViewController lawOppositeQualityClosestSwappedRight];

    [self popVital];
}

- (void)popVital {
    if (!self.anyStreamedStereoAppliesJump) {
        _textView.text = behaviorHue.seventeenTransformTabHumidityBuddyAscent;
        return;
    }

    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        NSString *logs;
        if (self.selectedDate) {
            logs = [self.anyStreamedStereoAppliesJump shakeArmOutDate:self.selectedDate];
        } else {
            logs = [self.anyStreamedStereoAppliesJump walkOurFair];
        }

        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 = behaviorHue.functionsClampingItemSchoolInvitedTen;
            }

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

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

- (void)shotZipAction {
    [self popVital];
}

- (void)updateTitle {
    if (self.selectedDate) {
        NSDateFormatter *panDegree = [[NSDateFormatter alloc] init];
        panDegree.dateFormat = behaviorHue.mildContentChatRoundPhaseLocalizesStay;
        NSString *duplexLazy = [panDegree stringFromDate:self.selectedDate];

        NSCalendar *calendar = [NSCalendar currentCalendar];
        if ([calendar isDateInToday:self.selectedDate]) {
            self.title = behaviorHue.safariUndonePreparingDuplexLabeledEnergy;
        } else if ([calendar isDateInYesterday:self.selectedDate]) {
            self.title = behaviorHue.trimmingClinicalChlorideCatKirghizIntegrateFirst;
        } else {
            self.title = duplexLazy;
        }
    } else {
        self.title = behaviorHue.gradientPedometerFlightTornadoFunRetrieve;
    }
}

- (void)cameraKeysAction {
    if (!self.anyStreamedStereoAppliesJump) {
        return;
    }

    NSArray<NSDate *> *autoOutputList = [self.anyStreamedStereoAppliesJump eachPenPack];
    if (autoOutputList.count == 0) {
        UIAlertController *lease = [UIAlertController alertControllerWithTitle:behaviorHue.highestDirtyCharAllMillProxy
                                                                       message:behaviorHue.functionsClampingItemSchoolInvitedTen
                                                                preferredStyle:UIAlertControllerStyleAlert];
        [lease addAction:[UIAlertAction actionWithTitle:behaviorHue.pressedFiveHusbandSearchingCiphersRequire style:UIAlertActionStyleDefault handler:nil]];
        [self presentViewController:lease animated:YES completion:nil];
        return;
    }

    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:behaviorHue.decayCommentsSignatureDetermineCleanupSafetyChat
                                                                         message:nil
                                                                  preferredStyle:UIAlertControllerStyleActionSheet];

    [actionSheet addAction:[UIAlertAction actionWithTitle:behaviorHue.gradientPedometerFlightTornadoFunRetrieve
                                                    style:UIAlertActionStyleDefault
                                                  handler:^(UIAlertAction *action) {
        self.selectedDate = nil;
        [self popVital];
    }]];

    NSDateFormatter *panDegree = [[NSDateFormatter alloc] init];
    panDegree.dateFormat = behaviorHue.mildContentChatRoundPhaseLocalizesStay;

    NSCalendar *calendar = [NSCalendar currentCalendar];

    for (NSDate *date in autoOutputList) {
        NSString *title;
        if ([calendar isDateInToday:date]) {
            title = behaviorHue.safariUndonePreparingDuplexLabeledEnergy;
        } else if ([calendar isDateInYesterday:date]) {
            title = behaviorHue.trimmingClinicalChlorideCatKirghizIntegrateFirst;
        } else {
            title = [panDegree stringFromDate:date];
        }

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

    [actionSheet addAction:[UIAlertAction actionWithTitle:behaviorHue.itsCheckerMainPasswordOneLater style:UIAlertActionStyleCancel handler:nil]];

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

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

- (void)cycleAction {
    if (!self.anyStreamedStereoAppliesJump) {
        return;
    }

    NSArray *compound = [self.anyStreamedStereoAppliesJump declinedBox];
    if (compound.count == 0) {
        UIAlertController *lease = [UIAlertController alertControllerWithTitle:behaviorHue.highestDirtyCharAllMillProxy
                                                                       message:behaviorHue.flipKoreanHighestExcludeSobNumber
                                                                preferredStyle:UIAlertControllerStyleAlert];
        [lease addAction:[UIAlertAction actionWithTitle:behaviorHue.pressedFiveHusbandSearchingCiphersRequire style:UIAlertActionStyleDefault handler:nil]];
        [self presentViewController:lease animated:YES completion:nil];
        return;
    }

    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:behaviorHue.echoSmoothedManWristBlackStylusLigatures
                                                                         message:nil
                                                                  preferredStyle:UIAlertControllerStyleActionSheet];

    [actionSheet addAction:[UIAlertAction actionWithTitle:behaviorHue.resizingPositionsSnapshotSecondsLigatureStandDictation
                                                    style:UIAlertActionStyleDefault
                                                  handler:^(UIAlertAction *action) {
        [self runSplatEdit];
    }]];

    for (NSURL *fileURL in compound) {
        NSString *fileName = fileURL.lastPathComponent;
        [actionSheet addAction:[UIAlertAction actionWithTitle:[NSString stringWithFormat:behaviorHue.decimalKelvinEvaluatedEasyInvokeInternalSpring, fileName]
                                                        style:UIAlertActionStyleDefault
                                                      handler:^(UIAlertAction *action) {
            [self receivedFile:fileURL];
        }]];
    }

    [actionSheet addAction:[UIAlertAction actionWithTitle:behaviorHue.itsCheckerMainPasswordOneLater style:UIAlertActionStyleCancel handler:nil]];

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

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

- (void)runSplatEdit {
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        
        NSString *flagCar = [self.anyStreamedStereoAppliesJump selfChunkyEdga];

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

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

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

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

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

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

@end
