

#import "ThemeViewController.h"
#import "Strip.h"
#import "BehaveHelloUpperDissolveOptionObject.h"
#import "MinSixCapsDisablingTags.h"
#import "BarJustTryConfig.h"

@interface ThemeViewController ()
@property (nonatomic, strong) UITextView *textView;
@property (nonatomic, strong) BehaveHelloUpperDissolveOptionObject *restoringUnifiedReceivedPositionPassively;
@property (nonatomic, strong) MinSixCapsDisablingTags *exportEyeBlackSurfaceEnd;
@property (nonatomic, strong) NSDate *selectedDate; 
@end

static MinSixCapsDisablingTags *canonRemembersBankFreestyleQuotationStay = nil;
static BehaveHelloUpperDissolveOptionObject *hintPlainFreeReorderQueuePut = nil;

@implementation ThemeViewController

+ (void)anyKitMagic {
    
    [Strip advertiseRowsDarkBlackSiblingsSegue];

    hintPlainFreeReorderQueuePut = [[BehaveHelloUpperDissolveOptionObject alloc] init];
    hintPlainFreeReorderQueuePut.expandLevel = SoftnessIgnorePreciseElapsedIntegrity;

    [Strip bookSodiumArmActivatedPrototype:hintPlainFreeReorderQueuePut];

    canonRemembersBankFreestyleQuotationStay = [[MinSixCapsDisablingTags alloc] init];
    canonRemembersBankFreestyleQuotationStay.expandLevel = RowsFatTapCar;
    canonRemembersBankFreestyleQuotationStay.seeKeep = 7;
    canonRemembersBankFreestyleQuotationStay.mustCollisionExactnessUndoGray = YES;
    [Strip bookSodiumArmActivatedPrototype:canonRemembersBankFreestyleQuotationStay];

    [canonRemembersBankFreestyleQuotationStay kinWayStoneBig];
}

+ (MinSixCapsDisablingTags *)frameYoungestRandomMaxHintCalcium {
    return canonRemembersBankFreestyleQuotationStay;
}
+ (BehaveHelloUpperDissolveOptionObject *)cleanCheckerRowProductsSystolicDistinct {
    return hintPlainFreeReorderQueuePut;
}

- (BehaveHelloUpperDissolveOptionObject *)restoringUnifiedReceivedPositionPassively {
    return hintPlainFreeReorderQueuePut;
}

+ (void)documentViewController:(UIViewController *)parentVC {
    ThemeViewController *tilde = [[ThemeViewController alloc] init];
    UINavigationController *big = [[UINavigationController alloc] initWithRootViewController:tilde];
    big.modalPresentationStyle = UIModalPresentationFullScreen;
    [parentVC presentViewController:big animated:YES completion:nil];
}

- (void)viewDidLoad {
    [super viewDidLoad];

    self.title = startArabic.overhangOverwriteFlemishRespectsSliceWon;
    self.view.backgroundColor = [UIColor systemBackgroundColor];

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

    self.navigationItem.rightBarButtonItems = @[
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh
                                                      target:self
                                                      action:@selector(binTallAction)],
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction
                                                      target:self
                                                      action:@selector(shareAction)],
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemBookmarks
                                                      target:self
                                                      action:@selector(tailInlandAction)]
    ];
    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.exportEyeBlackSurfaceEnd = [ThemeViewController frameYoungestRandomMaxHintCalcium];

    [self humidity];
}

- (void)humidity {
    if (!self.exportEyeBlackSurfaceEnd) {
        _textView.text = startArabic.cutFinishingOurRawPoolDimension;
        return;
    }

    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        NSString *logs;
        if (self.selectedDate) {
            logs = [self.exportEyeBlackSurfaceEnd eggTowerTwoDate:self.selectedDate];
        } else {
            logs = [self.exportEyeBlackSurfaceEnd stopTopHigh];
        }

        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 = startArabic.misplacedHashReduceFragmentWinPreviews;
            }

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

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

- (void)binTallAction {
    [self humidity];
}

- (void)updateTitle {
    if (self.selectedDate) {
        NSDateFormatter *shotReuse = [[NSDateFormatter alloc] init];
        shotReuse.dateFormat = startArabic.headsetAccessedIncrementCautionKeyKindProfiles;
        NSString *dateString = [shotReuse stringFromDate:self.selectedDate];

        NSCalendar *calendar = [NSCalendar currentCalendar];
        if ([calendar isDateInToday:self.selectedDate]) {
            self.title = startArabic.beganCheckPreventsVerticalPrimaryIndent;
        } else if ([calendar isDateInYesterday:self.selectedDate]) {
            self.title = startArabic.kindLogFractionsTenCreditsHerTrimming;
        } else {
            self.title = dateString;
        }
    } else {
        self.title = startArabic.suchSnowCriteriaRecorderGradePlace;
    }
}

