package com.google.android.gms.internal.ads;

import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.net.TrafficStats;
import android.net.Uri;
import android.os.Looper;
import android.os.SystemClock;
import android.view.KeyEvent;
import android.view.View;
import android.webkit.WebResourceResponse;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Toolbar;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import androidx.media3.exoplayer.rtsp.RtspHeaders;
import androidx.media3.exoplayer.rtsp.SessionDescription;
import com.google.android.gms.ads.internal.overlay.AdOverlayInfoParcel;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.WeakHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import tv.danmaku.ijk.media.player.IMediaPlayer;

/* JADX INFO: loaded from: classes2.dex */
public class c60 extends WebViewClient implements y60 {

    /* JADX INFO: renamed from: f0, reason: collision with root package name */
    public static final /* synthetic */ int f9745f0 = 0;
    public boolean S;
    public boolean T;
    public boolean U;
    public boolean V;
    public com.google.android.gms.ads.internal.overlay.d W;
    public m7.b X;
    public boolean Z;

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final x50 f9746a;

    /* JADX INFO: renamed from: a0, reason: collision with root package name */
    public boolean f9747a0;

    /* JADX INFO: renamed from: b0, reason: collision with root package name */
    public int f9749b0;

    /* JADX INFO: renamed from: c0, reason: collision with root package name */
    public boolean f9751c0;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public n7.a f9752d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public com.google.android.gms.ads.internal.overlay.p f9754e;

    /* JADX INFO: renamed from: e0, reason: collision with root package name */
    public y50 f9755e0;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public w60 f9756f;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public x60 f9757g;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public js f9758h;

    /* JADX INFO: renamed from: i, reason: collision with root package name */
    public ks f9759i;

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    public fk0 f9760j;

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    public boolean f9761k;

    /* JADX INFO: renamed from: l, reason: collision with root package name */
    public boolean f9762l;

    @Nullable
    private cr0 zzA;

    @Nullable
    private td0 zzB;

    @Nullable
    private final hw0 zzH;

    @Nullable
    protected p10 zzb;

    @Nullable
    private final il zzd;

    @Nullable
    private yx zzx;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final HashMap f9748b = new HashMap();

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final Object f9750c = new Object();

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    public int f9763m = 0;
    public String Q = "";
    public String R = "";
    public ux Y = null;

    /* JADX INFO: renamed from: d0, reason: collision with root package name */
    public final HashSet f9753d0 = new HashSet(Arrays.asList(((String) n7.y.f31093e.f31096c.b(ao.f9150x6)).split(",")));

    @VisibleForTesting
    public c60(x50 x50Var, @Nullable il ilVar, boolean z10, yx yxVar, @Nullable ux uxVar, @Nullable hw0 hw0Var) {
        this.zzd = ilVar;
        this.f9746a = x50Var;
        this.S = z10;
        this.zzx = yxVar;
        this.zzH = hw0Var;
    }

    public static final boolean n(x50 x50Var) {
        return x50Var.zzC() != null && x50Var.zzC().b();
    }

    public static final boolean p(boolean z10, x50 x50Var) {
        return (!z10 || x50Var.zzN().b() || x50Var.zzO().equals("interstitial_mb")) ? false : true;
    }

    @Nullable
    private static WebResourceResponse zzae() {
        if (((Boolean) n7.y.f31093e.f31096c.b(ao.f8880h1)).booleanValue()) {
            return new WebResourceResponse("", "", new ByteArrayInputStream(new byte[0]));
        }
        return null;
    }

    /* JADX WARN: Code restructure failed: missing block: B:38:0x0101, code lost:
    
        r0 = r7.getContentType();
     */
    /* JADX WARN: Code restructure failed: missing block: B:39:0x0109, code lost:
    
        r4 = "";
     */
    /* JADX WARN: Code restructure failed: missing block: B:40:0x010d, code lost:
    
        if (android.text.TextUtils.isEmpty(r0) == false) goto L42;
     */
    /* JADX WARN: Code restructure failed: missing block: B:41:0x010f, code lost:
    
        r11 = "";
     */
    /* JADX WARN: Code restructure failed: missing block: B:42:0x0111, code lost:
    
        r11 = r0.split(";")[0].trim();
     */
    /* JADX WARN: Code restructure failed: missing block: B:43:0x011c, code lost:
    
        r0 = r7.getContentType();
     */
    /* JADX WARN: Code restructure failed: missing block: B:44:0x0124, code lost:
    
        if (android.text.TextUtils.isEmpty(r0) == false) goto L46;
     */
    /* JADX WARN: Code restructure failed: missing block: B:45:0x0126, code lost:
    
        r12 = r4;
     */
    /* JADX WARN: Code restructure failed: missing block: B:46:0x0128, code lost:
    
        r0 = r0.split(";");
     */
    /* JADX WARN: Code restructure failed: missing block: B:47:0x012d, code lost:
    
        if (r0.length != 1) goto L49;
     */
    /* JADX WARN: Code restructure failed: missing block: B:49:0x0130, code lost:
    
        r1 = 1;
     */
    /* JADX WARN: Code restructure failed: missing block: B:51:0x0132, code lost:
    
        if (r1 >= r0.length) goto L102;
     */
    /* JADX WARN: Code restructure failed: missing block: B:53:0x0140, code lost:
    
        if (r0[r1].trim().startsWith("charset") == false) goto L104;
     */
    /* JADX WARN: Code restructure failed: missing block: B:54:0x0142, code lost:
    
        r2 = r0[r1].trim().split("=");
     */
    /* JADX WARN: Code restructure failed: missing block: B:55:0x014f, code lost:
    
        if (r2.length <= 1) goto L105;
     */
    /* JADX WARN: Code restructure failed: missing block: B:56:0x0151, code lost:
    
        r4 = r2[1].trim();
     */
    /* JADX WARN: Code restructure failed: missing block: B:57:0x0158, code lost:
    
        r1 = r1 + 1;
     */
    /* JADX WARN: Code restructure failed: missing block: B:58:0x015b, code lost:
    
        r0 = r7.getHeaderFields();
        r15 = new java.util.HashMap(r0.size());
        r0 = r0.entrySet().iterator();
     */
    /* JADX WARN: Code restructure failed: missing block: B:60:0x0174, code lost:
    
        if (r0.hasNext() == false) goto L93;
     */
    /* JADX WARN: Code restructure failed: missing block: B:61:0x0176, code lost:
    
        r1 = r0.next();
     */
    /* JADX WARN: Code restructure failed: missing block: B:62:0x0180, code lost:
    
        if (r1.getKey() == null) goto L98;
     */
    /* JADX WARN: Code restructure failed: missing block: B:64:0x0186, code lost:
    
        if (r1.getValue() == null) goto L99;
     */
    /* JADX WARN: Code restructure failed: missing block: B:66:0x0192, code lost:
    
        if (r1.getValue().isEmpty() != false) goto L100;
     */
    /* JADX WARN: Code restructure failed: missing block: B:67:0x0194, code lost:
    
        r15.put(r1.getKey(), r1.getValue().get(0));
     */
    /* JADX WARN: Code restructure failed: missing block: B:68:0x01aa, code lost:
    
        r0 = m7.n.C.f30467f;
        r13 = r7.getResponseCode();
        r14 = r7.getResponseMessage();
        r16 = r7.getInputStream();
        r0.getClass();
     */
    /* JADX WARN: Code restructure failed: missing block: B:69:0x01c3, code lost:
    
        r10 = new android.webkit.WebResourceResponse(r11, r12, r13, r14, r15, r16);
     */
    @Nullable
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    private final WebResourceResponse zzaf(String str, Map map) throws Throwable {
        WebResourceResponse webResourceResponse;
        URL url = new URL(str);
        try {
            TrafficStats.setThreadStatsTag(264);
            int i10 = 0;
            while (true) {
                i10++;
                if (i10 > 20) {
                    TrafficStats.clearThreadStatsTag();
                    throw new IOException("Too many redirects (20)");
                }
                URLConnection uRLConnectionOpenConnection = url.openConnection();
                uRLConnectionOpenConnection.setConnectTimeout(10000);
                uRLConnectionOpenConnection.setReadTimeout(10000);
                for (Map.Entry entry : map.entrySet()) {
                    uRLConnectionOpenConnection.addRequestProperty((String) entry.getKey(), (String) entry.getValue());
                }
                if (!(uRLConnectionOpenConnection instanceof HttpURLConnection)) {
                    throw new IOException("Invalid protocol.");
                }
                HttpURLConnection httpURLConnection = (HttpURLConnection) uRLConnectionOpenConnection;
                p7.r0 r0Var = m7.n.C.f30464c;
                try {
                    x50 x50Var = this.f9746a;
                    r0Var.x(x50Var.getContext(), x50Var.zzs().f32212a, httpURLConnection, 60000);
                    webResourceResponse = null;
                    q7.g gVar = new q7.g(null);
                    gVar.zza(httpURLConnection, null);
                    int responseCode = httpURLConnection.getResponseCode();
                    gVar.a(httpURLConnection, responseCode);
                    if (responseCode < 300 || responseCode >= 400) {
                        break;
                    }
                    String headerField = httpURLConnection.getHeaderField(RtspHeaders.LOCATION);
                    if (headerField == null) {
                        throw new IOException("Missing Location header in redirect");
                    }
                    if (headerField.startsWith("tel:")) {
                        break;
                    }
                    URL url2 = new URL(url, headerField);
                    String protocol = url2.getProtocol();
                    if (protocol == null) {
                        q7.j.d("Protocol is null");
                        webResourceResponse = zzae();
                        break;
                    }
                    if (!protocol.equals("http") && !protocol.equals("https")) {
                        StringBuilder sb = new StringBuilder(protocol.length() + 20);
                        sb.append("Unsupported scheme: ");
                        sb.append(protocol);
                        q7.j.d(sb.toString());
                        webResourceResponse = zzae();
                        break;
                    }
                    StringBuilder sb2 = new StringBuilder(headerField.length() + 15);
                    sb2.append("Redirecting to ");
                    sb2.append(headerField);
                    q7.j.a(sb2.toString());
                    httpURLConnection.disconnect();
                    url = url2;
                } catch (Throwable th) {
                    th = th;
                    TrafficStats.clearThreadStatsTag();
                    throw th;
                }
            }
            TrafficStats.clearThreadStatsTag();
            return webResourceResponse;
        } catch (Throwable th2) {
            th = th2;
        }
    }

