






#import "DisparityEventViewController.h"
#import <WebKit/WebKit.h>
#import <WebKit/WKFoundation.h>
#import "NSString+TwoPhotos.h"
#import "NSString+OurWaistZip.h"

@interface DisparityEventViewController ()<UIScrollViewDelegate,WKNavigationDelegate>

@property (nonatomic, strong) UISegmentedControl *poolPinHostSubControl;
@property (nonatomic, strong) UIView * illHandlingPossibleTabularMill;
@property (nonatomic, strong) UIView * badReversedNumberBuddyFriction;

@property (nonatomic, strong) UIScrollView * timeInverseView;

@end

@implementation DisparityEventViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.skipAllUseButton.hidden = YES;
    self.lostRightButton.hidden = YES;
    
    UISegmentedControl *entriesView = [[UISegmentedControl alloc] initWithItems:@[PintResting.exposeLeapAuto.confirmRandomNetTryDiskDog,PintResting.exposeLeapAuto.longestAffectingOccurredProgressDirtyBeacons]];
    entriesView.layer.masksToBounds = YES; 
    entriesView.layer.cornerRadius = 2;    
    [entriesView setTitleTextAttributes:@{NSForegroundColorAttributeName:[PintResting armHelperColor]} forState:UIControlStateSelected];
    [entriesView setTitleTextAttributes:@{NSForegroundColorAttributeName:[PintResting armHelperColor]} forState:UIControlStateNormal];
    [self.view addSubview:entriesView];
    [entriesView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.view);
        make.top.mas_equalTo(PintResting.findClickCat.sonOddTable);
    }];
    [entriesView addTarget:self action:@selector(icyEyeSeeAuto:) forControlEvents:UIControlEventValueChanged];
    self.poolPinHostSubControl = entriesView;
    
    _timeInverseView = [[UIScrollView alloc]init];
    _timeInverseView.pagingEnabled = YES;
    _timeInverseView.delegate = self;
    [self.view addSubview:_timeInverseView];
    [_timeInverseView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view).offset(PintResting.findClickCat.bitParentHex);
        make.right.equalTo(self.view).offset(-PintResting.findClickCat.bitParentHex);
        make.top.equalTo(self.view).offset(PintResting.findClickCat.treeKinAcute);
        make.bottom.equalTo(self.view).offset(-PintResting.findClickCat.reclaimLiner);
    }];
    
    UIView *containerView = [UIView new];
    containerView.backgroundColor = UIColor.whiteColor;
    [self.timeInverseView addSubview:containerView];
    [containerView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.timeInverseView);
        make.height.equalTo(_timeInverseView);
    }];
    
    UIView * rowSizeLight = [self wireFitSpaView:[PintResting separateProvidedSentShipmentFiller]];
    [containerView addSubview:rowSizeLight];
    [rowSizeLight mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(0);
        make.top.bottom.equalTo(containerView);
        make.width.mas_equalTo(self.timeInverseView);
    }];
    self.illHandlingPossibleTabularMill = rowSizeLight;
    
    UIView * suspendedPin = [self wireFitSpaView:[PintResting verboseDisplaysSobClipStair]];
    [containerView addSubview:suspendedPin];
    [suspendedPin mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(rowSizeLight.mas_right);
        make.bottom.top.equalTo(containerView);
        make.width.mas_equalTo(self.timeInverseView);
    }];
    self.badReversedNumberBuddyFriction = suspendedPin;
    
    [containerView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(suspendedPin.mas_right);
    }];
    
    if (![self.grandsonPop boolValue]) {
        UIButton *invitedButton = [PintResting serbianManInvokeSnapshotTwelveColor:PintResting.exposeLeapAuto.artThePurple];
        [invitedButton setBackgroundImage:[UIImage incrementNonceColor:[[UIColor lightGrayColor] colorWithAlphaComponent:0.5f]] forState:UIControlStateNormal];
        [invitedButton addTarget:self action:@selector(hueChamberSplatHourlyExistentUses:) forControlEvents:(UIControlEventTouchUpInside)];
        [self.view addSubview:invitedButton];
        
        [invitedButton mas_makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.equalTo(self.view).offset(-PintResting.findClickCat.hueDoneFont);
            make.left.equalTo(self.view).offset(PintResting.findClickCat.bitParentHex);
            make.right.equalTo(self.view.mas_centerX).offset(-PintResting.findClickCat.airCapsSign);
            make.height.mas_equalTo(PintResting.findClickCat.spouseAnswer);
        }];
    }

    UIButton *useBeenButton =  [PintResting serbianManInvokeSnapshotTwelveColor:PintResting.exposeLeapAuto.hasWarnBox];
    [useBeenButton addTarget:self action:@selector(decayMarginWinEntryEntryReduce:) forControlEvents:(UIControlEventTouchUpInside)];
    [self.view addSubview:useBeenButton];
    BOOL readyButton = ![self.grandsonPop boolValue];
    [useBeenButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.view).offset(-PintResting.findClickCat.hueDoneFont);
        make.right.equalTo(self.view).offset(-PintResting.findClickCat.bitParentHex);
        
        if (readyButton) {
            make.left.equalTo(self.view.mas_centerX).offset(PintResting.findClickCat.airCapsSign);
        } else {
            make.left.equalTo(self.view).offset(PintResting.findClickCat.bitParentHex);
        }
        make.height.mas_equalTo(PintResting.findClickCat.spouseAnswer);
    }];
    
    entriesView.selectedSegmentIndex = 0;
    [self icyEyeSeeAuto:entriesView];
}

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

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

