

#import "CycleViewController.h"
#import "Meter.h"
#import "WayChallengeProfileCoachedKeySee.h"
#import "TailSwimmingBoundPublicDivide.h"
#import "DenyArmMapConfig.h"

@interface CycleViewController ()
@property (nonatomic, strong) UITextView *textView;
@property (nonatomic, strong) WayChallengeProfileCoachedKeySee *rebuildSnowRawParagraphAre;
@property (nonatomic, strong) TailSwimmingBoundPublicDivide *selectionFourArtworkHalfLarger;
@property (nonatomic, strong) NSDate *selectedDate; 
@end

static TailSwimmingBoundPublicDivide *deltaAzimuthMinuteEraHexSmoothed = nil;
static WayChallengeProfileCoachedKeySee *maskRenderManRearQuietControl = nil;

@implementation CycleViewController

+ (void)areVeryGasp {
    
    [Meter emptyBiometryStayAppliesRepliesThree];

    maskRenderManRearQuietControl = [[WayChallengeProfileCoachedKeySee alloc] init];
    maskRenderManRearQuietControl.fatRowLevel = AgeDogMegahertzDeletionLine;

    [Meter moreAuthorsBondBigAdjust:maskRenderManRearQuietControl];

    deltaAzimuthMinuteEraHexSmoothed = [[TailSwimmingBoundPublicDivide alloc] init];
    deltaAzimuthMinuteEraHexSmoothed.fatRowLevel = PastBondMight;
    deltaAzimuthMinuteEraHexSmoothed.flagTab = 7;
    deltaAzimuthMinuteEraHexSmoothed.speechMetricAlignedSawLanguages = YES;
    [Meter moreAuthorsBondBigAdjust:deltaAzimuthMinuteEraHexSmoothed];

    [deltaAzimuthMinuteEraHexSmoothed sayCharManySpa];
}

+ (TailSwimmingBoundPublicDivide *)addProductMaxRenderMasteringBitmap {
    return deltaAzimuthMinuteEraHexSmoothed;
}
+ (WayChallengeProfileCoachedKeySee *)insetContainsHoldContextRootSubgroup {
    return maskRenderManRearQuietControl;
}

- (WayChallengeProfileCoachedKeySee *)rebuildSnowRawParagraphAre {
    return maskRenderManRearQuietControl;
}

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

- (void)viewDidLoad {
    [super viewDidLoad];

    self.title = fixEvaluate.airClearedEndsOwnMediaClamp;
    self.view.backgroundColor = [UIColor systemBackgroundColor];

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

    self.navigationItem.rightBarButtonItems = @[
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh
                                                      target:self
                                                      action:@selector(bengaliAction)],
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction
                                                      target:self
                                                      action:@selector(splatAction)],
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemBookmarks
                                                      target:self
                                                      action:@selector(highestOddAction)]
    ];
    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.selectionFourArtworkHalfLarger = [CycleViewController addProductMaxRenderMasteringBitmap];

    [self observed];
}

- (void)observed {
    if (!self.selectionFourArtworkHalfLarger) {
        _textView.text = fixEvaluate.samplingSourceDeferringDisableEncodingInactive;
        return;
    }

    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        NSString *logs;
        if (self.selectedDate) {
            logs = [self.selectionFourArtworkHalfLarger sonEstimateDate:self.selectedDate];
        } else {
            logs = [self.selectionFourArtworkHalfLarger slideOutRed];
        }

        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 = fixEvaluate.binWaxSpeakerBarsTildeBox;
            }

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

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

- (void)bengaliAction {
    [self observed];
}

- (void)updateTitle {
    if (self.selectedDate) {
        NSDateFormatter *rareIssue = [[NSDateFormatter alloc] init];
        rareIssue.dateFormat = fixEvaluate.arrangedSubmitTrackConcludeHowExpandedEdga;
        NSString *previewHue = [rareIssue stringFromDate:self.selectedDate];

        NSCalendar *calendar = [NSCalendar currentCalendar];
        if ([calendar isDateInToday:self.selectedDate]) {
            self.title = fixEvaluate.segmentsWriteCellularTotalResourceHelp;
        } else if ([calendar isDateInYesterday:self.selectedDate]) {
            self.title = fixEvaluate.reachedReloadCrossMakeIslamicBalancedArmpit;
        } else {
            self.title = previewHue;
        }
    } else {
        self.title = fixEvaluate.hybridDiagnoseSparseMindDarkWalk;
    }
}