    public final void M(String str, String str2) {
        hw0 hw0Var = this.zzH;
        x50 x50Var = this.f9746a;
        a(new AdOverlayInfoParcel(x50Var, x50Var.zzs(), str, str2, hw0Var));
    }

    public final void O(int i10, boolean z10, boolean z11) {
        x50 x50Var = this.f9746a;
        boolean zP = p(x50Var.y(), x50Var);
        boolean z12 = true;
        if (!zP && z11) {
            z12 = false;
        }
        a(new AdOverlayInfoParcel(zP ? null : this.f9752d, this.f9754e, this.W, x50Var, z10, i10, x50Var.zzs(), z12 ? null : this.f9760j, n(x50Var) ? this.zzH : null));
    }

    public final void W(boolean z10, int i10, String str, boolean z11, boolean z12) {
        x50 x50Var = this.f9746a;
        boolean zY = x50Var.y();
        boolean zP = p(zY, x50Var);
        boolean z13 = true;
        if (!zP && z11) {
            z13 = false;
        }
        a(new AdOverlayInfoParcel(zP ? null : this.f9752d, zY ? null : new b60(x50Var, this.f9754e), this.f9758h, this.f9759i, this.W, x50Var, z10, i10, str, x50Var.zzs(), z13 ? null : this.f9760j, n(x50Var) ? this.zzH : null, z12));
    }

    public final void a(AdOverlayInfoParcel adOverlayInfoParcel) {
        com.google.android.gms.ads.internal.overlay.g gVar;
        ux uxVar = this.Y;
        if (uxVar != null) {
            synchronized (uxVar.f17418l) {
                z = uxVar.V != null;
            }
        }
        com.google.android.gms.ads.internal.overlay.m mVar = m7.n.C.f30463b;
        com.google.android.gms.ads.internal.overlay.m.zza(this.f9746a.getContext(), adOverlayInfoParcel, !z, this.zzA);
        p10 p10Var = this.zzb;
        if (p10Var != null) {
            String str = adOverlayInfoParcel.f7899l;
            if (str == null && (gVar = adOverlayInfoParcel.f7887a) != null) {
                str = gVar.f7910b;
            }
            ((l10) p10Var).a(str);
        }
    }

    public final void d(String str, ys ysVar) {
        synchronized (this.f9750c) {
            try {
                HashMap map = this.f9748b;
                List copyOnWriteArrayList = (List) map.get(str);
                if (copyOnWriteArrayList == null) {
                    copyOnWriteArrayList = new CopyOnWriteArrayList();
                    map.put(str, copyOnWriteArrayList);
                }
                copyOnWriteArrayList.add(ysVar);
            } catch (Throwable th) {
                throw th;
            }
        }
    }

    public final void e(String str) {
        synchronized (this.f9750c) {
            try {
                List list = (List) this.f9748b.get(str);
                if (list == null) {
                    return;
                }
                list.clear();
            } catch (Throwable th) {
                throw th;
            }
        }
    }

    public final void f() {
        p10 p10Var = this.zzb;
        int i10 = 1;
        if (p10Var != null) {
            l10 l10Var = (l10) p10Var;
            synchronized (l10Var.f13467h) {
                l10Var.f13461b.keySet();
                bv1 bv1VarK = ih1.k(Collections.emptyMap());
                wt wtVar = new wt(l10Var, i10);
                a30 a30Var = b30.f9365g;
                ju1 ju1VarE1 = ih1.e1(bv1VarK, wtVar, a30Var);
                com.google.common.util.concurrent.w wVarZ0 = ih1.Z0(ju1VarE1, 10L, TimeUnit.SECONDS, b30.f9362d);
                ih1.z1(ju1VarE1, new vg(l10Var, wVarZ0), a30Var);
                l10.f13459l.add(wVarZ0);
            }
            this.zzb = null;
        }
        y50 y50Var = this.f9755e0;
        if (y50Var != null) {
            ((View) this.f9746a).removeOnAttachStateChangeListener(y50Var);
        }
        synchronized (this.f9750c) {
            try {
                this.f9748b.clear();
                this.f9752d = null;
                this.f9754e = null;
                this.f9756f = null;
                this.f9757g = null;
                this.f9758h = null;
                this.f9759i = null;
                this.f9761k = false;
                this.S = false;
                this.T = false;
                this.U = false;
                this.W = null;
                this.X = null;
                this.zzx = null;
                ux uxVar = this.Y;
                if (uxVar != null) {
                    uxVar.j(true);
                    this.Y = null;
                }
            } catch (Throwable th) {
                throw th;
            }
        }
    }

    public final cr0 g() {
        return this.zzA;
    }

    public final void h(td0 td0Var) {
        this.zzB = td0Var;
    }

    public final td0 i() {
        return this.zzB;
    }

    public final void j(Uri uri) {
        p7.l0.g("Received GMSG: ".concat(String.valueOf(uri)));
        HashMap map = this.f9748b;
        String path = uri.getPath();
        List list = (List) map.get(path);
        int i10 = 2;
        if (path == null || list == null) {
            p7.l0.g("No GMSG handler found for GMSG: ".concat(String.valueOf(uri)));
            if (!((Boolean) n7.y.f31093e.f31096c.b(ao.f9134w7)).booleanValue() || m7.n.C.f30469h.zza() == null) {
                return;
            }
            b30.f9359a.execute(new mv1((path == null || path.length() < 2) ? "null" : path.substring(1), 25));
            return;
        }
        String encodedQuery = uri.getEncodedQuery();
        tn tnVar = ao.f9133w6;
        n7.y yVar = n7.y.f31093e;
        if (((Boolean) yVar.f31096c.b(tnVar)).booleanValue() && this.f9753d0.contains(path) && encodedQuery != null) {
            if (encodedQuery.length() >= ((Integer) yVar.f31096c.b(ao.f9167y6)).intValue()) {
                p7.l0.g("Parsing gmsg query params on BG thread: ".concat(path));
                p7.r0 r0Var = m7.n.C.f30464c;
                r0Var.getClass();
                ih1.z1(ih1.A0(new x4.a(uri, i10), r0Var.f31774k), new eb(this, list, path, uri), b30.f9364f);
                return;
            }
        }
        p7.r0 r0Var2 = m7.n.C.f30464c;
        m(p7.r0.zzV(uri), list, path);
    }