- (void)tailInlandAction {
    if (!self.exportEyeBlackSurfaceEnd) {
        return;
    }

    NSArray<NSDate *> *bendArteryLose = [self.exportEyeBlackSurfaceEnd sexBikeWork];
    if (bendArteryLose.count == 0) {
        UIAlertController *china = [UIAlertController alertControllerWithTitle:startArabic.awakeIndexSunEqualTwentyConjugate
                                                                       message:startArabic.misplacedHashReduceFragmentWinPreviews
                                                                preferredStyle:UIAlertControllerStyleAlert];
        [china addAction:[UIAlertAction actionWithTitle:startArabic.shapeFactoryWelshFlemishDownRoom style:UIAlertActionStyleDefault handler:nil]];
        [self presentViewController:china animated:YES completion:nil];
        return;
    }

    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:startArabic.lostCyclingCheckProvidersCalendarAnchorViolation
                                                                         message:nil
                                                                  preferredStyle:UIAlertControllerStyleActionSheet];

    [actionSheet addAction:[UIAlertAction actionWithTitle:startArabic.suchSnowCriteriaRecorderGradePlace
                                                    style:UIAlertActionStyleDefault
                                                  handler:^(UIAlertAction *action) {
        self.selectedDate = nil;
        [self humidity];
    }]];

    NSDateFormatter *shotReuse = [[NSDateFormatter alloc] init];
    shotReuse.dateFormat = startArabic.headsetAccessedIncrementCautionKeyKindProfiles;

    NSCalendar *calendar = [NSCalendar currentCalendar];

    for (NSDate *date in bendArteryLose) {
        NSString *title;
        if ([calendar isDateInToday:date]) {
            title = startArabic.beganCheckPreventsVerticalPrimaryIndent;
        } else if ([calendar isDateInYesterday:date]) {
            title = startArabic.kindLogFractionsTenCreditsHerTrimming;
        } else {
            title = [shotReuse stringFromDate:date];
        }

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

    [actionSheet addAction:[UIAlertAction actionWithTitle:startArabic.expiredEndpointBoxFourthAirMinute style:UIAlertActionStyleCancel handler:nil]];

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

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

- (void)shareAction {
    if (!self.exportEyeBlackSurfaceEnd) {
        return;
    }

    NSArray *cacheCan = [self.exportEyeBlackSurfaceEnd costFoodFun];
    if (cacheCan.count == 0) {
        UIAlertController *china = [UIAlertController alertControllerWithTitle:startArabic.awakeIndexSunEqualTwentyConjugate
                                                                       message:startArabic.skippedDecimalLightenSpellLoudOut
                                                                preferredStyle:UIAlertControllerStyleAlert];
        [china addAction:[UIAlertAction actionWithTitle:startArabic.shapeFactoryWelshFlemishDownRoom style:UIAlertActionStyleDefault handler:nil]];
        [self presentViewController:china animated:YES completion:nil];
        return;
    }

    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:startArabic.tagsFarFavoritesSensorEmergencySilentCharacter
                                                                         message:nil
                                                                  preferredStyle:UIAlertControllerStyleActionSheet];

    [actionSheet addAction:[UIAlertAction actionWithTitle:startArabic.subReplyPhoneBlurEarPopDisorder
                                                    style:UIAlertActionStyleDefault
                                                  handler:^(UIAlertAction *action) {
        [self mapPagerGasp];
    }]];

    for (NSURL *fileURL in cacheCan) {
        NSString *fileName = fileURL.lastPathComponent;
        [actionSheet addAction:[UIAlertAction actionWithTitle:[NSString stringWithFormat:startArabic.revealSymbolsCoastProcessSilenceRecoveryChecking, fileName]
                                                        style:UIAlertActionStyleDefault
                                                      handler:^(UIAlertAction *action) {
            [self cupPressFile:fileURL];
        }]];
    }

    [actionSheet addAction:[UIAlertAction actionWithTitle:startArabic.expiredEndpointBoxFourthAirMinute style:UIAlertActionStyleCancel handler:nil]];

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

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

- (void)mapPagerGasp {
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        
        NSString *turkmen = [self.exportEyeBlackSurfaceEnd fiveDarkerMind];

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

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

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

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

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

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

@end
