

#import "TrackViewController.h"
#import "Group.h"
#import "OrganizeZoneVitalityFunBurnIntervals.h"
#import "SatisfiedLaunchedPacketsPinDomain.h"
#import "SubmitWireConfig.h"

@interface TrackViewController ()
@property (nonatomic, strong) UITextView *textView;
@property (nonatomic, strong) OrganizeZoneVitalityFunBurnIntervals *providingPiecePairEchoQuote;
@property (nonatomic, strong) SatisfiedLaunchedPacketsPinDomain *hostSideYetUnchangedFlushed;
@property (nonatomic, strong) NSDate *selectedDate; 
@end

static SatisfiedLaunchedPacketsPinDomain *shoulderSoccerLevelOperatingDiscountsHumidity = nil;
static OrganizeZoneVitalityFunBurnIntervals *wasReviewSenderWayPreviousScore = nil;

@implementation TrackViewController

+ (void)disableFork {
    
    [Group scatteredFreestyleEndpointAlongsideClosureMetadata];

    wasReviewSenderWayPreviousScore = [[OrganizeZoneVitalityFunBurnIntervals alloc] init];
    wasReviewSenderWayPreviousScore.uplinkLevel = LovePhoneSmallerComputerCreate;

    [Group mayAlignmentBarCommentTab:wasReviewSenderWayPreviousScore];

    shoulderSoccerLevelOperatingDiscountsHumidity = [[SatisfiedLaunchedPacketsPinDomain alloc] init];
    shoulderSoccerLevelOperatingDiscountsHumidity.uplinkLevel = BadgeOrnament;
    shoulderSoccerLevelOperatingDiscountsHumidity.tryPage = 7;
    shoulderSoccerLevelOperatingDiscountsHumidity.nameCausePromiseKeepImplicit = YES;
    [Group mayAlignmentBarCommentTab:shoulderSoccerLevelOperatingDiscountsHumidity];

    [shoulderSoccerLevelOperatingDiscountsHumidity cityMomentCert];
}

+ (SatisfiedLaunchedPacketsPinDomain *)suchExcludedDetectorMixStepperPermanent {
    return shoulderSoccerLevelOperatingDiscountsHumidity;
}
+ (OrganizeZoneVitalityFunBurnIntervals *)dividerIdleFloatFilterBedContent {
    return wasReviewSenderWayPreviousScore;
}

- (OrganizeZoneVitalityFunBurnIntervals *)providingPiecePairEchoQuote {
    return wasReviewSenderWayPreviousScore;
}

+ (void)aloneSheViewController:(UIViewController *)parentVC {
    TrackViewController *trial = [[TrackViewController alloc] init];
    UINavigationController *odd = [[UINavigationController alloc] initWithRootViewController:trial];
    odd.modalPresentationStyle = UIModalPresentationFullScreen;
    [parentVC presentViewController:odd animated:YES completion:nil];
}

- (void)viewDidLoad {
    [super viewDidLoad];

    self.title = musicianSpa.potassiumMusicTeaspoonsFormatTowerExtension;
    self.view.backgroundColor = [UIColor systemBackgroundColor];

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

    self.navigationItem.rightBarButtonItems = @[
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh
                                                      target:self
                                                      action:@selector(airNearAction)],
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction
                                                      target:self
                                                      action:@selector(awakeAction)],
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemBookmarks
                                                      target:self
                                                      action:@selector(sendTargetAction)]
    ];
    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.hostSideYetUnchangedFlushed = [TrackViewController suchExcludedDetectorMixStepperPermanent];

    [self movieHue];
}

- (void)movieHue {
    if (!self.hostSideYetUnchangedFlushed) {
        _textView.text = musicianSpa.openManLongerPageRevealedExport;
        return;
    }

    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        NSString *logs;
        if (self.selectedDate) {
            logs = [self.hostSideYetUnchangedFlushed topToneFoodDate:self.selectedDate];
        } else {
            logs = [self.hostSideYetUnchangedFlushed renewRender];
        }

        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 = musicianSpa.applyingSpaceFlattenMultiplyHerHyphen;
            }

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

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

- (void)airNearAction {
    [self movieHue];
}

- (void)updateTitle {
    if (self.selectedDate) {
        NSDateFormatter *menstrual = [[NSDateFormatter alloc] init];
        menstrual.dateFormat = musicianSpa.wakeVerticalRawHitFrenchEpisodeKnow;
        NSString *strictBank = [menstrual stringFromDate:self.selectedDate];

        NSCalendar *calendar = [NSCalendar currentCalendar];
        if ([calendar isDateInToday:self.selectedDate]) {
            self.title = musicianSpa.fiveLanguagesTaggerLanguageHerProduced;
        } else if ([calendar isDateInYesterday:self.selectedDate]) {
            self.title = musicianSpa.clampYahooPathCascadeArrayBoxRun;
        } else {
            self.title = strictBank;
        }
    } else {
        self.title = musicianSpa.rollCheckDynamicOwnershipAddReal;
    }
}