    public final void k(int i10, int i11) {
        yx yxVar = this.zzx;
        if (yxVar != null) {
            yxVar.j(i10, i11);
        }
        ux uxVar = this.Y;
        if (uxVar != null) {
            synchronized (uxVar.f17418l) {
                uxVar.f17412f = i10;
                uxVar.f17413g = i11;
            }
        }
    }

    public final void l(View view, p10 p10Var, int i10) throws Throwable {
        boolean z10;
        Bitmap bitmapCreateBitmap;
        l10 l10Var = (l10) p10Var;
        boolean z11 = l10Var.f13466g.f14797c;
        if (!z11 || (z10 = l10Var.f13469j) || i10 <= 0) {
            return;
        }
        if (z11 && !z10) {
            p7.r0 r0Var = m7.n.C.f30464c;
            Bitmap bitmap = null;
            if (view != null) {
                try {
                    boolean zIsDrawingCacheEnabled = view.isDrawingCacheEnabled();
                    view.setDrawingCacheEnabled(true);
                    Bitmap drawingCache = view.getDrawingCache();
                    bitmapCreateBitmap = drawingCache != null ? Bitmap.createBitmap(drawingCache) : null;
                    try {
                        view.setDrawingCacheEnabled(zIsDrawingCacheEnabled);
                    } catch (RuntimeException unused) {
                    }
                } catch (RuntimeException unused2) {
                    bitmapCreateBitmap = null;
                }
                if (bitmapCreateBitmap == null) {
                    try {
                        int width = view.getWidth();
                        int height = view.getHeight();
                        if (width == 0 || height == 0) {
                            q7.j.d("Width or height of view is zero");
                        } else {
                            Bitmap bitmapCreateBitmap2 = Bitmap.createBitmap(view.getWidth(), view.getHeight(), Bitmap.Config.RGB_565);
                            Canvas canvas = new Canvas(bitmapCreateBitmap2);
                            view.layout(0, 0, width, height);
                            view.draw(canvas);
                            bitmap = bitmapCreateBitmap2;
                        }
                    } catch (RuntimeException unused3) {
                    }
                } else {
                    bitmap = bitmapCreateBitmap;
                }
            }
            if (bitmap == null) {
                ni.l("Failed to capture the webview bitmap.");
            } else {
                l10Var.f13469j = true;
                bv bvVar = new bv(l10Var, bitmap, 13);
                if (Looper.getMainLooper().getThread() != Thread.currentThread()) {
                    bvVar.run();
                } else {
                    b30.f9359a.execute(bvVar);
                }
            }
        }
        if (!l10Var.f13466g.f14797c || l10Var.f13469j) {
            return;
        }
        p7.r0.f31763l.postDelayed(new l.w0(this, view, l10Var, i10), 100L);
    }

    @Override // com.google.android.gms.internal.ads.fk0
    public final void l0() {
        fk0 fk0Var = this.f9760j;
        if (fk0Var != null) {
            fk0Var.l0();
        }
    }

    public final void m(Map map, List list, String str) {
        if (p7.l0.h()) {
            p7.l0.g("Received GMSG: ".concat(str));
            for (String str2 : map.keySet()) {
                String str3 = (String) map.get(str2);
                StringBuilder sb = new StringBuilder(String.valueOf(str2).length() + 4 + String.valueOf(str3).length());
                sb.append("  ");
                sb.append(str2);
                sb.append(": ");
                sb.append(str3);
                p7.l0.g(sb.toString());
            }
        }
        Iterator it = list.iterator();
        while (it.hasNext()) {
            ((ys) it.next()).a(this.f9746a, map);
        }
    }

    @Override // n7.a
    public final void onAdClicked() {
        n7.a aVar = this.f9752d;
        if (aVar != null) {
            aVar.onAdClicked();
        }
    }

    @Override // android.webkit.WebViewClient
    public final void onLoadResource(WebView webView, String str) {
        p7.l0.g("Loading resource: ".concat(String.valueOf(str)));
        Uri uri = Uri.parse(str);
        if ("gmsg".equalsIgnoreCase(uri.getScheme()) && "mobileads.google.com".equalsIgnoreCase(uri.getHost())) {
            j(uri);
        }
    }

    @Override // android.webkit.WebViewClient
    public final void onPageFinished(WebView webView, String str) {
        Toolbar toolbar;
        synchronized (this.f9750c) {
            try {
                x50 x50Var = this.f9746a;
                if (x50Var.K()) {
                    p7.l0.g("Blank page loaded, 1...");
                    x50Var.B();
                    return;
                }
                this.Z = true;
                x60 x60Var = this.f9757g;
                if (x60Var != null) {
                    x60Var.mo4zza();
                    this.f9757g = null;
                }
                u();
                x50 x50Var2 = this.f9746a;
                if (x50Var2.S() != null) {
                    if (!((Boolean) n7.y.f31093e.f31096c.b(ao.f8859fd)).booleanValue() || (toolbar = x50Var2.S().X) == null) {
                        return;
                    }
                    toolbar.setSubtitle(str);
                }
            } catch (Throwable th) {
                throw th;
            }
        }
    }

    @Override // android.webkit.WebViewClient
    public final void onReceivedError(WebView webView, int i10, String str, String str2) {
        this.f9762l = true;
        this.f9763m = i10;
        this.Q = str;
        this.R = str2;
    }

    public final boolean q() {
        boolean z10;
        synchronized (this.f9750c) {
            z10 = this.T;
        }
        return z10;
    }

    public final void r0(int i10, boolean z10, boolean z11, String str, String str2) {
        x50 x50Var = this.f9746a;
        boolean zY = x50Var.y();
        boolean zP = p(zY, x50Var);
        boolean z12 = true;
        if (!zP && z11) {
            z12 = false;
        }
        a(new AdOverlayInfoParcel(zP ? null : this.f9752d, zY ? null : new b60(x50Var, this.f9754e), this.f9758h, this.f9759i, this.W, x50Var, z10, i10, str, str2, x50Var.zzs(), z12 ? null : this.f9760j, n(x50Var) ? this.zzH : null));
    }

    /* JADX WARN: Multi-variable type inference failed */
    public final void s() throws Throwable {
        p10 p10Var = this.zzb;
        if (p10Var != null) {
            x50 x50Var = this.f9746a;
            WebView webViewC = x50Var.c();
            WeakHashMap weakHashMap = androidx.core.view.s1.f1815a;
            if (webViewC.isAttachedToWindow()) {
                l(webViewC, p10Var, 10);
                return;
            }
            y50 y50Var = this.f9755e0;
            if (y50Var != null) {
                ((View) x50Var).removeOnAttachStateChangeListener(y50Var);
            }
            y50 y50Var2 = new y50(this, p10Var);
            this.f9755e0 = y50Var2;
            ((View) x50Var).addOnAttachStateChangeListener(y50Var2);
        }
    }

    @Override // android.webkit.WebViewClient
    @Nullable
    public final WebResourceResponse shouldInterceptRequest(WebView webView, String str) {
        return zzL(str, Collections.emptyMap());
    }

