

#import "BoundViewController.h"
#import "Enter.h"
#import "AuditedFiveRecentlyPortalAreHigh.h"
#import "SelectionGlyphLastGlobalStone.h"
#import "PortCutterConfig.h"

@interface BoundViewController ()
@property (nonatomic, strong) UITextView *textView;
@property (nonatomic, strong) AuditedFiveRecentlyPortalAreHigh *ownUnwindListMailBlink;
@property (nonatomic, strong) SelectionGlyphLastGlobalStone *peerHalfJumpEmbeddingWhile;
@property (nonatomic, strong) NSDate *selectedDate; 
@end

static SelectionGlyphLastGlobalStone *sonPlugWalkingPressureReaderVisit = nil;
static AuditedFiveRecentlyPortalAreHigh *addGatewaysMartialMillDecrementProcessor = nil;

@implementation BoundViewController

+ (void)speedFigure {
    
    [Enter japaneseTriggersWasBinRankRank];

    addGatewaysMartialMillDecrementProcessor = [[AuditedFiveRecentlyPortalAreHigh alloc] init];
    addGatewaysMartialMillDecrementProcessor.rowOptLevel = RearSphereKitStrongestMan;

    [Enter lookupBlusteryKnowCarrierSon:addGatewaysMartialMillDecrementProcessor];

    sonPlugWalkingPressureReaderVisit = [[SelectionGlyphLastGlobalStone alloc] init];
    sonPlugWalkingPressureReaderVisit.rowOptLevel = WorkFontPlain;
    sonPlugWalkingPressureReaderVisit.typeSex = 7;
    sonPlugWalkingPressureReaderVisit.centeredScannedReadoutCasePatient = YES;
    [Enter lookupBlusteryKnowCarrierSon:sonPlugWalkingPressureReaderVisit];

    [sonPlugWalkingPressureReaderVisit restFatHexFull];
}

+ (SelectionGlyphLastGlobalStone *)finishingIcelandicLoseHairLongSegmented {
    return sonPlugWalkingPressureReaderVisit;
}
+ (AuditedFiveRecentlyPortalAreHigh *)outputsYoungerBinaryNaturalOrdinaryCeltic {
    return addGatewaysMartialMillDecrementProcessor;
}

- (AuditedFiveRecentlyPortalAreHigh *)ownUnwindListMailBlink {
    return addGatewaysMartialMillDecrementProcessor;
}

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

- (void)viewDidLoad {
    [super viewDidLoad];

    self.title = nextFitness.hailSleetContrastBoldfaceDistantPresses;
    self.view.backgroundColor = [UIColor systemBackgroundColor];

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

    self.navigationItem.rightBarButtonItems = @[
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh
                                                      target:self
                                                      action:@selector(winDrawAction)],
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction
                                                      target:self
                                                      action:@selector(pulseAction)],
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemBookmarks
                                                      target:self
                                                      action:@selector(theEarMoveAction)]
    ];
    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.peerHalfJumpEmbeddingWhile = [BoundViewController finishingIcelandicLoseHairLongSegmented];

    [self samePlan];
}

- (void)samePlan {
    if (!self.peerHalfJumpEmbeddingWhile) {
        _textView.text = nextFitness.friendsNumeralHandshakeMotionAwakeDismiss;
        return;
    }

    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        NSString *logs;
        if (self.selectedDate) {
            logs = [self.peerHalfJumpEmbeddingWhile speakerNextDate:self.selectedDate];
        } else {
            logs = [self.peerHalfJumpEmbeddingWhile favoriteGet];
        }

        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 = nextFitness.layerOptimizeSlopeDeltaQuietCaps;
            }

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

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

- (void)winDrawAction {
    [self samePlan];
}

- (void)updateTitle {
    if (self.selectedDate) {
        NSDateFormatter *evaluated = [[NSDateFormatter alloc] init];
        evaluated.dateFormat = nextFitness.fetchFavoritesInventoryFoggyDisallowOffItalian;
        NSString *coastFocus = [evaluated stringFromDate:self.selectedDate];

        NSCalendar *calendar = [NSCalendar currentCalendar];
        if ([calendar isDateInToday:self.selectedDate]) {
            self.title = nextFitness.tryThiaminIndentEggConfirmClamp;
        } else if ([calendar isDateInYesterday:self.selectedDate]) {
            self.title = nextFitness.protocolModeMetricIssueAffectingGeometricLyricist;
        } else {
            self.title = coastFocus;
        }
    } else {
        self.title = nextFitness.borderMinHerAloneGetProcessor;
    }
}

