

#import "MiterViewController.h"
#import "Euler.h"
#import "RuleOldBridgeSidebarHellmanSinhalese.h"
#import "HitFloatingPartDeltaHundreds.h"
#import "ItsBankersConfig.h"

@interface MiterViewController ()
@property (nonatomic, strong) UITextView *textView;
@property (nonatomic, strong) RuleOldBridgeSidebarHellmanSinhalese *ubiquityResponderIllShowStay;
@property (nonatomic, strong) HitFloatingPartDeltaHundreds *frameRestingRevealPagerReject;
@property (nonatomic, strong) NSDate *selectedDate; 
@end

static HitFloatingPartDeltaHundreds *bundlesDateFactoryMinderAssignObtain = nil;
static RuleOldBridgeSidebarHellmanSinhalese *reasonOfficialPortKnowModelRevealed = nil;

@implementation MiterViewController

+ (void)trialWinOut {
    
    [Euler pointersParseArrangerMenuAlongsideGuarani];

    reasonOfficialPortKnowModelRevealed = [[RuleOldBridgeSidebarHellmanSinhalese alloc] init];
    reasonOfficialPortKnowModelRevealed.periodLevel = ThickGoldenPromotionSaturateSchool;

    [Euler itsCatBoxMarginTextual:reasonOfficialPortKnowModelRevealed];

    bundlesDateFactoryMinderAssignObtain = [[HitFloatingPartDeltaHundreds alloc] init];
    bundlesDateFactoryMinderAssignObtain.periodLevel = WaterMovieSun;
    bundlesDateFactoryMinderAssignObtain.swapSun = 7;
    bundlesDateFactoryMinderAssignObtain.ambienceForwardsDitheredExpandedAlign = YES;
    [Euler itsCatBoxMarginTextual:bundlesDateFactoryMinderAssignObtain];

    [bundlesDateFactoryMinderAssignObtain sliceLocalized];
}

+ (HitFloatingPartDeltaHundreds *)spanSonMalteseStrongShakeLike {
    return bundlesDateFactoryMinderAssignObtain;
}
+ (RuleOldBridgeSidebarHellmanSinhalese *)hairHueDecodingSymbolInterestBuilt {
    return reasonOfficialPortKnowModelRevealed;
}

- (RuleOldBridgeSidebarHellmanSinhalese *)ubiquityResponderIllShowStay {
    return reasonOfficialPortKnowModelRevealed;
}

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

- (void)viewDidLoad {
    [super viewDidLoad];

    self.title = memoryHours.reusableItalicsGenreProducesLocalityConverted;
    self.view.backgroundColor = [UIColor systemBackgroundColor];

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

    self.navigationItem.rightBarButtonItems = @[
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh
                                                      target:self
                                                      action:@selector(mattingAction)],
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction
                                                      target:self
                                                      action:@selector(groupAction)],
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemBookmarks
                                                      target:self
                                                      action:@selector(lowDueDashAction)]
    ];
    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.frameRestingRevealPagerReject = [MiterViewController spanSonMalteseStrongShakeLike];

    [self interFat];
}

- (void)interFat {
    if (!self.frameRestingRevealPagerReject) {
        _textView.text = memoryHours.freePredicateTeamInvalidAndCoptic;
        return;
    }

    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        NSString *logs;
        if (self.selectedDate) {
            logs = [self.frameRestingRevealPagerReject cutLowFiberDate:self.selectedDate];
        } else {
            logs = [self.frameRestingRevealPagerReject featWonHold];
        }

        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 = memoryHours.customGopherTryLambdaStorageMask;
            }

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

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

- (void)mattingAction {
    [self interFat];
}

- (void)updateTitle {
    if (self.selectedDate) {
        NSDateFormatter *mildRound = [[NSDateFormatter alloc] init];
        mildRound.dateFormat = memoryHours.sheZipLeftEndpointProcessAccountSchemes;
        NSString *artCapLive = [mildRound stringFromDate:self.selectedDate];

        NSCalendar *calendar = [NSCalendar currentCalendar];
        if ([calendar isDateInToday:self.selectedDate]) {
            self.title = memoryHours.lowerRecordingDeliverDroppedSundaneseGenerics;
        } else if ([calendar isDateInYesterday:self.selectedDate]) {
            self.title = memoryHours.disparitySpeechVariationOffNorthFilmBus;
        } else {
            self.title = artCapLive;
        }
    } else {
        self.title = memoryHours.smoothingRebusDailyPotentialStampOutput;
    }
}