    @Override // android.webkit.WebViewClient
    public final boolean shouldOverrideKeyEvent(WebView webView, KeyEvent keyEvent) {
        int keyCode = keyEvent.getKeyCode();
        if (keyCode == 79 || keyCode == 222) {
            return true;
        }
        switch (keyCode) {
            case 85:
            case 86:
            case 87:
            case 88:
            case 89:
            case 90:
            case 91:
                return true;
            default:
                switch (keyCode) {
                    case 126:
                    case 127:
                    case 128:
                    case 129:
                    case 130:
                        return true;
                    default:
                        return false;
                }
        }
    }

    /* JADX WARN: Multi-variable type inference failed */
    @Override // android.webkit.WebViewClient
    public final boolean shouldOverrideUrlLoading(WebView webView, String str) {
        p7.l0.g("AdWebView shouldOverrideUrlLoading: ".concat(String.valueOf(str)));
        Uri uriB = Uri.parse(str);
        if ("gmsg".equalsIgnoreCase(uriB.getScheme()) && "mobileads.google.com".equalsIgnoreCase(uriB.getHost())) {
            j(uriB);
        } else {
            boolean z10 = this.f9761k;
            x50 x50Var = this.f9746a;
            if (z10 && webView == x50Var.c()) {
                String scheme = uriB.getScheme();
                if ("http".equalsIgnoreCase(scheme) || "https".equalsIgnoreCase(scheme)) {
                    n7.a aVar = this.f9752d;
                    if (aVar != null) {
                        aVar.onAdClicked();
                        p10 p10Var = this.zzb;
                        if (p10Var != null) {
                            ((l10) p10Var).a(str);
                        }
                        this.f9752d = null;
                    }
                    fk0 fk0Var = this.f9760j;
                    if (fk0Var != null) {
                        fk0Var.w();
                        this.f9760j = null;
                    }
                    return super.shouldOverrideUrlLoading(webView, str);
                }
            }
            if (x50Var.c().willNotDraw()) {
                q7.j.d("AdWebView unable to handle URL: ".concat(String.valueOf(str)));
            } else {
                try {
                    tg tgVarZ = x50Var.z();
                    kb1 kb1VarI0 = x50Var.i0();
                    if (!((Boolean) n7.y.f31093e.f31096c.b(ao.f8924jd)).booleanValue() || kb1VarI0 == null) {
                        if (tgVarZ != null && tgVarZ.a(uriB)) {
                            uriB = tgVarZ.b(uriB, x50Var.getContext(), (View) x50Var, x50Var.zzj());
                        }
                    } else if (tgVarZ != null && tgVarZ.a(uriB)) {
                        uriB = kb1VarI0.zza(uriB, x50Var.getContext(), (View) x50Var, x50Var.zzj());
                    }
                } catch (zzazi unused) {
                    q7.j.d("Unable to append parameter to URL: ".concat(String.valueOf(str)));
                }
                m7.b bVar = this.X;
                if (bVar == null || bVar.a()) {
                    v(new com.google.android.gms.ads.internal.overlay.g("android.intent.action.VIEW", uriB.toString(), null, null, null, null, null, null), true, false, x50Var.zzn());
                } else {
                    bVar.zzc(str);
                }
            }
        }
        return true;
    }

    public final void t() {
        il ilVar = this.zzd;
        if (ilVar != null) {
            ilVar.b(IMediaPlayer.MEDIA_INFO_OPEN_INPUT);
        }
        this.f9747a0 = true;
        this.f9763m = IMediaPlayer.MEDIA_INFO_VIDEO_DECODED_START;
        this.Q = "Page loaded delay cancel.";
        u();
        this.f9746a.destroy();
    }

    public final void u() {
        w60 w60Var = this.f9756f;
        x50 x50Var = this.f9746a;
        if (w60Var != null && ((this.Z && this.f9749b0 <= 0) || this.f9747a0 || this.f9762l)) {
            if (((Boolean) n7.y.f31093e.f31096c.b(ao.f8979n2)).booleanValue() && x50Var.zzq() != null) {
                eo.zza(x50Var.zzq().f13331b, x50Var.zzi(), "awfllc");
            }
            w60 w60Var2 = this.f9756f;
            boolean z10 = false;
            if (!this.f9747a0 && !this.f9762l) {
                z10 = true;
            }
            w60Var2.s(this.Q, this.f9763m, this.R, z10);
            this.f9756f = null;
        }
        x50Var.E();
    }

    public final void v(com.google.android.gms.ads.internal.overlay.g gVar, boolean z10, boolean z11, String str) {
        x50 x50Var = this.f9746a;
        boolean zY = x50Var.y();
        boolean z12 = p(zY, x50Var) || z11;
        a(new AdOverlayInfoParcel(gVar, z12 ? null : this.f9752d, zY ? null : this.f9754e, this.W, x50Var.zzs(), x50Var, z12 || !z10 ? null : this.f9760j, str));
    }

