

#import "SenseViewController.h"
#import "Dance.h"
#import "DaySleetElevenAnchorVitalSynthetic.h"
#import "ArtistEyeTalkRestartGeneric.h"
#import "TypeHigherConfig.h"

@interface SenseViewController ()
@property (nonatomic, strong) UITextView *textView;
@property (nonatomic, strong) DaySleetElevenAnchorVitalSynthetic *sendStartingEggChangingProduce;
@property (nonatomic, strong) ArtistEyeTalkRestartGeneric *mapFlashDirtyOurWeekend;
@property (nonatomic, strong) NSDate *selectedDate; 
@end

static ArtistEyeTalkRestartGeneric *flashStartSubscriptStrategySyntaxLenient = nil;
static DaySleetElevenAnchorVitalSynthetic *divideNotifiedVitalityTrainingAlbumPersian = nil;

@implementation SenseViewController

+ (void)reverseDark {
    
    [Dance darkerIllPermuteEndpointsColumnDid];

    divideNotifiedVitalityTrainingAlbumPersian = [[DaySleetElevenAnchorVitalSynthetic alloc] init];
    divideNotifiedVitalityTrainingAlbumPersian.itsRowLevel = RestSpecificAnotherLiftOwn;

    [Dance republicSplatOverlapDetailOrder:divideNotifiedVitalityTrainingAlbumPersian];

    flashStartSubscriptStrategySyntaxLenient = [[ArtistEyeTalkRestartGeneric alloc] init];
    flashStartSubscriptStrategySyntaxLenient.itsRowLevel = TransposeName;
    flashStartSubscriptStrategySyntaxLenient.marquee = 7;
    flashStartSubscriptStrategySyntaxLenient.samplesHourDidLoopsDarker = YES;
    [Dance republicSplatOverlapDetailOrder:flashStartSubscriptStrategySyntaxLenient];

    [flashStartSubscriptStrategySyntaxLenient waitOwnMixRoot];
}

+ (ArtistEyeTalkRestartGeneric *)operandWaxModerateBusAppearSidebar {
    return flashStartSubscriptStrategySyntaxLenient;
}
+ (DaySleetElevenAnchorVitalSynthetic *)segmentedFilterSynthesisMethodNetRound {
    return divideNotifiedVitalityTrainingAlbumPersian;
}

- (DaySleetElevenAnchorVitalSynthetic *)sendStartingEggChangingProduce {
    return divideNotifiedVitalityTrainingAlbumPersian;
}

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

- (void)viewDidLoad {
    [super viewDidLoad];

    self.title = drainSender.speakerHelloSedentaryDrainSlabNotify;
    self.view.backgroundColor = [UIColor systemBackgroundColor];

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

    self.navigationItem.rightBarButtonItems = @[
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh
                                                      target:self
                                                      action:@selector(pendingAction)],
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction
                                                      target:self
                                                      action:@selector(insetAction)],
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemBookmarks
                                                      target:self
                                                      action:@selector(tryWalkRetAction)]
    ];
    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.mapFlashDirtyOurWeekend = [SenseViewController operandWaxModerateBusAppearSidebar];

    [self ironHome];
}

- (void)ironHome {
    if (!self.mapFlashDirtyOurWeekend) {
        _textView.text = drainSender.gainIntervalBreakProteinElderBox;
        return;
    }

    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        NSString *logs;
        if (self.selectedDate) {
            logs = [self.mapFlashDirtyOurWeekend mixSkinManyDate:self.selectedDate];
        } else {
            logs = [self.mapFlashDirtyOurWeekend ageDaysLine];
        }

        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 = drainSender.millibarsTwentyObscuresFathomsHangShelf;
            }

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

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

- (void)pendingAction {
    [self ironHome];
}

- (void)updateTitle {
    if (self.selectedDate) {
        NSDateFormatter *spouseTop = [[NSDateFormatter alloc] init];
        spouseTop.dateFormat = drainSender.tapFitRectifiedNearBaseThousandDivide;
        NSString *bookFormat = [spouseTop stringFromDate:self.selectedDate];

        NSCalendar *calendar = [NSCalendar currentCalendar];
        if ([calendar isDateInToday:self.selectedDate]) {
            self.title = drainSender.textualValueConnectFastOverlaySetup;
        } else if ([calendar isDateInYesterday:self.selectedDate]) {
            self.title = drainSender.ageIntervalsBarOperatorInsideLawIndigo;
        } else {
            self.title = bookFormat;
        }
    } else {
        self.title = drainSender.stableIndianFiveMeterCloudDistant;
    }
}

