

#import "SegueViewController.h"
#import "Right.h"
#import "AffinityStillLiteralTurnFinishLeftover.h"
#import "VendorBarriersGeneratesAssemblyFlag.h"
#import "MetalVowelConfig.h"

@interface SegueViewController ()
@property (nonatomic, strong) UITextView *textView;
@property (nonatomic, strong) AffinityStillLiteralTurnFinishLeftover *cellphoneGracefulHandoffGenericsSay;
@property (nonatomic, strong) VendorBarriersGeneratesAssemblyFlag *initiallyFoundMarkAdapterNepali;
@property (nonatomic, strong) NSDate *selectedDate; 
@end

static VendorBarriersGeneratesAssemblyFlag *maxShakeEnergyDrivenThreeBusy = nil;
static AffinityStillLiteralTurnFinishLeftover *cardTopEngineTriggerGeometricDecrease = nil;

@implementation SegueViewController

+ (void)driveFamily {
    
    [Right authorityMasteringThreeAdjustsExpectsDelete];

    cardTopEngineTriggerGeometricDecrease = [[AffinityStillLiteralTurnFinishLeftover alloc] init];
    cardTopEngineTriggerGeometricDecrease.decideLevel = BoundBurnBitmapWasDance;

    [Right postcardInterNepaliExposureLike:cardTopEngineTriggerGeometricDecrease];

    maxShakeEnergyDrivenThreeBusy = [[VendorBarriersGeneratesAssemblyFlag alloc] init];
    maxShakeEnergyDrivenThreeBusy.decideLevel = HumanMakerOld;
    maxShakeEnergyDrivenThreeBusy.oddGram = 7;
    maxShakeEnergyDrivenThreeBusy.ourEditorSystolicChapterSticky = YES;
    [Right postcardInterNepaliExposureLike:maxShakeEnergyDrivenThreeBusy];

    [maxShakeEnergyDrivenThreeBusy manBleedWasYou];
}

+ (VendorBarriersGeneratesAssemblyFlag *)distinctRetainMemoryUsesQualityReference {
    return maxShakeEnergyDrivenThreeBusy;
}
+ (AffinityStillLiteralTurnFinishLeftover *)intrinsicGenericActionsInsulinSerializeRelay {
    return cardTopEngineTriggerGeometricDecrease;
}

- (AffinityStillLiteralTurnFinishLeftover *)cellphoneGracefulHandoffGenericsSay {
    return cardTopEngineTriggerGeometricDecrease;
}

+ (void)howWrongViewController:(UIViewController *)parentVC {
    SegueViewController *evict = [[SegueViewController alloc] init];
    UINavigationController *son = [[UINavigationController alloc] initWithRootViewController:evict];
    son.modalPresentationStyle = UIModalPresentationFullScreen;
    [parentVC presentViewController:son animated:YES completion:nil];
}

- (void)viewDidLoad {
    [super viewDidLoad];

    self.title = fileSongWax.titleDesignVowelInversePrefixedPerfusion;
    self.view.backgroundColor = [UIColor systemBackgroundColor];

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

    self.navigationItem.rightBarButtonItems = @[
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh
                                                      target:self
                                                      action:@selector(youSelfAction)],
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction
                                                      target:self
                                                      action:@selector(occurAction)],
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemBookmarks
                                                      target:self
                                                      action:@selector(bitLexiconAction)]
    ];
    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.initiallyFoundMarkAdapterNepali = [SegueViewController distinctRetainMemoryUsesQualityReference];

    [self tailSink];
}

- (void)tailSink {
    if (!self.initiallyFoundMarkAdapterNepali) {
        _textView.text = fileSongWax.launchingIndexedGuideSenseMagneticBag;
        return;
    }

    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        NSString *logs;
        if (self.selectedDate) {
            logs = [self.initiallyFoundMarkAdapterNepali redInputYouDate:self.selectedDate];
        } else {
            logs = [self.initiallyFoundMarkAdapterNepali fireUseGray];
        }

        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 = fileSongWax.custodianUndoneSaltEggMayProducer;
            }

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

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

- (void)youSelfAction {
    [self tailSink];
}

- (void)updateTitle {
    if (self.selectedDate) {
        NSDateFormatter *recordPut = [[NSDateFormatter alloc] init];
        recordPut.dateFormat = fileSongWax.ephemeralInvokeAbovePinMixerCallUplink;
        NSString *artsAdjust = [recordPut stringFromDate:self.selectedDate];

        NSCalendar *calendar = [NSCalendar currentCalendar];
        if ([calendar isDateInToday:self.selectedDate]) {
            self.title = fileSongWax.startupHourlyArmourNotLastNormal;
        } else if ([calendar isDateInYesterday:self.selectedDate]) {
            self.title = fileSongWax.outdoorInfoSatisfiedFrequencyAmbiguitySharpenStep;
        } else {
            self.title = artsAdjust;
        }
    } else {
        self.title = fileSongWax.bypassedFatDryGetAccordingBuddhist;
    }
}

