






#import "PeakHerCurlPinViewController.h"
#import <WebKit/WebKit.h>
#import <WebKit/WKFoundation.h>
#import "NSString+PublicDry.h"
#import "NSString+TimeRegular.h"

@interface PeakHerCurlPinViewController ()<UIScrollViewDelegate,WKNavigationDelegate>

@property (nonatomic, strong) UISegmentedControl *cloudExposuresControl;
@property (nonatomic, strong) UIView * neverConvertedWrapperBalticJapanese;
@property (nonatomic, strong) UIView * wakePhoneMenGlobalPull;

@property (nonatomic, strong) UIScrollView * exitsDetailView;

@end

@implementation PeakHerCurlPinViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.reportsHasButton.hidden = YES;
    self.peopleRedButton.hidden = YES;
    
    UISegmentedControl *trustedView = [[UISegmentedControl alloc] initWithItems:@[CupDenyLeap.cutReuseIcyOur.appendedNeedDivideKeepUnifyTab,CupDenyLeap.cutReuseIcyOur.centralThirdShePanoramasDueRing]];
    trustedView.layer.masksToBounds = YES; 
    trustedView.layer.cornerRadius = 2;    
    [trustedView setTitleTextAttributes:@{NSForegroundColorAttributeName:[CupDenyLeap ringMatchColor]} forState:UIControlStateSelected];
    [trustedView setTitleTextAttributes:@{NSForegroundColorAttributeName:[CupDenyLeap ringMatchColor]} forState:UIControlStateNormal];
    [self.view addSubview:trustedView];
    [trustedView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.view);
        make.top.mas_equalTo(CupDenyLeap.rarePutOther.weekendBase);
    }];
    [trustedView addTarget:self action:@selector(stillNotWhite:) forControlEvents:UIControlEventValueChanged];
    self.cloudExposuresControl = trustedView;
    
    _exitsDetailView = [[UIScrollView alloc]init];
    _exitsDetailView.pagingEnabled = YES;
    _exitsDetailView.delegate = self;
    [self.view addSubview:_exitsDetailView];
    [_exitsDetailView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view).offset(CupDenyLeap.rarePutOther.spatialWelsh);
        make.right.equalTo(self.view).offset(-CupDenyLeap.rarePutOther.spatialWelsh);
        make.top.equalTo(self.view).offset(CupDenyLeap.rarePutOther.initialChunk);
        make.bottom.equalTo(self.view).offset(-CupDenyLeap.rarePutOther.rotorTabRead);
    }];
    
    UIView *containerView = [UIView new];
    containerView.backgroundColor = UIColor.whiteColor;
    [self.exitsDetailView addSubview:containerView];
    [containerView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.exitsDetailView);
        make.height.equalTo(_exitsDetailView);
    }];
    
    UIView * draftAnchors = [self metricsManView:[CupDenyLeap sindhiSonSenseDustSexual]];
    [containerView addSubview:draftAnchors];
    [draftAnchors mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(0);
        make.top.bottom.equalTo(containerView);
        make.width.mas_equalTo(self.exitsDetailView);
    }];
    self.neverConvertedWrapperBalticJapanese = draftAnchors;
    
    UIView * dueRulePoint = [self metricsManView:[CupDenyLeap topPromiseReturnedUnpluggedLappish]];
    [containerView addSubview:dueRulePoint];
    [dueRulePoint mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(draftAnchors.mas_right);
        make.bottom.top.equalTo(containerView);
        make.width.mas_equalTo(self.exitsDetailView);
    }];
    self.wakePhoneMenGlobalPull = dueRulePoint;
    
    [containerView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(dueRulePoint.mas_right);
    }];
    
    if (![self.yetLearnTab boolValue]) {
        UIButton *soloistButton = [CupDenyLeap endSourceApplierAchievedLigatureColor:CupDenyLeap.cutReuseIcyOur.plateMeasure];
        [soloistButton setBackgroundImage:[UIImage nineHintItsHasColor:[[UIColor lightGrayColor] colorWithAlphaComponent:0.5f]] forState:UIControlStateNormal];
        [soloistButton addTarget:self action:@selector(finnishVirtualWeightedCommittedArrowEmbedding:) forControlEvents:(UIControlEventTouchUpInside)];
        [self.view addSubview:soloistButton];
        
        [soloistButton mas_makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.equalTo(self.view).offset(-CupDenyLeap.rarePutOther.slightElder);
            make.left.equalTo(self.view).offset(CupDenyLeap.rarePutOther.spatialWelsh);
            make.right.equalTo(self.view.mas_centerX).offset(-CupDenyLeap.rarePutOther.eyeRestFill);
            make.height.mas_equalTo(CupDenyLeap.rarePutOther.hueOriginSex);
        }];
    }

    UIButton *hitFreeButton =  [CupDenyLeap endSourceApplierAchievedLigatureColor:CupDenyLeap.cutReuseIcyOur.belowAllow];
    [hitFreeButton addTarget:self action:@selector(lowercaseCreatingCommitPrintableSilentBound:) forControlEvents:(UIControlEventTouchUpInside)];
    [self.view addSubview:hitFreeButton];
    BOOL unifyButton = ![self.yetLearnTab boolValue];
    [hitFreeButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.view).offset(-CupDenyLeap.rarePutOther.slightElder);
        make.right.equalTo(self.view).offset(-CupDenyLeap.rarePutOther.spatialWelsh);
        
        if (unifyButton) {
            make.left.equalTo(self.view.mas_centerX).offset(CupDenyLeap.rarePutOther.eyeRestFill);
        } else {
            make.left.equalTo(self.view).offset(CupDenyLeap.rarePutOther.spatialWelsh);
        }
        make.height.mas_equalTo(CupDenyLeap.rarePutOther.hueOriginSex);
    }];
    
    trustedView.selectedSegmentIndex = 0;
    [self stillNotWhite:trustedView];
}

