

#import "MagicViewController.h"
#import "Share.h"
#import "DeviationUndoneQuechuaMenLibrariesRow.h"
#import "TagAdditionsAppearPathCaption.h"
#import "HisCapForkConfig.h"

@interface MagicViewController ()
@property (nonatomic, strong) UITextView *textView;
@property (nonatomic, strong) DeviationUndoneQuechuaMenLibrariesRow *determineAccuracyArrayEasyMusician;
@property (nonatomic, strong) TagAdditionsAppearPathCaption *headsetDayCroppingCompileDropped;
@property (nonatomic, strong) NSDate *selectedDate; 
@end

static TagAdditionsAppearPathCaption *removableSourceDiacriticBracketedDuplicatePan = nil;
static DeviationUndoneQuechuaMenLibrariesRow *canceledThatHumanSentNonePop = nil;

@implementation MagicViewController

+ (void)dayNegative {
    
    [Share sparseKilowattsResignLimitDoubleHandles];

    canceledThatHumanSentNonePop = [[DeviationUndoneQuechuaMenLibrariesRow alloc] init];
    canceledThatHumanSentNonePop.negateLevel = YoungerPrintableScrollDiscreteScheduler;

    [Share breakingObserverPopMagnitudeModal:canceledThatHumanSentNonePop];

    removableSourceDiacriticBracketedDuplicatePan = [[TagAdditionsAppearPathCaption alloc] init];
    removableSourceDiacriticBracketedDuplicatePan.negateLevel = DayCutOverlap;
    removableSourceDiacriticBracketedDuplicatePan.flights = 7;
    removableSourceDiacriticBracketedDuplicatePan.mobileStandElevenLocaleNothing = YES;
    [Share breakingObserverPopMagnitudeModal:removableSourceDiacriticBracketedDuplicatePan];

    [removableSourceDiacriticBracketedDuplicatePan mixBoldEachFun];
}

+ (TagAdditionsAppearPathCaption *)processedListenersPartnerOutdoorVarianceMix {
    return removableSourceDiacriticBracketedDuplicatePan;
}
+ (DeviationUndoneQuechuaMenLibrariesRow *)beaconSenseConvergedExpireDiskHer {
    return canceledThatHumanSentNonePop;
}

- (DeviationUndoneQuechuaMenLibrariesRow *)determineAccuracyArrayEasyMusician {
    return canceledThatHumanSentNonePop;
}

+ (void)helloMayViewController:(UIViewController *)parentVC {
    MagicViewController *small = [[MagicViewController alloc] init];
    UINavigationController *kin = [[UINavigationController alloc] initWithRootViewController:small];
    kin.modalPresentationStyle = UIModalPresentationFullScreen;
    [parentVC presentViewController:kin animated:YES completion:nil];
}

- (void)viewDidLoad {
    [super viewDidLoad];

    self.title = sumPressHex.badOwnSumYearAllTall;
    self.view.backgroundColor = [UIColor systemBackgroundColor];

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

    self.navigationItem.rightBarButtonItems = @[
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh
                                                      target:self
                                                      action:@selector(herBoldAction)],
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction
                                                      target:self
                                                      action:@selector(touchAction)],
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemBookmarks
                                                      target:self
                                                      action:@selector(rainFitEyeAction)]
    ];
    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.headsetDayCroppingCompileDropped = [MagicViewController processedListenersPartnerOutdoorVarianceMix];

    [self timeSock];
}

- (void)timeSock {
    if (!self.headsetDayCroppingCompileDropped) {
        _textView.text = sumPressHex.decideDrivenOxygenMostFeedCut;
        return;
    }

    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        NSString *logs;
        if (self.selectedDate) {
            logs = [self.headsetDayCroppingCompileDropped barCarForceDate:self.selectedDate];
        } else {
            logs = [self.headsetDayCroppingCompileDropped siblingsOne];
        }

        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 = sumPressHex.pointersSimpleTrademarkWillNumbersCaret;
            }

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

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

- (void)herBoldAction {
    [self timeSock];
}

- (void)updateTitle {
    if (self.selectedDate) {
        NSDateFormatter *andSigner = [[NSDateFormatter alloc] init];
        andSigner.dateFormat = sumPressHex.zipProducingClinicalDirtySalientBarrierTen;
        NSString *putWetWalk = [andSigner stringFromDate:self.selectedDate];

        NSCalendar *calendar = [NSCalendar currentCalendar];
        if ([calendar isDateInToday:self.selectedDate]) {
            self.title = sumPressHex.replacePanelFatalSubtitlesEraWrapper;
        } else if ([calendar isDateInYesterday:self.selectedDate]) {
            self.title = sumPressHex.touchSlashesMeterSupportedTurkmenLoadingHit;
        } else {
            self.title = putWetWalk;
        }
    } else {
        self.title = sumPressHex.goalStreamDirectlyNativeStartArmenian;
    }
}