- (void)bitLexiconAction {
    if (!self.initiallyFoundMarkAdapterNepali) {
        return;
    }

    NSArray<NSDate *> *chinaPingSurge = [self.initiallyFoundMarkAdapterNepali englishTaps];
    if (chinaPingSurge.count == 0) {
        UIAlertController *press = [UIAlertController alertControllerWithTitle:fileSongWax.protocolsIcySugarKitMeterGenerics
                                                                       message:fileSongWax.custodianUndoneSaltEggMayProducer
                                                                preferredStyle:UIAlertControllerStyleAlert];
        [press addAction:[UIAlertAction actionWithTitle:fileSongWax.icyTrimmingBalanceHomepageExtrinsicPackage style:UIAlertActionStyleDefault handler:nil]];
        [self presentViewController:press animated:YES completion:nil];
        return;
    }

    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:fileSongWax.faceSphereFilterHeadSetupCreditScheduler
                                                                         message:nil
                                                                  preferredStyle:UIAlertControllerStyleActionSheet];

    [actionSheet addAction:[UIAlertAction actionWithTitle:fileSongWax.bypassedFatDryGetAccordingBuddhist
                                                    style:UIAlertActionStyleDefault
                                                  handler:^(UIAlertAction *action) {
        self.selectedDate = nil;
        [self tailSink];
    }]];

    NSDateFormatter *recordPut = [[NSDateFormatter alloc] init];
    recordPut.dateFormat = fileSongWax.ephemeralInvokeAbovePinMixerCallUplink;

    NSCalendar *calendar = [NSCalendar currentCalendar];

    for (NSDate *date in chinaPingSurge) {
        NSString *title;
        if ([calendar isDateInToday:date]) {
            title = fileSongWax.startupHourlyArmourNotLastNormal;
        } else if ([calendar isDateInYesterday:date]) {
            title = fileSongWax.outdoorInfoSatisfiedFrequencyAmbiguitySharpenStep;
        } else {
            title = [recordPut stringFromDate:date];
        }

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

    [actionSheet addAction:[UIAlertAction actionWithTitle:fileSongWax.signalingTipRebusRecordedSeekMaximum style:UIAlertActionStyleCancel handler:nil]];

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

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

- (void)occurAction {
    if (!self.initiallyFoundMarkAdapterNepali) {
        return;
    }

    NSArray *curveTab = [self.initiallyFoundMarkAdapterNepali foodUnitBox];
    if (curveTab.count == 0) {
        UIAlertController *press = [UIAlertController alertControllerWithTitle:fileSongWax.protocolsIcySugarKitMeterGenerics
                                                                       message:fileSongWax.consumedNetworkScanCenteredRelatedObservers
                                                                preferredStyle:UIAlertControllerStyleAlert];
        [press addAction:[UIAlertAction actionWithTitle:fileSongWax.icyTrimmingBalanceHomepageExtrinsicPackage style:UIAlertActionStyleDefault handler:nil]];
        [self presentViewController:press animated:YES completion:nil];
        return;
    }

    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:fileSongWax.slavicLargestExpandingTrimmingSourcesWalkReject
                                                                         message:nil
                                                                  preferredStyle:UIAlertControllerStyleActionSheet];

    [actionSheet addAction:[UIAlertAction actionWithTitle:fileSongWax.teacherProcessedQueueShowingYetProcessedNote
                                                    style:UIAlertActionStyleDefault
                                                  handler:^(UIAlertAction *action) {
        [self middleSyntax];
    }]];

    for (NSURL *fileURL in curveTab) {
        NSString *fileName = fileURL.lastPathComponent;
        [actionSheet addAction:[UIAlertAction actionWithTitle:[NSString stringWithFormat:fileSongWax.containBuilderHerStorylineButContentsMen, fileName]
                                                        style:UIAlertActionStyleDefault
                                                      handler:^(UIAlertAction *action) {
            [self alphaSunFile:fileURL];
        }]];
    }

    [actionSheet addAction:[UIAlertAction actionWithTitle:fileSongWax.signalingTipRebusRecordedSeekMaximum style:UIAlertActionStyleCancel handler:nil]];

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

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

- (void)middleSyntax {
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        
        NSString *jobNext = [self.initiallyFoundMarkAdapterNepali minSelfPartIll];

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

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

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

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

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

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

@end
