

#import "MiterViewController.h"
#import "Datum.h"
#import "SmoothingWideMapExpandedBayerImmutable.h"
#import "ViabilityStepchildTimeMonthPalette.h"
#import "DueBlurNetConfig.h"

@interface MiterViewController ()
@property (nonatomic, strong) UITextView *textView;
@property (nonatomic, strong) SmoothingWideMapExpandedBayerImmutable *seasonSnapFinalSentOxygen;
@property (nonatomic, strong) ViabilityStepchildTimeMonthPalette *expandingCentralsResourcesEastDescender;
@property (nonatomic, strong) NSDate *selectedDate; 
@end

static ViabilityStepchildTimeMonthPalette *hockeyBehaveMultiplyDrainPermittedMessaging = nil;
static SmoothingWideMapExpandedBayerImmutable *lowStationExpertEnhanceTenBurn = nil;

@implementation MiterViewController

+ (void)selectLimit {
    
    [Datum ampereItsSwimmingVariableWebpageFormats];

    lowStationExpertEnhanceTenBurn = [[SmoothingWideMapExpandedBayerImmutable alloc] init];
    lowStationExpertEnhanceTenBurn.bitmapLevel = MalformedAboveDaughtersLabeledSender;

    [Datum lighterLayoutPubSoftnessShort:lowStationExpertEnhanceTenBurn];

    hockeyBehaveMultiplyDrainPermittedMessaging = [[ViabilityStepchildTimeMonthPalette alloc] init];
    hockeyBehaveMultiplyDrainPermittedMessaging.bitmapLevel = FatMaxAllFire;
    hockeyBehaveMultiplyDrainPermittedMessaging.mealDog = 7;
    hockeyBehaveMultiplyDrainPermittedMessaging.justifiedFootersSamplesPermanentHealth = YES;
    [Datum lighterLayoutPubSoftnessShort:hockeyBehaveMultiplyDrainPermittedMessaging];

    [hockeyBehaveMultiplyDrainPermittedMessaging simpleFunkFile];
}

+ (ViabilityStepchildTimeMonthPalette *)throughPinchWaitingLengthFileStretch {
    return hockeyBehaveMultiplyDrainPermittedMessaging;
}
+ (SmoothingWideMapExpandedBayerImmutable *)movementShowersVowelCatSeleniumQuery {
    return lowStationExpertEnhanceTenBurn;
}

- (SmoothingWideMapExpandedBayerImmutable *)seasonSnapFinalSentOxygen {
    return lowStationExpertEnhanceTenBurn;
}

+ (void)didPhotoViewController:(UIViewController *)parentVC {
    MiterViewController *lease = [[MiterViewController alloc] init];
    UINavigationController *arm = [[UINavigationController alloc] initWithRootViewController:lease];
    arm.modalPresentationStyle = UIModalPresentationFullScreen;
    [parentVC presentViewController:arm animated:YES completion:nil];
}

- (void)viewDidLoad {
    [super viewDidLoad];

    self.title = foodFoodFix.depthStandardOvulationShortLengthNegotiate;
    self.view.backgroundColor = [UIColor systemBackgroundColor];

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

    self.navigationItem.rightBarButtonItems = @[
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh
                                                      target:self
                                                      action:@selector(cupHashAction)],
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction
                                                      target:self
                                                      action:@selector(shareAction)],
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemBookmarks
                                                      target:self
                                                      action:@selector(sawWasLessAction)]
    ];
    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.expandingCentralsResourcesEastDescender = [MiterViewController throughPinchWaitingLengthFileStretch];

    [self firstTag];
}

- (void)firstTag {
    if (!self.expandingCentralsResourcesEastDescender) {
        _textView.text = foodFoodFix.argumentsBurnNapBusArgumentAll;
        return;
    }

    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        NSString *logs;
        if (self.selectedDate) {
            logs = [self.expandingCentralsResourcesEastDescender labelMayPutDate:self.selectedDate];
        } else {
            logs = [self.expandingCentralsResourcesEastDescender lowDropRain];
        }

        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 = foodFoodFix.nameReturnedSumShortBendBadminton;
            }

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

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

- (void)cupHashAction {
    [self firstTag];
}

- (void)updateTitle {
    if (self.selectedDate) {
        NSDateFormatter *cutSample = [[NSDateFormatter alloc] init];
        cutSample.dateFormat = foodFoodFix.pieceAbsoluteGuestRetrieveSoftnessCommandsPalette;
        NSString *dateString = [cutSample stringFromDate:self.selectedDate];

        NSCalendar *calendar = [NSCalendar currentCalendar];
        if ([calendar isDateInToday:self.selectedDate]) {
            self.title = foodFoodFix.rejectInputHighlightItsListenersDecoder;
        } else if ([calendar isDateInYesterday:self.selectedDate]) {
            self.title = foodFoodFix.winKilovoltsMiddleBitSeparatedTabDismissed;
        } else {
            self.title = dateString;
        }
    } else {
        self.title = foodFoodFix.consumerDiamondBaselineDayLeadIndices;
    }
}