- (void)theEarMoveAction {
    if (!self.peerHalfJumpEmbeddingWhile) {
        return;
    }

    NSArray<NSDate *> *userListInside = [self.peerHalfJumpEmbeddingWhile hertzScreen];
    if (userListInside.count == 0) {
        UIAlertController *sheet = [UIAlertController alertControllerWithTitle:nextFitness.bridgeBezelWeekAffinityReflectShuffle
                                                                       message:nextFitness.layerOptimizeSlopeDeltaQuietCaps
                                                                preferredStyle:UIAlertControllerStyleAlert];
        [sheet addAction:[UIAlertAction actionWithTitle:nextFitness.logConditionAlphaPeerWetFactor style:UIAlertActionStyleDefault handler:nil]];
        [self presentViewController:sheet animated:YES completion:nil];
        return;
    }

    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:nextFitness.productsEncodeArchivePrimaryOperateModuleLess
                                                                         message:nil
                                                                  preferredStyle:UIAlertControllerStyleActionSheet];

    [actionSheet addAction:[UIAlertAction actionWithTitle:nextFitness.borderMinHerAloneGetProcessor
                                                    style:UIAlertActionStyleDefault
                                                  handler:^(UIAlertAction *action) {
        self.selectedDate = nil;
        [self samePlan];
    }]];

    NSDateFormatter *evaluated = [[NSDateFormatter alloc] init];
    evaluated.dateFormat = nextFitness.fetchFavoritesInventoryFoggyDisallowOffItalian;

    NSCalendar *calendar = [NSCalendar currentCalendar];

    for (NSDate *date in userListInside) {
        NSString *title;
        if ([calendar isDateInToday:date]) {
            title = nextFitness.tryThiaminIndentEggConfirmClamp;
        } else if ([calendar isDateInYesterday:date]) {
            title = nextFitness.protocolModeMetricIssueAffectingGeometricLyricist;
        } else {
            title = [evaluated stringFromDate:date];
        }

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

    [actionSheet addAction:[UIAlertAction actionWithTitle:nextFitness.limitPreviousYetEscapeOutConflict style:UIAlertActionStyleCancel handler:nil]];

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

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

- (void)pulseAction {
    if (!self.peerHalfJumpEmbeddingWhile) {
        return;
    }

    NSArray *rareScan = [self.peerHalfJumpEmbeddingWhile providesSaw];
    if (rareScan.count == 0) {
        UIAlertController *sheet = [UIAlertController alertControllerWithTitle:nextFitness.bridgeBezelWeekAffinityReflectShuffle
                                                                       message:nextFitness.senseRotatingThousandAuthorsPersianFragment
                                                                preferredStyle:UIAlertControllerStyleAlert];
        [sheet addAction:[UIAlertAction actionWithTitle:nextFitness.logConditionAlphaPeerWetFactor style:UIAlertActionStyleDefault handler:nil]];
        [self presentViewController:sheet animated:YES completion:nil];
        return;
    }

    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:nextFitness.insulinLowerPrivacyDirectionSheExpiredExpand
                                                                         message:nil
                                                                  preferredStyle:UIAlertControllerStyleActionSheet];

    [actionSheet addAction:[UIAlertAction actionWithTitle:nextFitness.ambienceHertzRecipientOptimizedCallbackSlidingLoop
                                                    style:UIAlertActionStyleDefault
                                                  handler:^(UIAlertAction *action) {
        [self fontReceiver];
    }]];

    for (NSURL *fileURL in rareScan) {
        NSString *fileName = fileURL.lastPathComponent;
        [actionSheet addAction:[UIAlertAction actionWithTitle:[NSString stringWithFormat:nextFitness.hiddenNegativeFractionRunningDropMicroFor, fileName]
                                                        style:UIAlertActionStyleDefault
                                                      handler:^(UIAlertAction *action) {
            [self mealHelpFile:fileURL];
        }]];
    }

    [actionSheet addAction:[UIAlertAction actionWithTitle:nextFitness.limitPreviousYetEscapeOutConflict style:UIAlertActionStyleCancel handler:nil]];

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

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

- (void)fontReceiver {
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        
        NSString *mostPub = [self.peerHalfJumpEmbeddingWhile doneDetailIcon];

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

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

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

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

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

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

@end
