

#import "BoundViewController.h"
#import "Polar.h"
#import "ForEventBitmapGenericRetainRing.h"
#import "SucceededDeepBusDistinctMobile.h"
#import "ArmpitMathConfig.h"

@interface BoundViewController ()
@property (nonatomic, strong) UITextView *textView;
@property (nonatomic, strong) ForEventBitmapGenericRetainRing *removableTranslateCountedHelpConvert;
@property (nonatomic, strong) SucceededDeepBusDistinctMobile *dictationDriveGatherBoxTelephony;
@property (nonatomic, strong) NSDate *selectedDate; 
@end

static SucceededDeepBusDistinctMobile *deltaSlashesUkrainianExportForkPrimary = nil;
static ForEventBitmapGenericRetainRing *bouncingAddGreatBaseAlpineMore = nil;

@implementation BoundViewController

+ (void)photoSphere {
    
    [Polar depthPointerPassiveMegahertzRedEncrypt];

    bouncingAddGreatBaseAlpineMore = [[ForEventBitmapGenericRetainRing alloc] init];
    bouncingAddGreatBaseAlpineMore.outputLevel = CommentsMalayVowelProposalConsumes;

    [Polar handleVowelLaunchingReachableTriangle:bouncingAddGreatBaseAlpineMore];

    deltaSlashesUkrainianExportForkPrimary = [[SucceededDeepBusDistinctMobile alloc] init];
    deltaSlashesUkrainianExportForkPrimary.outputLevel = TapJobSobHash;
    deltaSlashesUkrainianExportForkPrimary.scanner = 7;
    deltaSlashesUkrainianExportForkPrimary.trailingReportedFocusFocusesLong = YES;
    [Polar handleVowelLaunchingReachableTriangle:deltaSlashesUkrainianExportForkPrimary];

    [deltaSlashesUkrainianExportForkPrimary bondTheMeanShe];
}

+ (SucceededDeepBusDistinctMobile *)flipCelsiusLikeExternSerialThick {
    return deltaSlashesUkrainianExportForkPrimary;
}
+ (ForEventBitmapGenericRetainRing *)playAppleInvertedReceiveRevertingArrow {
    return bouncingAddGreatBaseAlpineMore;
}

- (ForEventBitmapGenericRetainRing *)removableTranslateCountedHelpConvert {
    return bouncingAddGreatBaseAlpineMore;
}

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

- (void)viewDidLoad {
    [super viewDidLoad];

    self.title = foldPlayLog.eraArmYellowUnsavedThinSite;
    self.view.backgroundColor = [UIColor systemBackgroundColor];

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

    self.navigationItem.rightBarButtonItems = @[
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh
                                                      target:self
                                                      action:@selector(rareHowAction)],
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction
                                                      target:self
                                                      action:@selector(boostAction)],
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemBookmarks
                                                      target:self
                                                      action:@selector(audioUsageAction)]
    ];
    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.dictationDriveGatherBoxTelephony = [BoundViewController flipCelsiusLikeExternSerialThick];

    [self yetQueue];
}

- (void)yetQueue {
    if (!self.dictationDriveGatherBoxTelephony) {
        _textView.text = foldPlayLog.scriptsParentalAzimuthOrnamentsSongArray;
        return;
    }

    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        NSString *logs;
        if (self.selectedDate) {
            logs = [self.dictationDriveGatherBoxTelephony farPanSliceDate:self.selectedDate];
        } else {
            logs = [self.dictationDriveGatherBoxTelephony sawTagDatum];
        }

        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 = foldPlayLog.semicolonLowBordersInvitedEncodingLift;
            }

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

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

- (void)rareHowAction {
    [self yetQueue];
}

- (void)updateTitle {
    if (self.selectedDate) {
        NSDateFormatter *searchThe = [[NSDateFormatter alloc] init];
        searchThe.dateFormat = foldPlayLog.leapProtectedThreePatternPlateFarAdjust;
        NSString *wristMolar = [searchThe stringFromDate:self.selectedDate];

        NSCalendar *calendar = [NSCalendar currentCalendar];
        if ([calendar isDateInToday:self.selectedDate]) {
            self.title = foldPlayLog.markPullTintPubHitArtist;
        } else if ([calendar isDateInYesterday:self.selectedDate]) {
            self.title = foldPlayLog.opacityPersonalElevenListenBaseballDecrementTrainer;
        } else {
            self.title = wristMolar;
        }
    } else {
        self.title = foldPlayLog.yardBleedMixConjugateNearestOwnership;
    }
}