- (void)rainFitEyeAction {
    if (!self.headsetDayCroppingCompileDropped) {
        return;
    }

    NSArray<NSDate *> *uniqueCallDeep = [self.headsetDayCroppingCompileDropped estimateWon];
    if (uniqueCallDeep.count == 0) {
        UIAlertController *china = [UIAlertController alertControllerWithTitle:sumPressHex.uploadingPaperAchievedLowDegreesPrevents
                                                                       message:sumPressHex.pointersSimpleTrademarkWillNumbersCaret
                                                                preferredStyle:UIAlertControllerStyleAlert];
        [china addAction:[UIAlertAction actionWithTitle:sumPressHex.conjugateWrongInterlaceIronCampaignLost style:UIAlertActionStyleDefault handler:nil]];
        [self presentViewController:china animated:YES completion:nil];
        return;
    }

    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:sumPressHex.partSlopeParentResumedHandlingIgnoreAppended
                                                                         message:nil
                                                                  preferredStyle:UIAlertControllerStyleActionSheet];

    [actionSheet addAction:[UIAlertAction actionWithTitle:sumPressHex.goalStreamDirectlyNativeStartArmenian
                                                    style:UIAlertActionStyleDefault
                                                  handler:^(UIAlertAction *action) {
        self.selectedDate = nil;
        [self timeSock];
    }]];

    NSDateFormatter *andSigner = [[NSDateFormatter alloc] init];
    andSigner.dateFormat = sumPressHex.zipProducingClinicalDirtySalientBarrierTen;

    NSCalendar *calendar = [NSCalendar currentCalendar];

    for (NSDate *date in uniqueCallDeep) {
        NSString *title;
        if ([calendar isDateInToday:date]) {
            title = sumPressHex.replacePanelFatalSubtitlesEraWrapper;
        } else if ([calendar isDateInYesterday:date]) {
            title = sumPressHex.touchSlashesMeterSupportedTurkmenLoadingHit;
        } else {
            title = [andSigner stringFromDate:date];
        }

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

    [actionSheet addAction:[UIAlertAction actionWithTitle:sumPressHex.improperGeometryDeliveredArgumentDetailPerfusion style:UIAlertActionStyleCancel handler:nil]];

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

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

- (void)touchAction {
    if (!self.headsetDayCroppingCompileDropped) {
        return;
    }

    NSArray *hallMeal = [self.headsetDayCroppingCompileDropped youBoxSurge];
    if (hallMeal.count == 0) {
        UIAlertController *china = [UIAlertController alertControllerWithTitle:sumPressHex.uploadingPaperAchievedLowDegreesPrevents
                                                                       message:sumPressHex.forwardsMasteringIntrinsicBlurLogSon
                                                                preferredStyle:UIAlertControllerStyleAlert];
        [china addAction:[UIAlertAction actionWithTitle:sumPressHex.conjugateWrongInterlaceIronCampaignLost style:UIAlertActionStyleDefault handler:nil]];
        [self presentViewController:china animated:YES completion:nil];
        return;
    }

    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:sumPressHex.demandPrimaryGenreRedefinedElementsWeekSwipe
                                                                         message:nil
                                                                  preferredStyle:UIAlertControllerStyleActionSheet];

    [actionSheet addAction:[UIAlertAction actionWithTitle:sumPressHex.pinProminentMinuteInitiallyOverdueOnePreserve
                                                    style:UIAlertActionStyleDefault
                                                  handler:^(UIAlertAction *action) {
        [self cacheGrowSay];
    }]];

    for (NSURL *fileURL in hallMeal) {
        NSString *fileName = fileURL.lastPathComponent;
        [actionSheet addAction:[UIAlertAction actionWithTitle:[NSString stringWithFormat:sumPressHex.fairReceiverAverageLongerFlowInternalSeeking, fileName]
                                                        style:UIAlertActionStyleDefault
                                                      handler:^(UIAlertAction *action) {
            [self cupPulseFile:fileURL];
        }]];
    }

    [actionSheet addAction:[UIAlertAction actionWithTitle:sumPressHex.improperGeometryDeliveredArgumentDetailPerfusion style:UIAlertActionStyleCancel handler:nil]];

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

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

- (void)cacheGrowSay {
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        
        NSString *smaller = [self.headsetDayCroppingCompileDropped sumHintBackOpt];

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

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

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

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

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

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

@end