-(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{
    [self.cloudExposuresControl setSelectedSegmentIndex:scrollView.contentOffset.x/self.view.frame.size.width ==0?0:1];
    [self keyCountingFocalFilteringOptText:scrollView.contentOffset.x/self.view.frame.size.width ==0?0:1];
}

- (void)stillNotWhite:(UISegmentedControl *)sender {
    [self keyCountingFocalFilteringOptText:sender.selectedSegmentIndex == 0?0:1];
    [self.exitsDetailView setContentOffset:CGPointMake(sender.selectedSegmentIndex == 0?0:self.exitsDetailView.frame.size.width, 0) animated:YES];
}

- (void)keyCountingFocalFilteringOptText:(NSInteger)type {
    NSString *optPanMust = nil;
    UIView *contentView = nil;
    optPanMust = type == 0 ? [CupDenyLeap sindhiSonSenseDustSexual]:[CupDenyLeap topPromiseReturnedUnpluggedLappish];
    contentView = type == 0 ? self.neverConvertedWrapperBalticJapanese:self.wakePhoneMenGlobalPull;
    
    if (optPanMust.mediaOurLong) {
        return;
    }
    
    if ([[optPanMust pathExtension] containsString:CupDenyLeap.rarePutOther.fatYearsEditSeekPut]) {
        UITextView *sinView = (UITextView *)contentView;
        if (sinView.text.length > 0) {
            return;
        }

        
        [RedScriptsView pulseSheSetupView:contentView];

        
        NSURL *url = [NSURL URLWithString:optPanMust];
        NSURLSessionDataTask *task = [[NSURLSession sharedSession] dataTaskWithURL:url
                                                                 completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
            
            dispatch_async(dispatch_get_main_queue(), ^{
                
                [RedScriptsView homeRareRunBinOldView:contentView];
                
                if (error || data.length == 0) {
                    
                    sinView.text = CupDenyLeap.cutReuseIcyOur.beatPrettyArtworkWalkingDetachingNordic;
                    return;
                }
                
                
                NSString *quitDidNotSon = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
                sinView.text = quitDidNotSon ?: CupDenyLeap.cutReuseIcyOur.scheduledAreMoodWhileIdenticalTagalogCoalesce;
            });
        }];
        
        [task resume];

    }else {
        WKWebView *hexDog = (WKWebView *)contentView;
        if (!hexDog.isLoading && hexDog.estimatedProgress == 1) {
            [RedScriptsView homeRareRunBinOldView:contentView];
            return;
        }
        [RedScriptsView pulseSheSetupView:contentView];
        NSString *embedding =  [optPanMust.includingStylusAssetLockWinCutoff stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
        NSURL *url = [NSURL URLWithString:embedding];
        NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:15.0];
        [hexDog loadRequest:request];
    }
}

- (void)finnishVirtualWeightedCommittedArrowEmbedding:(id)sender {
    [self routeMembersBadTemporalRevisionAction:nil];
    if (self.labeledComplexStoneCutSiblings) {
        self.labeledComplexStoneCutSiblings(NO);
    }
}

- (void)lowercaseCreatingCommitPrintableSilentBound:(id)sender {
    [self routeMembersBadTemporalRevisionAction:nil];
    if (self.labeledComplexStoneCutSiblings) {
        self.labeledComplexStoneCutSiblings(YES);
    }
}

- (UIView *)metricsManView:(NSString *)string {
    UIView *optRegistry = nil;
    if ([[string pathExtension] containsString:CupDenyLeap.rarePutOther.fatYearsEditSeekPut]) {
        UITextView * flipFont = [UITextView new];
        flipFont.editable = NO;
        flipFont.backgroundColor = UIColor.whiteColor;
        flipFont.textColor = UIColor.grayColor;
        optRegistry = flipFont;
    }else {
        WKWebView *withTagItem = [[WKWebView alloc] initWithFrame:CGRectZero];
        withTagItem.backgroundColor = UIColor.clearColor;
        withTagItem.scrollView.backgroundColor = UIColor.lightGrayColor;
        withTagItem.opaque = YES;
        withTagItem.scrollView.bounces =NO;
        withTagItem.scrollView.showsVerticalScrollIndicator = NO;
        withTagItem.scrollView.showsHorizontalScrollIndicator = NO;
        withTagItem.navigationDelegate = self;
        optRegistry = withTagItem;
    }
    return optRegistry;
}

- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation {
    [RedScriptsView homeRareRunBinOldView:webView];
}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    UIEdgeInsets allArmDisk = [[CutStringManager shared] wetEarlyCropWindow].safeAreaInsets;
    allArmDisk.top    += 10;
    allArmDisk.left   += 10;
    allArmDisk.bottom += 10;
    allArmDisk.right  += 10;

    [self.view mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.edges.mas_equalTo(allArmDisk);
    }];
}

@end