- (void)audioUsageAction {
    if (!self.dictationDriveGatherBoxTelephony) {
        return;
    }

    NSArray<NSDate *> *dayRearTabList = [self.dictationDriveGatherBoxTelephony bestOwnWeek];
    if (dayRearTabList.count == 0) {
        UIAlertController *molar = [UIAlertController alertControllerWithTitle:foldPlayLog.incomingCubeInferOddHairOne
                                                                       message:foldPlayLog.semicolonLowBordersInvitedEncodingLift
                                                                preferredStyle:UIAlertControllerStyleAlert];
        [molar addAction:[UIAlertAction actionWithTitle:foldPlayLog.mismatchPolicyStackedContactsIterationGet style:UIAlertActionStyleDefault handler:nil]];
        [self presentViewController:molar animated:YES completion:nil];
        return;
    }

    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:foldPlayLog.optStairZoneDeleteNotifyingAnalysisOur
                                                                         message:nil
                                                                  preferredStyle:UIAlertControllerStyleActionSheet];

    [actionSheet addAction:[UIAlertAction actionWithTitle:foldPlayLog.yardBleedMixConjugateNearestOwnership
                                                    style:UIAlertActionStyleDefault
                                                  handler:^(UIAlertAction *action) {
        self.selectedDate = nil;
        [self yetQueue];
    }]];

    NSDateFormatter *searchThe = [[NSDateFormatter alloc] init];
    searchThe.dateFormat = foldPlayLog.leapProtectedThreePatternPlateFarAdjust;

    NSCalendar *calendar = [NSCalendar currentCalendar];

    for (NSDate *date in dayRearTabList) {
        NSString *title;
        if ([calendar isDateInToday:date]) {
            title = foldPlayLog.markPullTintPubHitArtist;
        } else if ([calendar isDateInYesterday:date]) {
            title = foldPlayLog.opacityPersonalElevenListenBaseballDecrementTrainer;
        } else {
            title = [searchThe stringFromDate:date];
        }

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

    [actionSheet addAction:[UIAlertAction actionWithTitle:foldPlayLog.removeSecretChargeBadgeThreeCalories style:UIAlertActionStyleCancel handler:nil]];

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

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

- (void)boostAction {
    if (!self.dictationDriveGatherBoxTelephony) {
        return;
    }

    NSArray *occurHer = [self.dictationDriveGatherBoxTelephony ownAxialBox];
    if (occurHer.count == 0) {
        UIAlertController *molar = [UIAlertController alertControllerWithTitle:foldPlayLog.incomingCubeInferOddHairOne
                                                                       message:foldPlayLog.formatPrinterSegmentedIllegalBinRed
                                                                preferredStyle:UIAlertControllerStyleAlert];
        [molar addAction:[UIAlertAction actionWithTitle:foldPlayLog.mismatchPolicyStackedContactsIterationGet style:UIAlertActionStyleDefault handler:nil]];
        [self presentViewController:molar animated:YES completion:nil];
        return;
    }

    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:foldPlayLog.zeroMoveRawFocusMoireWonNap
                                                                         message:nil
                                                                  preferredStyle:UIAlertControllerStyleActionSheet];

    [actionSheet addAction:[UIAlertAction actionWithTitle:foldPlayLog.textualNotOutSmallForbiddenRenameEighteen
                                                    style:UIAlertActionStyleDefault
                                                  handler:^(UIAlertAction *action) {
        [self wayPenAppear];
    }]];

    for (NSURL *fileURL in occurHer) {
        NSString *fileName = fileURL.lastPathComponent;
        [actionSheet addAction:[UIAlertAction actionWithTitle:[NSString stringWithFormat:foldPlayLog.eulerBengaliDisappearHyphensUsesTwistSynthesis, fileName]
                                                        style:UIAlertActionStyleDefault
                                                      handler:^(UIAlertAction *action) {
            [self pinkGolfFile:fileURL];
        }]];
    }

    [actionSheet addAction:[UIAlertAction actionWithTitle:foldPlayLog.removeSecretChargeBadgeThreeCalories style:UIAlertActionStyleCancel handler:nil]];

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

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

- (void)wayPenAppear {
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        
        NSString *chinese = [self.dictationDriveGatherBoxTelephony digitalClimbed];

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

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

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

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

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

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

@end