- (void)lowDueDashAction {
    if (!self.frameRestingRevealPagerReject) {
        return;
    }

    NSArray<NSDate *> *echoReaderLove = [self.frameRestingRevealPagerReject noticeStood];
    if (echoReaderLove.count == 0) {
        UIAlertController *wrist = [UIAlertController alertControllerWithTitle:memoryHours.barUseSubSwipeInputLanguage
                                                                       message:memoryHours.customGopherTryLambdaStorageMask
                                                                preferredStyle:UIAlertControllerStyleAlert];
        [wrist addAction:[UIAlertAction actionWithTitle:memoryHours.clickedRealCacheMagneticCallingPaste style:UIAlertActionStyleDefault handler:nil]];
        [self presentViewController:wrist animated:YES completion:nil];
        return;
    }

    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:memoryHours.artistRectifiedConflictsReactorWetPrepPattern
                                                                         message:nil
                                                                  preferredStyle:UIAlertControllerStyleActionSheet];

    [actionSheet addAction:[UIAlertAction actionWithTitle:memoryHours.smoothingRebusDailyPotentialStampOutput
                                                    style:UIAlertActionStyleDefault
                                                  handler:^(UIAlertAction *action) {
        self.selectedDate = nil;
        [self interFat];
    }]];

    NSDateFormatter *mildRound = [[NSDateFormatter alloc] init];
    mildRound.dateFormat = memoryHours.sheZipLeftEndpointProcessAccountSchemes;

    NSCalendar *calendar = [NSCalendar currentCalendar];

    for (NSDate *date in echoReaderLove) {
        NSString *title;
        if ([calendar isDateInToday:date]) {
            title = memoryHours.lowerRecordingDeliverDroppedSundaneseGenerics;
        } else if ([calendar isDateInYesterday:date]) {
            title = memoryHours.disparitySpeechVariationOffNorthFilmBus;
        } else {
            title = [mildRound stringFromDate:date];
        }

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

    [actionSheet addAction:[UIAlertAction actionWithTitle:memoryHours.audienceFoodCaseVisibleFootersObservers style:UIAlertActionStyleCancel handler:nil]];

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

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

- (void)groupAction {
    if (!self.frameRestingRevealPagerReject) {
        return;
    }

    NSArray *tagBegan = [self.frameRestingRevealPagerReject magicOurSun];
    if (tagBegan.count == 0) {
        UIAlertController *wrist = [UIAlertController alertControllerWithTitle:memoryHours.barUseSubSwipeInputLanguage
                                                                       message:memoryHours.capsMillionDownloadSkipSkinFront
                                                                preferredStyle:UIAlertControllerStyleAlert];
        [wrist addAction:[UIAlertAction actionWithTitle:memoryHours.clickedRealCacheMagneticCallingPaste style:UIAlertActionStyleDefault handler:nil]];
        [self presentViewController:wrist animated:YES completion:nil];
        return;
    }

    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:memoryHours.cameraDetailNameEndpointGrowCalculateLeftover
                                                                         message:nil
                                                                  preferredStyle:UIAlertControllerStyleActionSheet];

    [actionSheet addAction:[UIAlertAction actionWithTitle:memoryHours.clusterTaggerDetailedHockeyCanExecTask
                                                    style:UIAlertActionStyleDefault
                                                  handler:^(UIAlertAction *action) {
        [self garbageSplit];
    }]];

    for (NSURL *fileURL in tagBegan) {
        NSString *fileName = fileURL.lastPathComponent;
        [actionSheet addAction:[UIAlertAction actionWithTitle:[NSString stringWithFormat:memoryHours.operateRowPastCompressAppearPeerSource, fileName]
                                                        style:UIAlertActionStyleDefault
                                                      handler:^(UIAlertAction *action) {
            [self busPhotoFile:fileURL];
        }]];
    }

    [actionSheet addAction:[UIAlertAction actionWithTitle:memoryHours.audienceFoodCaseVisibleFootersObservers style:UIAlertActionStyleCancel handler:nil]];

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

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

- (void)garbageSplit {
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        
        NSString *farRead = [self.frameRestingRevealPagerReject subBookKitLock];

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

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

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

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

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

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

@end
