

#import "AngleViewController.h"
#import "Bound.h"
#import "ProducerAreStrategyIncreaseLogHour.h"
#import "EstimatedSpeakerSeedTenFull.h"
#import "MarkDivideConfig.h"

@interface AngleViewController ()
@property (nonatomic, strong) UITextView *textView;
@property (nonatomic, strong) ProducerAreStrategyIncreaseLogHour *multipleDeleteOrnamentMayArray;
@property (nonatomic, strong) EstimatedSpeakerSeedTenFull *indexesAbsentSignaturePenDigest;
@property (nonatomic, strong) NSDate *selectedDate; 
@end

static EstimatedSpeakerSeedTenFull *eraStartupDrawingYouPlaceHand = nil;
static ProducerAreStrategyIncreaseLogHour *herSegmentPeerAdjustRedefinedCoulombs = nil;

@implementation AngleViewController

+ (void)shapeAmpere {
    
    [Bound smallFunControlUnderApertureChain];

    herSegmentPeerAdjustRedefinedCoulombs = [[ProducerAreStrategyIncreaseLogHour alloc] init];
    herSegmentPeerAdjustRedefinedCoulombs.oxygenLevel = BigBoxConsumedSemanticComplex;

    [Bound monitoredSuccessUpdatesBorderCity:herSegmentPeerAdjustRedefinedCoulombs];

    eraStartupDrawingYouPlaceHand = [[EstimatedSpeakerSeedTenFull alloc] init];
    eraStartupDrawingYouPlaceHand.oxygenLevel = MapCupMargins;
    eraStartupDrawingYouPlaceHand.sliding = 7;
    eraStartupDrawingYouPlaceHand.wetAtomFinishingMagentaStair = YES;
    [Bound monitoredSuccessUpdatesBorderCity:eraStartupDrawingYouPlaceHand];

    [eraStartupDrawingYouPlaceHand yetAreSugarTry];
}

+ (EstimatedSpeakerSeedTenFull *)lineOldEitherMightOptPlayback {
    return eraStartupDrawingYouPlaceHand;
}
+ (ProducerAreStrategyIncreaseLogHour *)calendarNordicObserversImproperHeartbeatDue {
    return herSegmentPeerAdjustRedefinedCoulombs;
}

- (ProducerAreStrategyIncreaseLogHour *)multipleDeleteOrnamentMayArray {
    return herSegmentPeerAdjustRedefinedCoulombs;
}

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

- (void)viewDidLoad {
    [super viewDidLoad];

    self.title = containsFor.darkCollectedSugarEndSizeResolved;
    self.view.backgroundColor = [UIColor systemBackgroundColor];

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

    self.navigationItem.rightBarButtonItems = @[
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh
                                                      target:self
                                                      action:@selector(createdAction)],
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction
                                                      target:self
                                                      action:@selector(givenAction)],
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemBookmarks
                                                      target:self
                                                      action:@selector(typeSayWhoAction)]
    ];
    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.indexesAbsentSignaturePenDigest = [AngleViewController lineOldEitherMightOptPlayback];

    [self ratioWho];
}

- (void)ratioWho {
    if (!self.indexesAbsentSignaturePenDigest) {
        _textView.text = containsFor.adoptMultipleMustSixTreeRole;
        return;
    }

    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        NSString *logs;
        if (self.selectedDate) {
            logs = [self.indexesAbsentSignaturePenDigest flipVitaminDate:self.selectedDate];
        } else {
            logs = [self.indexesAbsentSignaturePenDigest cupPoloIdle];
        }

        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 = containsFor.beatRevokedReliableAddressesObjectExtension;
            }

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

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

- (void)createdAction {
    [self ratioWho];
}

- (void)updateTitle {
    if (self.selectedDate) {
        NSDateFormatter *updateKey = [[NSDateFormatter alloc] init];
        updateKey.dateFormat = containsFor.logicalReleaseNodeMinNotifyingPresenterAnd;
        NSString *bitHueMain = [updateKey stringFromDate:self.selectedDate];

        NSCalendar *calendar = [NSCalendar currentCalendar];
        if ([calendar isDateInToday:self.selectedDate]) {
            self.title = containsFor.combinePushAdvancedCapGlyphStartup;
        } else if ([calendar isDateInYesterday:self.selectedDate]) {
            self.title = containsFor.warnCategoryUpdatesAdvertiseWorkspaceKannadaBin;
        } else {
            self.title = bitHueMain;
        }
    } else {
        self.title = containsFor.profileSymptomAttitudeLeadPlayTap;
    }
}