    @Override // com.google.android.gms.internal.ads.fk0
    public final void w() {
        fk0 fk0Var = this.f9760j;
        if (fk0Var != null) {
            fk0Var.w();
        }
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Removed duplicated region for block: B:101:0x02c5 A[Catch: NoClassDefFoundError -> 0x0020, Exception -> 0x0023, TryCatch #18 {Exception -> 0x0023, NoClassDefFoundError -> 0x0020, blocks: (B:3:0x000c, B:5:0x0019, B:10:0x0026, B:12:0x0036, B:14:0x003d, B:16:0x0049, B:18:0x0065, B:20:0x007f, B:22:0x0096, B:23:0x0099, B:25:0x009c, B:33:0x00ca, B:98:0x024a, B:91:0x0223, B:142:0x032e, B:90:0x01e5, B:99:0x0289, B:100:0x02c4, B:54:0x0163, B:101:0x02c5, B:103:0x02d2, B:105:0x02d8, B:107:0x02db, B:108:0x02dc, B:109:0x02e3, B:111:0x02e6, B:112:0x02e7, B:113:0x02ee, B:115:0x02f1, B:116:0x02f2, B:117:0x02f9, B:119:0x02fc, B:120:0x02fd, B:122:0x030b, B:126:0x031c, B:127:0x031d, B:130:0x0320, B:131:0x0321, B:134:0x0324, B:135:0x0325, B:138:0x0328, B:139:0x0329, B:144:0x0342, B:146:0x0348, B:148:0x0356, B:110:0x02e4, B:106:0x02d9, B:118:0x02fa, B:114:0x02ef), top: B:165:0x000c, inners: #2, #4, #17, #19 }] */
    /* JADX WARN: Removed duplicated region for block: B:142:0x032e A[Catch: NoClassDefFoundError -> 0x0020, Exception -> 0x0023, TryCatch #18 {Exception -> 0x0023, NoClassDefFoundError -> 0x0020, blocks: (B:3:0x000c, B:5:0x0019, B:10:0x0026, B:12:0x0036, B:14:0x003d, B:16:0x0049, B:18:0x0065, B:20:0x007f, B:22:0x0096, B:23:0x0099, B:25:0x009c, B:33:0x00ca, B:98:0x024a, B:91:0x0223, B:142:0x032e, B:90:0x01e5, B:99:0x0289, B:100:0x02c4, B:54:0x0163, B:101:0x02c5, B:103:0x02d2, B:105:0x02d8, B:107:0x02db, B:108:0x02dc, B:109:0x02e3, B:111:0x02e6, B:112:0x02e7, B:113:0x02ee, B:115:0x02f1, B:116:0x02f2, B:117:0x02f9, B:119:0x02fc, B:120:0x02fd, B:122:0x030b, B:126:0x031c, B:127:0x031d, B:130:0x0320, B:131:0x0321, B:134:0x0324, B:135:0x0325, B:138:0x0328, B:139:0x0329, B:144:0x0342, B:146:0x0348, B:148:0x0356, B:110:0x02e4, B:106:0x02d9, B:118:0x02fa, B:114:0x02ef), top: B:165:0x000c, inners: #2, #4, #17, #19 }] */
    /* JADX WARN: Removed duplicated region for block: B:146:0x0348 A[Catch: NoClassDefFoundError -> 0x0020, Exception -> 0x0023, TryCatch #18 {Exception -> 0x0023, NoClassDefFoundError -> 0x0020, blocks: (B:3:0x000c, B:5:0x0019, B:10:0x0026, B:12:0x0036, B:14:0x003d, B:16:0x0049, B:18:0x0065, B:20:0x007f, B:22:0x0096, B:23:0x0099, B:25:0x009c, B:33:0x00ca, B:98:0x024a, B:91:0x0223, B:142:0x032e, B:90:0x01e5, B:99:0x0289, B:100:0x02c4, B:54:0x0163, B:101:0x02c5, B:103:0x02d2, B:105:0x02d8, B:107:0x02db, B:108:0x02dc, B:109:0x02e3, B:111:0x02e6, B:112:0x02e7, B:113:0x02ee, B:115:0x02f1, B:116:0x02f2, B:117:0x02f9, B:119:0x02fc, B:120:0x02fd, B:122:0x030b, B:126:0x031c, B:127:0x031d, B:130:0x0320, B:131:0x0321, B:134:0x0324, B:135:0x0325, B:138:0x0328, B:139:0x0329, B:144:0x0342, B:146:0x0348, B:148:0x0356, B:110:0x02e4, B:106:0x02d9, B:118:0x02fa, B:114:0x02ef), top: B:165:0x000c, inners: #2, #4, #17, #19 }] */
    /* JADX WARN: Removed duplicated region for block: B:150:0x035b A[ADDED_TO_REGION, ORIG_RETURN, RETURN] */
    /* JADX WARN: Removed duplicated region for block: B:167:0x00b6 A[EXC_TOP_SPLITTER, SYNTHETIC] */
    /* JADX WARN: Removed duplicated region for block: B:85:0x01cf A[Catch: all -> 0x01d8, TryCatch #14 {all -> 0x01d8, blocks: (B:94:0x022d, B:96:0x023f, B:97:0x0246, B:83:0x01bd, B:85:0x01cf, B:89:0x01db), top: B:160:0x00e2 }] */
    /* JADX WARN: Removed duplicated region for block: B:96:0x023f A[Catch: all -> 0x01d8, TryCatch #14 {all -> 0x01d8, blocks: (B:94:0x022d, B:96:0x023f, B:97:0x0246, B:83:0x01bd, B:85:0x01cf, B:89:0x01db), top: B:160:0x00e2 }] */
    @Nullable
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final WebResourceResponse zzL(String str, Map map) throws Throwable {
        int i10;
        tn tnVar;
        n7.y yVar;
        final boolean z10;
        final boolean z11;
        final boolean z12;
        InputStream inputStream;
        InputStream inputStream2;
        InputStream inputStream3;
        String string;
        InputStream it1Var;
        boolean z13;
        boolean z14;
        boolean z15;
        long j10;
        try {
            HashMap map2 = new HashMap();
            x50 x50Var = this.f9746a;
            if (x50Var.zzC() != null) {
                map2 = x50Var.zzC().f18004q0;
            }
            String strE = ni.e(str, x50Var.getContext(), this.f9751c0, map2);
            if (!strE.equals(str)) {
                return zzaf(strE, map);
            }
            yk ykVarZza = yk.zza(Uri.parse(str));
            if (ykVarZza != null) {
                HashMap map3 = new HashMap();
                map3.put("Access-Control-Allow-Origin", "*");
                Uri uri = Uri.parse(str);
                if (uri.getQueryParameterNames().contains(SessionDescription.ATTR_RANGE)) {
                    List listN = ru.c(new kq1('-')).n(uri.getQueryParameter(SessionDescription.ATTR_RANGE));
                    if (listN.size() == 2) {
                        int i11 = Integer.parseInt((String) listN.get(0));
                        int i12 = Integer.parseInt((String) listN.get(1)) + 1;
                        if (i11 > 0) {
                            ykVarZza.f18864g = i11;
                        }
                        i10 = i12 - i11;
                    }
                    tnVar = ao.f8767a5;
                    yVar = n7.y.f31093e;
                    if (((Boolean) yVar.f31096c.b(tnVar)).booleanValue()) {
                        vk vkVarB = m7.n.C.f30471j.b(ykVarZza);
                        if (vkVarB == null || !vkVarB.w()) {
                            it1Var = null;
                        } else {
                            synchronized (vkVarB) {
                                z13 = vkVarB.f17666a;
                            }
                            map3.put("X-Afma-Gcache-HasAdditionalMetadataFromReadV2", Boolean.toString(z13));
                            synchronized (vkVarB) {
                                z14 = vkVarB.f17669d;
                            }
                            map3.put("X-Afma-Gcache-IsGcacheHit", Boolean.toString(z14));
                            synchronized (vkVarB) {
                                z15 = vkVarB.f17667b;
                            }
                            map3.put("X-Afma-Gcache-IsDownloaded", Boolean.toString(z15));
                            synchronized (vkVarB) {
                                j10 = vkVarB.f17668c;
                            }
                            map3.put("X-Afma-Gcache-CachedBytes", Long.toString(j10));
                            InputStream inputStreamZzb = vkVarB.zzb();
                            if (i10 != -1) {
                                long j11 = i10;
                                int i13 = jt1.f13018a;
                                it1Var = new it1(inputStreamZzb, j11, 0);
                            } else {
                                it1Var = inputStreamZzb;
                            }
                        }
                    } else {
                        try {
                            String strZzn = x50Var.zzn();
                            if (strZzn == null) {
                                strZzn = "";
                            }
                            ykVarZza.f18865h = strZzn;
                            ykVarZza.f18866i = x50Var.zzp();
                            try {
                                long jLongValue = (ykVarZza.f18863f ? (Long) yVar.f31096c.b(ao.f8801c5) : (Long) yVar.f31096c.b(ao.f8784b5)).longValue();
                                m7.n nVar = m7.n.C;
                                nVar.f30472k.getClass();
                                long jElapsedRealtime = SystemClock.elapsedRealtime();
                                al alVarA = new el(x50Var.getContext()).a(ykVarZza);
                                try {
                                    gl glVar = (gl) alVarA.f10610a.get(jLongValue, TimeUnit.MILLISECONDS);
                                    try {
                                        try {
                                            map3.put("X-Afma-Gcache-HasAdditionalMetadataFromReadV2", Boolean.toString(glVar.f11781b));
                                            map3.put("X-Afma-Gcache-IsGcacheHit", Boolean.toString(glVar.f11782c));
                                            map3.put("X-Afma-Gcache-IsDownloaded", Boolean.toString(glVar.f11784e));
                                            map3.put("X-Afma-Gcache-CachedBytes", Long.toString(glVar.f11783d));
                                            InputStream it1Var2 = glVar.f11780a;
                                            if (i10 != -1) {
                                                long j12 = i10;
                                                try {
                                                    int i14 = jt1.f13018a;
                                                    it1Var2 = new it1(it1Var2, j12, 0);
                                                } catch (InterruptedException e10) {
                                                    e = e10;
                                                    inputStream2 = it1Var2;
                                                    z12 = true;
                                                    if (((Boolean) n7.y.f31093e.f31096c.b(ao.f8851f5)).booleanValue()) {
                                                        m7.n.C.f30469h.d("AdWebViewClient.interceptRequest.gcache", e);
                                                    }
                                                    alVarA.cancel(true);
                                                    Thread.currentThread().interrupt();
                                                    m7.n.C.f30472k.getClass();
                                                    final long jElapsedRealtime2 = SystemClock.elapsedRealtime() - jElapsedRealtime;
                                                    final int i15 = 1;
                                                    inputStream3 = inputStream2;
                                                    p7.r0.f31763l.post(new Runnable(this) { // from class: com.google.android.gms.internal.ads.a60

                                                        /* JADX INFO: renamed from: b, reason: collision with root package name */
                                                        public final /* synthetic */ c60 f8500b;

                                                        {
                                                            this.f8500b = this;
                                                        }

                                                        @Override // java.lang.Runnable
                                                        public final /* synthetic */ void run() {
                                                            int i16 = i15;
                                                            boolean z16 = z12;
                                                            long j13 = jElapsedRealtime2;
                                                            c60 c60Var = this.f8500b;
                                                            switch (i16) {
                                                                case 0:
                                                                    c60Var.f9746a.v(j13, z16);
                                                                    break;
                                                                case 1:
                                                                    c60Var.f9746a.v(j13, z16);
                                                                    break;
                                                                default:
                                                                    c60Var.f9746a.v(j13, z16);
                                                                    break;
                                                            }
                                                        }
                                                    });
                                                    StringBuilder sb = new StringBuilder(String.valueOf(jElapsedRealtime2).length() + 24);
                                                    sb.append("Cache connection took ");
                                                    sb.append(jElapsedRealtime2);
                                                    sb.append("ms");
                                                    string = sb.toString();
                                                    p7.l0.g(string);
                                                    it1Var = inputStream3;
                                                } catch (ExecutionException e11) {
                                                    e = e11;
                                                    inputStream = it1Var2;
                                                    z11 = true;
                                                    if (((Boolean) n7.y.f31093e.f31096c.b(ao.f8851f5)).booleanValue()) {
                                                        m7.n.C.f30469h.d("AdWebViewClient.interceptRequest.gcache", e);
                                                    }
                                                    alVarA.cancel(true);
                                                    m7.n.C.f30472k.getClass();
                                                    final long jElapsedRealtime3 = SystemClock.elapsedRealtime() - jElapsedRealtime;
                                                    final int i16 = 0;
                                                    inputStream3 = inputStream;
                                                    p7.r0.f31763l.post(new Runnable(this) { // from class: com.google.android.gms.internal.ads.a60

                                                        /* JADX INFO: renamed from: b, reason: collision with root package name */
                                                        public final /* synthetic */ c60 f8500b;

                                                        {
                                                            this.f8500b = this;
                                                        }

                                                        @Override // java.lang.Runnable
                                                        public final /* synthetic */ void run() {
                                                            int i162 = i16;
                                                            boolean z16 = z11;
                                                            long j13 = jElapsedRealtime3;
                                                            c60 c60Var = this.f8500b;
                                                            switch (i162) {
                                                                case 0:
                                                                    c60Var.f9746a.v(j13, z16);
                                                                    break;
                                                                case 1:
                                                                    c60Var.f9746a.v(j13, z16);
                                                                    break;
                                                                default:
                                                                    c60Var.f9746a.v(j13, z16);
                                                                    break;
                                                            }
                                                        }
                                                    });
                                                    StringBuilder sb2 = new StringBuilder(String.valueOf(jElapsedRealtime3).length() + 24);
                                                    sb2.append("Cache connection took ");
                                                    sb2.append(jElapsedRealtime3);
                                                    sb2.append("ms");
                                                    string = sb2.toString();
                                                    p7.l0.g(string);
                                                    it1Var = inputStream3;
                                                } catch (TimeoutException e12) {
                                                    e = e12;
                                                    inputStream = it1Var2;
                                                    z11 = true;
                                                    if (((Boolean) n7.y.f31093e.f31096c.b(ao.f8851f5)).booleanValue()) {
                                                    }
                                                    alVarA.cancel(true);
                                                    m7.n.C.f30472k.getClass();
                                                    final long jElapsedRealtime32 = SystemClock.elapsedRealtime() - jElapsedRealtime;
                                                    final int i162 = 0;
                                                    inputStream3 = inputStream;
                                                    p7.r0.f31763l.post(new Runnable(this) { // from class: com.google.android.gms.internal.ads.a60

                                                        /* JADX INFO: renamed from: b, reason: collision with root package name */
                                                        public final /* synthetic */ c60 f8500b;

                                                        {
                                                            this.f8500b = this;
                                                        }

                                                        @Override // java.lang.Runnable
                                                        public final /* synthetic */ void run() {
                                                            int i1622 = i162;
                                                            boolean z16 = z11;
                                                            long j13 = jElapsedRealtime32;
                                                            c60 c60Var = this.f8500b;
                                                            switch (i1622) {
                                                                case 0:
                                                                    c60Var.f9746a.v(j13, z16);
                                                                    break;
                                                                case 1:
                                                                    c60Var.f9746a.v(j13, z16);
                                                                    break;
                                                                default:
                                                                    c60Var.f9746a.v(j13, z16);
                                                                    break;
                                                            }
                                                        }
                                                    });
                                                    StringBuilder sb22 = new StringBuilder(String.valueOf(jElapsedRealtime32).length() + 24);
                                                    sb22.append("Cache connection took ");
                                                    sb22.append(jElapsedRealtime32);
                                                    sb22.append("ms");
                                                    string = sb22.toString();
                                                    p7.l0.g(string);
                                                    it1Var = inputStream3;
                                                }
                                            }
                                            nVar.f30472k.getClass();
                                            long jElapsedRealtime4 = SystemClock.elapsedRealtime() - jElapsedRealtime;
                                            p7.r0.f31763l.post(new z50(this, jElapsedRealtime4));
                                            StringBuilder sb3 = new StringBuilder(String.valueOf(jElapsedRealtime4).length() + 24);
                                            sb3.append("Cache connection took ");
                                            sb3.append(jElapsedRealtime4);
                                            sb3.append("ms");
                                            p7.l0.g(sb3.toString());
                                            it1Var = it1Var2;
                                        } catch (Throwable th) {
                                            th = th;
                                            z10 = 1;
                                            m7.n.C.f30472k.getClass();
                                            final long jElapsedRealtime5 = SystemClock.elapsedRealtime() - jElapsedRealtime;
                                            final int i17 = 2;
                                            p7.r0.f31763l.post(new Runnable(this) { // from class: com.google.android.gms.internal.ads.a60

                                                /* JADX INFO: renamed from: b, reason: collision with root package name */
                                                public final /* synthetic */ c60 f8500b;

                                                {
                                                    this.f8500b = this;
                                                }

                                                @Override // java.lang.Runnable
                                                public final /* synthetic */ void run() {
                                                    int i1622 = i17;
                                                    boolean z16 = z10;
                                                    long j13 = jElapsedRealtime5;
                                                    c60 c60Var = this.f8500b;
                                                    switch (i1622) {
                                                        case 0:
                                                            c60Var.f9746a.v(j13, z16);
                                                            break;
                                                        case 1:
                                                            c60Var.f9746a.v(j13, z16);
                                                            break;
                                                        default:
                                                            c60Var.f9746a.v(j13, z16);
                                                            break;
                                                    }
                                                }
                                            });
                                            StringBuilder sb4 = new StringBuilder(String.valueOf(jElapsedRealtime5).length() + 24);
                                            sb4.append("Cache connection took ");
                                            sb4.append(jElapsedRealtime5);
                                            sb4.append("ms");
                                            p7.l0.g(sb4.toString());
                                            throw th;
                                        }
                                    } catch (InterruptedException e13) {
                                        e = e13;
                                        z12 = true;
                                        inputStream2 = null;
                                        if (((Boolean) n7.y.f31093e.f31096c.b(ao.f8851f5)).booleanValue()) {
                                        }
                                        alVarA.cancel(true);
                                        Thread.currentThread().interrupt();
                                        m7.n.C.f30472k.getClass();
                                        final long jElapsedRealtime22 = SystemClock.elapsedRealtime() - jElapsedRealtime;
                                        final int i152 = 1;
                                        inputStream3 = inputStream2;
                                        p7.r0.f31763l.post(new Runnable(this) { // from class: com.google.android.gms.internal.ads.a60

                                            /* JADX INFO: renamed from: b, reason: collision with root package name */
                                            public final /* synthetic */ c60 f8500b;

                                            {
                                                this.f8500b = this;
                                            }

                                            @Override // java.lang.Runnable
                                            public final /* synthetic */ void run() {
                                                int i1622 = i152;
                                                boolean z16 = z12;
                                                long j13 = jElapsedRealtime22;
                                                c60 c60Var = this.f8500b;
                                                switch (i1622) {
                                                    case 0:
                                                        c60Var.f9746a.v(j13, z16);
                                                        break;
                                                    case 1:
                                                        c60Var.f9746a.v(j13, z16);
                                                        break;
                                                    default:
                                                        c60Var.f9746a.v(j13, z16);
                                                        break;
                                                }
                                            }
                                        });
                                        StringBuilder sb5 = new StringBuilder(String.valueOf(jElapsedRealtime22).length() + 24);
                                        sb5.append("Cache connection took ");
                                        sb5.append(jElapsedRealtime22);
                                        sb5.append("ms");
                                        string = sb5.toString();
                                        p7.l0.g(string);
                                        it1Var = inputStream3;
                                        if (it1Var != null) {
                                        }
                                        return !q7.g.b() ? null : null;
                                    } catch (ExecutionException e14) {
                                        e = e14;
                                        z11 = true;
                                        inputStream = null;
                                        if (((Boolean) n7.y.f31093e.f31096c.b(ao.f8851f5)).booleanValue()) {
                                        }
                                        alVarA.cancel(true);
                                        m7.n.C.f30472k.getClass();
                                        final long jElapsedRealtime322 = SystemClock.elapsedRealtime() - jElapsedRealtime;
                                        final int i1622 = 0;
                                        inputStream3 = inputStream;
                                        p7.r0.f31763l.post(new Runnable(this) { // from class: com.google.android.gms.internal.ads.a60

                                            /* JADX INFO: renamed from: b, reason: collision with root package name */
                                            public final /* synthetic */ c60 f8500b;

                                            {
                                                this.f8500b = this;
                                            }

                                            @Override // java.lang.Runnable
                                            public final /* synthetic */ void run() {
                                                int i16222 = i1622;
                                                boolean z16 = z11;
                                                long j13 = jElapsedRealtime322;
                                                c60 c60Var = this.f8500b;
                                                switch (i16222) {
                                                    case 0:
                                                        c60Var.f9746a.v(j13, z16);
                                                        break;
                                                    case 1:
                                                        c60Var.f9746a.v(j13, z16);
                                                        break;
                                                    default:
                                                        c60Var.f9746a.v(j13, z16);
                                                        break;
                                                }
                                            }
                                        });
                                        StringBuilder sb222 = new StringBuilder(String.valueOf(jElapsedRealtime322).length() + 24);
                                        sb222.append("Cache connection took ");
                                        sb222.append(jElapsedRealtime322);
                                        sb222.append("ms");
                                        string = sb222.toString();
                                        p7.l0.g(string);
                                        it1Var = inputStream3;
                                        if (it1Var != null) {
                                        }
                                        if (!q7.g.b()) {
                                        }
                                    } catch (TimeoutException e15) {
                                        e = e15;
                                        z11 = true;
                                        inputStream = null;
                                        if (((Boolean) n7.y.f31093e.f31096c.b(ao.f8851f5)).booleanValue()) {
                                        }
                                        alVarA.cancel(true);
                                        m7.n.C.f30472k.getClass();
                                        final long jElapsedRealtime3222 = SystemClock.elapsedRealtime() - jElapsedRealtime;
                                        final int i16222 = 0;
                                        inputStream3 = inputStream;
                                        p7.r0.f31763l.post(new Runnable(this) { // from class: com.google.android.gms.internal.ads.a60

                                            /* JADX INFO: renamed from: b, reason: collision with root package name */
                                            public final /* synthetic */ c60 f8500b;

                                            {
                                                this.f8500b = this;
                                            }

                                            @Override // java.lang.Runnable
                                            public final /* synthetic */ void run() {
                                                int i162222 = i16222;
                                                boolean z16 = z11;
                                                long j13 = jElapsedRealtime3222;
                                                c60 c60Var = this.f8500b;
                                                switch (i162222) {
                                                    case 0:
                                                        c60Var.f9746a.v(j13, z16);
                                                        break;
                                                    case 1:
                                                        c60Var.f9746a.v(j13, z16);
                                                        break;
                                                    default:
                                                        c60Var.f9746a.v(j13, z16);
                                                        break;
                                                }
                                            }
                                        });
                                        StringBuilder sb2222 = new StringBuilder(String.valueOf(jElapsedRealtime3222).length() + 24);
                                        sb2222.append("Cache connection took ");
                                        sb2222.append(jElapsedRealtime3222);
                                        sb2222.append("ms");
                                        string = sb2222.toString();
                                        p7.l0.g(string);
                                        it1Var = inputStream3;
                                        if (it1Var != null) {
                                        }
                                        if (!q7.g.b()) {
                                        }
                                    }
                                } catch (InterruptedException e16) {
                                    e = e16;
                                    z12 = false;
                                } catch (ExecutionException e17) {
                                    e = e17;
                                    z11 = false;
                                    inputStream = null;
                                    if (((Boolean) n7.y.f31093e.f31096c.b(ao.f8851f5)).booleanValue()) {
                                    }
                                    alVarA.cancel(true);
                                    m7.n.C.f30472k.getClass();
                                    final long jElapsedRealtime32222 = SystemClock.elapsedRealtime() - jElapsedRealtime;
                                    final int i162222 = 0;
                                    inputStream3 = inputStream;
                                    p7.r0.f31763l.post(new Runnable(this) { // from class: com.google.android.gms.internal.ads.a60

                                        /* JADX INFO: renamed from: b, reason: collision with root package name */
                                        public final /* synthetic */ c60 f8500b;

                                        {
                                            this.f8500b = this;
                                        }

                                        @Override // java.lang.Runnable
                                        public final /* synthetic */ void run() {
                                            int i1622222 = i162222;
                                            boolean z16 = z11;
                                            long j13 = jElapsedRealtime32222;
                                            c60 c60Var = this.f8500b;
                                            switch (i1622222) {
                                                case 0:
                                                    c60Var.f9746a.v(j13, z16);
                                                    break;
                                                case 1:
                                                    c60Var.f9746a.v(j13, z16);
                                                    break;
                                                default:
                                                    c60Var.f9746a.v(j13, z16);
                                                    break;
                                            }
                                        }
                                    });
                                    StringBuilder sb22222 = new StringBuilder(String.valueOf(jElapsedRealtime32222).length() + 24);
                                    sb22222.append("Cache connection took ");
                                    sb22222.append(jElapsedRealtime32222);
                                    sb22222.append("ms");
                                    string = sb22222.toString();
                                    p7.l0.g(string);
                                    it1Var = inputStream3;
                                    if (it1Var != null) {
                                    }
                                    if (!q7.g.b()) {
                                    }
                                } catch (TimeoutException e18) {
                                    e = e18;
                                    z11 = false;
                                    inputStream = null;
                                    if (((Boolean) n7.y.f31093e.f31096c.b(ao.f8851f5)).booleanValue()) {
                                    }
                                    alVarA.cancel(true);
                                    m7.n.C.f30472k.getClass();
                                    final long jElapsedRealtime322222 = SystemClock.elapsedRealtime() - jElapsedRealtime;
                                    final int i1622222 = 0;
                                    inputStream3 = inputStream;
                                    p7.r0.f31763l.post(new Runnable(this) { // from class: com.google.android.gms.internal.ads.a60

                                        /* JADX INFO: renamed from: b, reason: collision with root package name */
                                        public final /* synthetic */ c60 f8500b;

                                        {
                                            this.f8500b = this;
                                        }

                                        @Override // java.lang.Runnable
                                        public final /* synthetic */ void run() {
                                            int i16222222 = i1622222;
                                            boolean z16 = z11;
                                            long j13 = jElapsedRealtime322222;
                                            c60 c60Var = this.f8500b;
                                            switch (i16222222) {
                                                case 0:
                                                    c60Var.f9746a.v(j13, z16);
                                                    break;
                                                case 1:
                                                    c60Var.f9746a.v(j13, z16);
                                                    break;
                                                default:
                                                    c60Var.f9746a.v(j13, z16);
                                                    break;
                                            }
                                        }
                                    });
                                    StringBuilder sb222222 = new StringBuilder(String.valueOf(jElapsedRealtime322222).length() + 24);
                                    sb222222.append("Cache connection took ");
                                    sb222222.append(jElapsedRealtime322222);
                                    sb222222.append("ms");
                                    string = sb222222.toString();
                                    p7.l0.g(string);
                                    it1Var = inputStream3;
                                    if (it1Var != null) {
                                    }
                                    if (!q7.g.b()) {
                                    }
                                } catch (Throwable th2) {
                                    th = th2;
                                    z10 = 0;
                                }
                            } catch (Throwable th3) {
                                th = th3;
                                z10 = x50Var;
                            }
                        } catch (Exception | NoClassDefFoundError e19) {
                            e = e19;
                            m7.n.C.f30469h.d("AdWebViewClient.interceptRequest", e);
                            return zzae();
                        }
                    }
                    if (it1Var != null) {
                        return new WebResourceResponse("", "", 200, "OK", map3, it1Var);
                    }
                }
                i10 = -1;
                tnVar = ao.f8767a5;
                yVar = n7.y.f31093e;
                if (((Boolean) yVar.f31096c.b(tnVar)).booleanValue()) {
                }
                if (it1Var != null) {
                }
            }
            if (!q7.g.b() && ((Boolean) lp.f13824b.j()).booleanValue()) {
                return zzaf(str, map);
            }
        } catch (Exception e20) {
            e = e20;
            m7.n.C.f30469h.d("AdWebViewClient.interceptRequest", e);
            return zzae();
        } catch (NoClassDefFoundError e21) {
            e = e21;
            m7.n.C.f30469h.d("AdWebViewClient.interceptRequest", e);
            return zzae();
        }
    }

    @Override // com.google.android.gms.internal.ads.y60
    public final void zzab(@Nullable n7.a aVar, @Nullable js jsVar, @Nullable com.google.android.gms.ads.internal.overlay.p pVar, @Nullable ks ksVar, @Nullable com.google.android.gms.ads.internal.overlay.d dVar, boolean z10, @Nullable at atVar, @Nullable m7.b bVar, @Nullable zx zxVar, @Nullable p10 p10Var, @Nullable dw0 dw0Var, @Nullable re1 re1Var, @Nullable cr0 cr0Var, @Nullable mt mtVar, @Nullable fk0 fk0Var, @Nullable lt ltVar, @Nullable gt gtVar, @Nullable zs zsVar, @Nullable y90 y90Var, @Nullable pr0 pr0Var, @Nullable xd0 xd0Var, @Nullable td0 td0Var) {
        x50 x50Var = this.f9746a;
        m7.b bVar2 = bVar == null ? new m7.b(x50Var.getContext(), p10Var, null) : bVar;
        this.Y = new ux(x50Var, zxVar);
        this.zzb = p10Var;
        tn tnVar = ao.f9029q1;
        n7.y yVar = n7.y.f31093e;
        int i10 = 1;
        if (((Boolean) yVar.f31096c.b(tnVar)).booleanValue()) {
            d("/adMetadata", new m40(jsVar, i10));
        }
        int i11 = 2;
        if (ksVar != null) {
            d("/appEvent", new m40(ksVar, i11));
        }
        d("/backButton", xs.f18539e);
        d("/refresh", xs.f18540f);
        d("/canOpenApp", ps.f15501a);
        d("/canOpenURLs", ws.f18207a);
        d("/canOpenIntents", qs.f15853a);
        d("/close", xs.f18535a);
        d("/customClose", xs.f18536b);
        d("/instrument", xs.f18543i);
        d("/delayPageLoaded", xs.f18545k);
        d("/delayPageClosed", xs.f18546l);
        d("/getLocationInfo", xs.f18547m);
        d("/log", xs.f18537c);
        d("/mraid", new bt(bVar2, this.Y, zxVar));
        yx yxVar = this.zzx;
        if (yxVar != null) {
            d("/mraidLoaded", yxVar);
        }
        m7.b bVar3 = bVar2;
        d("/open", new ft(bVar2, this.Y, dw0Var, cr0Var, y90Var, xd0Var));
        d("/precache", new x40());
        d("/touch", us.f17376a);
        d("/video", xs.f18541g);
        d("/videoMeta", xs.f18542h);
        if (dw0Var == null || re1Var == null) {
            d("/click", new gn0(fk0Var, y90Var, 1));
            d("/httpTrack", ts.f16999a);
        } else {
            d("/click", new tl0(y90Var, fk0Var, dw0Var, re1Var));
            d("/httpTrack", new gn0(re1Var, dw0Var, 6));
        }
        if (m7.n.C.f30486y.a(x50Var.getContext())) {
            HashMap map = new HashMap();
            if (x50Var.zzC() != null) {
                map = x50Var.zzC().f18004q0;
            }
            d("/logScionEvent", new gn0(x50Var.getContext(), map, 2));
        }
        if (atVar != null) {
            d("/setInterstitialProperties", new m40(atVar, 3));
        }
        yn ynVar = yVar.f31096c;
        if (mtVar != null && ((Boolean) ynVar.b(ao.f8856fa)).booleanValue()) {
            d("/inspectorNetworkExtras", mtVar);
        }
        if (((Boolean) ynVar.b(ao.f9171ya)).booleanValue() && ltVar != null) {
            d("/shareSheet", ltVar);
        }
        if (((Boolean) ynVar.b(ao.G8)).booleanValue() && pr0Var != null) {
            d("/onDeviceStorageEvent", new m40(pr0Var, 4));
        }
        if (((Boolean) ynVar.b(ao.Da)).booleanValue() && gtVar != null) {
            d("/inspectorOutOfContextTest", gtVar);
        }
        if (((Boolean) ynVar.b(ao.Ia)).booleanValue() && zsVar != null) {
            d("/inspectorStorage", zsVar);
        }
        if (((Boolean) ynVar.b(ao.Kc)).booleanValue()) {
            d("/bindPlayStoreOverlay", xs.f18550p);
            d("/presentPlayStoreOverlay", xs.f18551q);
            d("/expandPlayStoreOverlay", xs.f18552r);
            d("/collapsePlayStoreOverlay", xs.f18553s);
            d("/closePlayStoreOverlay", xs.f18554t);
        }
        if (((Boolean) ynVar.b(ao.V3)).booleanValue()) {
            d("/setPAIDPersonalizationEnabled", xs.f18556v);
            d("/resetPAID", xs.f18555u);
        }
        if (((Boolean) ynVar.b(ao.f8842ed)).booleanValue() && x50Var.zzC() != null && x50Var.zzC().f17994l0) {
            d("/writeToLocalStorage", xs.f18557w);
            d("/clearLocalStorageKeys", xs.f18558x);
        }
        this.f9752d = aVar;
        this.f9754e = pVar;
        this.f9758h = jsVar;
        this.f9759i = ksVar;
        this.W = dVar;
        this.X = bVar3;
        this.f9760j = fk0Var;
        this.zzA = cr0Var;
        this.zzB = td0Var;
        this.f9761k = z10;
    }

    @Override // com.google.android.gms.internal.ads.y60
    public final void zzd(y90 y90Var, @Nullable dw0 dw0Var, @Nullable re1 re1Var) {
        e("/click");
        if (dw0Var != null && re1Var != null) {
            d("/click", new tl0(y90Var, this.f9760j, dw0Var, re1Var));
            return;
        }
        fk0 fk0Var = this.f9760j;
        ns nsVar = xs.f18535a;
        d("/click", new gn0(fk0Var, y90Var, 1));
    }

    @Override // com.google.android.gms.internal.ads.y60
    public final void zze(y90 y90Var, @Nullable dw0 dw0Var, @Nullable cr0 cr0Var) {
        e("/open");
        d("/open", new ft(this.X, this.Y, dw0Var, cr0Var, y90Var, null));
    }

    @Override // com.google.android.gms.internal.ads.y60
    public final void zzi(@Nullable m7.b bVar) {
        this.X = bVar;
    }

    @Override // com.google.android.gms.internal.ads.y60
    public final void zzj(p10 p10Var) {
        this.zzb = p10Var;
    }
}