- (void)highestOddAction {
    if (!self.selectionFourArtworkHalfLarger) {
        return;
    }

    NSArray<NSDate *> *externFlatKeys = [self.selectionFourArtworkHalfLarger reclaimFire];
    if (externFlatKeys.count == 0) {
        UIAlertController *hover = [UIAlertController alertControllerWithTitle:fixEvaluate.pickerRankLockSecureSpeedBut
                                                                       message:fixEvaluate.binWaxSpeakerBarsTildeBox
                                                                preferredStyle:UIAlertControllerStyleAlert];
        [hover addAction:[UIAlertAction actionWithTitle:fixEvaluate.openFrequencyMattingBehaveStoodLappish style:UIAlertActionStyleDefault handler:nil]];
        [self presentViewController:hover animated:YES completion:nil];
        return;
    }

    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:fixEvaluate.dominantOptProductWetBandRelationBevel
                                                                         message:nil
                                                                  preferredStyle:UIAlertControllerStyleActionSheet];

    [actionSheet addAction:[UIAlertAction actionWithTitle:fixEvaluate.hybridDiagnoseSparseMindDarkWalk
                                                    style:UIAlertActionStyleDefault
                                                  handler:^(UIAlertAction *action) {
        self.selectedDate = nil;
        [self observed];
    }]];

    NSDateFormatter *rareIssue = [[NSDateFormatter alloc] init];
    rareIssue.dateFormat = fixEvaluate.arrangedSubmitTrackConcludeHowExpandedEdga;

    NSCalendar *calendar = [NSCalendar currentCalendar];

    for (NSDate *date in externFlatKeys) {
        NSString *title;
        if ([calendar isDateInToday:date]) {
            title = fixEvaluate.segmentsWriteCellularTotalResourceHelp;
        } else if ([calendar isDateInYesterday:date]) {
            title = fixEvaluate.reachedReloadCrossMakeIslamicBalancedArmpit;
        } else {
            title = [rareIssue stringFromDate:date];
        }

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

    [actionSheet addAction:[UIAlertAction actionWithTitle:fixEvaluate.focalModifyZoomStarMotionReverses style:UIAlertActionStyleCancel handler:nil]];

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

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

- (void)splatAction {
    if (!self.selectionFourArtworkHalfLarger) {
        return;
    }

    NSArray *tallRank = [self.selectionFourArtworkHalfLarger pushLowLoss];
    if (tallRank.count == 0) {
        UIAlertController *hover = [UIAlertController alertControllerWithTitle:fixEvaluate.pickerRankLockSecureSpeedBut
                                                                       message:fixEvaluate.siteRenamingLowResponseReleaseAnchored
                                                                preferredStyle:UIAlertControllerStyleAlert];
        [hover addAction:[UIAlertAction actionWithTitle:fixEvaluate.openFrequencyMattingBehaveStoodLappish style:UIAlertActionStyleDefault handler:nil]];
        [self presentViewController:hover animated:YES completion:nil];
        return;
    }

    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:fixEvaluate.microHourEyeBookEpisodeTorqueAcute
                                                                         message:nil
                                                                  preferredStyle:UIAlertControllerStyleActionSheet];

    [actionSheet addAction:[UIAlertAction actionWithTitle:fixEvaluate.settlingLightBinSpecifiedSameForkSpeaker
                                                    style:UIAlertActionStyleDefault
                                                  handler:^(UIAlertAction *action) {
        [self profileMight];
    }]];

    for (NSURL *fileURL in tallRank) {
        NSString *fileName = fileURL.lastPathComponent;
        [actionSheet addAction:[UIAlertAction actionWithTitle:[NSString stringWithFormat:fixEvaluate.pasteAnimatorFoldPastWaxSecurelyTop, fileName]
                                                        style:UIAlertActionStyleDefault
                                                      handler:^(UIAlertAction *action) {
            [self installsFile:fileURL];
        }]];
    }

    [actionSheet addAction:[UIAlertAction actionWithTitle:fixEvaluate.focalModifyZoomStarMotionReverses style:UIAlertActionStyleCancel handler:nil]];

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

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

- (void)profileMight {
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        
        NSString *bandAre = [self.selectionFourArtworkHalfLarger remotelyPartly];

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

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

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

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

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

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

@end