- (void)typeSayWhoAction {
    if (!self.indexesAbsentSignaturePenDigest) {
        return;
    }

    NSArray<NSDate *> *busTiedBitsGet = [self.indexesAbsentSignaturePenDigest sameElastic];
    if (busTiedBitsGet.count == 0) {
        UIAlertController *boost = [UIAlertController alertControllerWithTitle:containsFor.selectorsBetterLargeDivideGloballyAmpere
                                                                       message:containsFor.beatRevokedReliableAddressesObjectExtension
                                                                preferredStyle:UIAlertControllerStyleAlert];
        [boost addAction:[UIAlertAction actionWithTitle:containsFor.expirePastePanLooseNotSpotlight style:UIAlertActionStyleDefault handler:nil]];
        [self presentViewController:boost animated:YES completion:nil];
        return;
    }

    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:containsFor.silencedPrintScrollingLossCellularDitheredStorm
                                                                         message:nil
                                                                  preferredStyle:UIAlertControllerStyleActionSheet];

    [actionSheet addAction:[UIAlertAction actionWithTitle:containsFor.profileSymptomAttitudeLeadPlayTap
                                                    style:UIAlertActionStyleDefault
                                                  handler:^(UIAlertAction *action) {
        self.selectedDate = nil;
        [self ratioWho];
    }]];

    NSDateFormatter *updateKey = [[NSDateFormatter alloc] init];
    updateKey.dateFormat = containsFor.logicalReleaseNodeMinNotifyingPresenterAnd;

    NSCalendar *calendar = [NSCalendar currentCalendar];

    for (NSDate *date in busTiedBitsGet) {
        NSString *title;
        if ([calendar isDateInToday:date]) {
            title = containsFor.combinePushAdvancedCapGlyphStartup;
        } else if ([calendar isDateInYesterday:date]) {
            title = containsFor.warnCategoryUpdatesAdvertiseWorkspaceKannadaBin;
        } else {
            title = [updateKey stringFromDate:date];
        }

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

    [actionSheet addAction:[UIAlertAction actionWithTitle:containsFor.categorySayDoubleDutchRuleSummary style:UIAlertActionStyleCancel handler:nil]];

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

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

- (void)givenAction {
    if (!self.indexesAbsentSignaturePenDigest) {
        return;
    }

    NSArray *artHover = [self.indexesAbsentSignaturePenDigest methodApple];
    if (artHover.count == 0) {
        UIAlertController *boost = [UIAlertController alertControllerWithTitle:containsFor.selectorsBetterLargeDivideGloballyAmpere
                                                                       message:containsFor.audienceBarAttachedArmpitTenGlyph
                                                                preferredStyle:UIAlertControllerStyleAlert];
        [boost addAction:[UIAlertAction actionWithTitle:containsFor.expirePastePanLooseNotSpotlight style:UIAlertActionStyleDefault handler:nil]];
        [self presentViewController:boost animated:YES completion:nil];
        return;
    }

    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:containsFor.tagsNoteCupActualRevertAirFourth
                                                                         message:nil
                                                                  preferredStyle:UIAlertControllerStyleActionSheet];

    [actionSheet addAction:[UIAlertAction actionWithTitle:containsFor.bigScaleDueCornerYearHandoverBroken
                                                    style:UIAlertActionStyleDefault
                                                  handler:^(UIAlertAction *action) {
        [self zeroPlaneHow];
    }]];

    for (NSURL *fileURL in artHover) {
        NSString *fileName = fileURL.lastPathComponent;
        [actionSheet addAction:[UIAlertAction actionWithTitle:[NSString stringWithFormat:containsFor.fetchedCrossTriangleRadixPromptSchemesSay, fileName]
                                                        style:UIAlertActionStyleDefault
                                                      handler:^(UIAlertAction *action) {
            [self sixWhiteFile:fileURL];
        }]];
    }

    [actionSheet addAction:[UIAlertAction actionWithTitle:containsFor.categorySayDoubleDutchRuleSummary style:UIAlertActionStyleCancel handler:nil]];

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

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

- (void)zeroPlaneHow {
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        
        NSString *retRoom = [self.indexesAbsentSignaturePenDigest yahooSpacePint];

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

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

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

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

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

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

@end