- (void)sawWasLessAction {
    if (!self.expandingCentralsResourcesEastDescender) {
        return;
    }

    NSArray<NSDate *> *fourDryMaskOur = [self.expandingCentralsResourcesEastDescender appendCubic];
    if (fourDryMaskOur.count == 0) {
        UIAlertController *cocoa = [UIAlertController alertControllerWithTitle:foodFoodFix.writeDiscardGaspAgeSchemeDesigner
                                                                       message:foodFoodFix.nameReturnedSumShortBendBadminton
                                                                preferredStyle:UIAlertControllerStyleAlert];
        [cocoa addAction:[UIAlertAction actionWithTitle:foodFoodFix.disablesTeluguNinePingRollEdga style:UIAlertActionStyleDefault handler:nil]];
        [self presentViewController:cocoa animated:YES completion:nil];
        return;
    }

    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:foodFoodFix.portraitAffectingSinhaleseDiacriticKeyboardPrettyActivate
                                                                         message:nil
                                                                  preferredStyle:UIAlertControllerStyleActionSheet];

    [actionSheet addAction:[UIAlertAction actionWithTitle:foodFoodFix.consumerDiamondBaselineDayLeadIndices
                                                    style:UIAlertActionStyleDefault
                                                  handler:^(UIAlertAction *action) {
        self.selectedDate = nil;
        [self firstTag];
    }]];

    NSDateFormatter *cutSample = [[NSDateFormatter alloc] init];
    cutSample.dateFormat = foodFoodFix.pieceAbsoluteGuestRetrieveSoftnessCommandsPalette;

    NSCalendar *calendar = [NSCalendar currentCalendar];

    for (NSDate *date in fourDryMaskOur) {
        NSString *title;
        if ([calendar isDateInToday:date]) {
            title = foodFoodFix.rejectInputHighlightItsListenersDecoder;
        } else if ([calendar isDateInYesterday:date]) {
            title = foodFoodFix.winKilovoltsMiddleBitSeparatedTabDismissed;
        } else {
            title = [cutSample stringFromDate:date];
        }

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

    [actionSheet addAction:[UIAlertAction actionWithTitle:foodFoodFix.addressesOrdinaryNowUniformViabilityOrder 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.expandingCentralsResourcesEastDescender) {
        return;
    }

    NSArray *graphics = [self.expandingCentralsResourcesEastDescender adaptiveOwn];
    if (graphics.count == 0) {
        UIAlertController *cocoa = [UIAlertController alertControllerWithTitle:foodFoodFix.writeDiscardGaspAgeSchemeDesigner
                                                                       message:foodFoodFix.semanticWeightedFocusesPlatePubIcon
                                                                preferredStyle:UIAlertControllerStyleAlert];
        [cocoa addAction:[UIAlertAction actionWithTitle:foodFoodFix.disablesTeluguNinePingRollEdga style:UIAlertActionStyleDefault handler:nil]];
        [self presentViewController:cocoa animated:YES completion:nil];
        return;
    }

    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:foodFoodFix.mantissaTrainerDirectlyPitchEncodedExecutorLegal
                                                                         message:nil
                                                                  preferredStyle:UIAlertControllerStyleActionSheet];

    [actionSheet addAction:[UIAlertAction actionWithTitle:foodFoodFix.mouseSystemSignalPassCousinIntroMerge
                                                    style:UIAlertActionStyleDefault
                                                  handler:^(UIAlertAction *action) {
        [self topWeightMin];
    }]];

    for (NSURL *fileURL in graphics) {
        NSString *fileName = fileURL.lastPathComponent;
        [actionSheet addAction:[UIAlertAction actionWithTitle:[NSString stringWithFormat:foodFoodFix.resumeStayBagSelectionWalkMinDraft, fileName]
                                                        style:UIAlertActionStyleDefault
                                                      handler:^(UIAlertAction *action) {
            [self mightEyeFile:fileURL];
        }]];
    }

    [actionSheet addAction:[UIAlertAction actionWithTitle:foodFoodFix.addressesOrdinaryNowUniformViabilityOrder style:UIAlertActionStyleCancel handler:nil]];

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

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

- (void)topWeightMin {
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        
        NSString *easyToo = [self.expandingCentralsResourcesEastDescender definedDescent];

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

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

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

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

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

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

@end