- (void)tryWalkRetAction {
    if (!self.mapFlashDirtyOurWeekend) {
        return;
    }

    NSArray<NSDate *> *appearLoadTree = [self.mapFlashDirtyOurWeekend escapedEasy];
    if (appearLoadTree.count == 0) {
        UIAlertController *adopt = [UIAlertController alertControllerWithTitle:drainSender.mixerTooNoiseAngleEstonianWon
                                                                       message:drainSender.millibarsTwentyObscuresFathomsHangShelf
                                                                preferredStyle:UIAlertControllerStyleAlert];
        [adopt addAction:[UIAlertAction actionWithTitle:drainSender.procedureWrappedSymbolsCalculateAutomaticHandled style:UIAlertActionStyleDefault handler:nil]];
        [self presentViewController:adopt animated:YES completion:nil];
        return;
    }

    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:drainSender.lengthWayUnionAbnormalRuleRecordTrack
                                                                         message:nil
                                                                  preferredStyle:UIAlertControllerStyleActionSheet];

    [actionSheet addAction:[UIAlertAction actionWithTitle:drainSender.stableIndianFiveMeterCloudDistant
                                                    style:UIAlertActionStyleDefault
                                                  handler:^(UIAlertAction *action) {
        self.selectedDate = nil;
        [self ironHome];
    }]];

    NSDateFormatter *spouseTop = [[NSDateFormatter alloc] init];
    spouseTop.dateFormat = drainSender.tapFitRectifiedNearBaseThousandDivide;

    NSCalendar *calendar = [NSCalendar currentCalendar];

    for (NSDate *date in appearLoadTree) {
        NSString *title;
        if ([calendar isDateInToday:date]) {
            title = drainSender.textualValueConnectFastOverlaySetup;
        } else if ([calendar isDateInYesterday:date]) {
            title = drainSender.ageIntervalsBarOperatorInsideLawIndigo;
        } else {
            title = [spouseTop stringFromDate:date];
        }

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

    [actionSheet addAction:[UIAlertAction actionWithTitle:drainSender.dryNotIterateTodayForkTrust style:UIAlertActionStyleCancel handler:nil]];

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

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

- (void)insetAction {
    if (!self.mapFlashDirtyOurWeekend) {
        return;
    }

    NSArray *inactive = [self.mapFlashDirtyOurWeekend sobSolidAsk];
    if (inactive.count == 0) {
        UIAlertController *adopt = [UIAlertController alertControllerWithTitle:drainSender.mixerTooNoiseAngleEstonianWon
                                                                       message:drainSender.scalingPrivacyDriveSpeakerExecutingQuotes
                                                                preferredStyle:UIAlertControllerStyleAlert];
        [adopt addAction:[UIAlertAction actionWithTitle:drainSender.procedureWrappedSymbolsCalculateAutomaticHandled style:UIAlertActionStyleDefault handler:nil]];
        [self presentViewController:adopt animated:YES completion:nil];
        return;
    }

    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:drainSender.northAggregateMaskRecyclePageAscendedGeorgian
                                                                         message:nil
                                                                  preferredStyle:UIAlertControllerStyleActionSheet];

    [actionSheet addAction:[UIAlertAction actionWithTitle:drainSender.eraserSobCivilEyeAcrossPacketHandled
                                                    style:UIAlertActionStyleDefault
                                                  handler:^(UIAlertAction *action) {
        [self nodeNetscape];
    }]];

    for (NSURL *fileURL in inactive) {
        NSString *fileName = fileURL.lastPathComponent;
        [actionSheet addAction:[UIAlertAction actionWithTitle:[NSString stringWithFormat:drainSender.artworkSalientStrategyFontToolAssistantAsset, fileName]
                                                        style:UIAlertActionStyleDefault
                                                      handler:^(UIAlertAction *action) {
            [self cropAxesFile:fileURL];
        }]];
    }

    [actionSheet addAction:[UIAlertAction actionWithTitle:drainSender.dryNotIterateTodayForkTrust style:UIAlertActionStyleCancel handler:nil]];

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

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

- (void)nodeNetscape {
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        
        NSString *goalHis = [self.mapFlashDirtyOurWeekend dissolveFolder];

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

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

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

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

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

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

@end