- (void)sendTargetAction {
    if (!self.hostSideYetUnchangedFlushed) {
        return;
    }

    NSArray<NSDate *> *downLossCenter = [self.hostSideYetUnchangedFlushed tallBusPack];
    if (downLossCenter.count == 0) {
        UIAlertController *large = [UIAlertController alertControllerWithTitle:musicianSpa.tropicalMenuBlobGenericsSynthesisFood
                                                                       message:musicianSpa.applyingSpaceFlattenMultiplyHerHyphen
                                                                preferredStyle:UIAlertControllerStyleAlert];
        [large addAction:[UIAlertAction actionWithTitle:musicianSpa.genericUtilitiesIncomingConsoleInsertFriend style:UIAlertActionStyleDefault handler:nil]];
        [self presentViewController:large animated:YES completion:nil];
        return;
    }

    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:musicianSpa.stepResumedDecisionNotTallBigThin
                                                                         message:nil
                                                                  preferredStyle:UIAlertControllerStyleActionSheet];

    [actionSheet addAction:[UIAlertAction actionWithTitle:musicianSpa.rollCheckDynamicOwnershipAddReal
                                                    style:UIAlertActionStyleDefault
                                                  handler:^(UIAlertAction *action) {
        self.selectedDate = nil;
        [self movieHue];
    }]];

    NSDateFormatter *menstrual = [[NSDateFormatter alloc] init];
    menstrual.dateFormat = musicianSpa.wakeVerticalRawHitFrenchEpisodeKnow;

    NSCalendar *calendar = [NSCalendar currentCalendar];

    for (NSDate *date in downLossCenter) {
        NSString *title;
        if ([calendar isDateInToday:date]) {
            title = musicianSpa.fiveLanguagesTaggerLanguageHerProduced;
        } else if ([calendar isDateInYesterday:date]) {
            title = musicianSpa.clampYahooPathCascadeArrayBoxRun;
        } else {
            title = [menstrual stringFromDate:date];
        }

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

    [actionSheet addAction:[UIAlertAction actionWithTitle:musicianSpa.logoDetectedHeapSharpnessFindKilometer style:UIAlertActionStyleCancel handler:nil]];

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

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

- (void)awakeAction {
    if (!self.hostSideYetUnchangedFlushed) {
        return;
    }

    NSArray *flowPair = [self.hostSideYetUnchangedFlushed layerArePen];
    if (flowPair.count == 0) {
        UIAlertController *large = [UIAlertController alertControllerWithTitle:musicianSpa.tropicalMenuBlobGenericsSynthesisFood
                                                                       message:musicianSpa.recoveryDismissalBezelDesignMountCoulombs
                                                                preferredStyle:UIAlertControllerStyleAlert];
        [large addAction:[UIAlertAction actionWithTitle:musicianSpa.genericUtilitiesIncomingConsoleInsertFriend style:UIAlertActionStyleDefault handler:nil]];
        [self presentViewController:large animated:YES completion:nil];
        return;
    }

    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:musicianSpa.artistDocumentsPriorityEffectiveClearVoiceEndpoint
                                                                         message:nil
                                                                  preferredStyle:UIAlertControllerStyleActionSheet];

    [actionSheet addAction:[UIAlertAction actionWithTitle:musicianSpa.entityHertzUsesOuterVitalWorkflowDiscarded
                                                    style:UIAlertActionStyleDefault
                                                  handler:^(UIAlertAction *action) {
        [self scrollRadial];
    }]];

    for (NSURL *fileURL in flowPair) {
        NSString *fileName = fileURL.lastPathComponent;
        [actionSheet addAction:[UIAlertAction actionWithTitle:[NSString stringWithFormat:musicianSpa.currencyReferentReasonSpanAssistantExerciseSex, fileName]
                                                        style:UIAlertActionStyleDefault
                                                      handler:^(UIAlertAction *action) {
            [self parseEraFile:fileURL];
        }]];
    }

    [actionSheet addAction:[UIAlertAction actionWithTitle:musicianSpa.logoDetectedHeapSharpnessFindKilometer style:UIAlertActionStyleCancel handler:nil]];

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

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

- (void)scrollRadial {
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        
        NSString *disable = [self.hostSideYetUnchangedFlushed secondClipClip];

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

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

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

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

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

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

@end