- (void)redirectAdapterWarnNominallyTextText:(NSInteger)type {
    NSString *wrapTabZip = nil;
    UIView *contentView = nil;
    wrapTabZip = type == 0 ? [PintResting separateProvidedSentShipmentFiller]:[PintResting verboseDisplaysSobClipStair];
    contentView = type == 0 ? self.illHandlingPossibleTabularMill:self.badReversedNumberBuddyFriction;
    
    if (wrapTabZip.mayItsPartly) {
        return;
    }
    
    if ([[wrapTabZip pathExtension] containsString:PintResting.findClickCat.purplePresentedSoftwareSpousesBayer]) {
        UITextView *askView = (UITextView *)contentView;
        if (askView.text.length > 0) {
            return;
        }

        
        [EmptyBatchView secondRepeatsView:contentView];

        
        NSURL *url = [NSURL URLWithString:wrapTabZip];
        NSURLSessionDataTask *task = [[NSURLSession sharedSession] dataTaskWithURL:url
                                                                 completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
            
            dispatch_async(dispatch_get_main_queue(), ^{
                
                [EmptyBatchView resolvedSimpleClosestPeerMessageView:contentView];
                
                if (error || data.length == 0) {
                    
                    askView.text = PintResting.exposeLeapAuto.grantingRevertingSafetyOverallNeedBordered;
                    return;
                }
                
                
                NSString *zeroStepchild = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
                askView.text = zeroStepchild ?: PintResting.exposeLeapAuto.penLowerNextCarrierBevelEraDeep;
            });
        }];
        
        [task resume];

    }else {
        WKWebView *reveal = (WKWebView *)contentView;
        if (!reveal.isLoading && reveal.estimatedProgress == 1) {
            [EmptyBatchView resolvedSimpleClosestPeerMessageView:contentView];
            return;
        }
        [EmptyBatchView secondRepeatsView:contentView];
        NSString *sliceSelf =  [wrapTabZip.answerSemicolonCutoffMusicianWorkSensor stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
        NSURL *url = [NSURL URLWithString:sliceSelf];
        NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:15.0];
        [reveal loadRequest:request];
    }
}

- (void)hueChamberSplatHourlyExistentUses:(id)sender {
    [self buildFirstClickedBroadcastHowAction:nil];
    if (self.interiorKurdishRevertSelectInside) {
        self.interiorKurdishRevertSelectInside(NO);
    }
}

- (void)decayMarginWinEntryEntryReduce:(id)sender {
    [self buildFirstClickedBroadcastHowAction:nil];
    if (self.interiorKurdishRevertSelectInside) {
        self.interiorKurdishRevertSelectInside(YES);
    }
}

- (UIView *)wireFitSpaView:(NSString *)string {
    UIView *sumRollSwap = nil;
    if ([[string pathExtension] containsString:PintResting.findClickCat.purplePresentedSoftwareSpousesBayer]) {
        UITextView * occurArt = [UITextView new];
        occurArt.editable = NO;
        occurArt.backgroundColor = UIColor.whiteColor;
        occurArt.textColor = UIColor.grayColor;
        sumRollSwap = occurArt;
    }else {
        WKWebView *bigUnlocked = [[WKWebView alloc] initWithFrame:CGRectZero];
        bigUnlocked.backgroundColor = UIColor.clearColor;
        bigUnlocked.scrollView.backgroundColor = UIColor.lightGrayColor;
        bigUnlocked.opaque = YES;
        bigUnlocked.scrollView.bounces =NO;
        bigUnlocked.scrollView.showsVerticalScrollIndicator = NO;
        bigUnlocked.scrollView.showsHorizontalScrollIndicator = NO;
        bigUnlocked.navigationDelegate = self;
        sumRollSwap = bigUnlocked;
    }
    return sumRollSwap;
}

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

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

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

@end
