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

import android.app.Activity;
import android.content.Context;
import android.view.InputEvent;
import android.view.View;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

/* JADX INFO: loaded from: classes2.dex */
public final class do1 implements wn1 {

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

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final uo1 f10460b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final ExecutorService f10461c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final zo1 f10462d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public final jp1 f10463e;

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

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public final String f10465g;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public final long f10466h;

    /* JADX INFO: renamed from: i, reason: collision with root package name */
    public final long f10467i;

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

    public do1(wo1 wo1Var, uo1 uo1Var, zo1 zo1Var, jp1 jp1Var, bk1 bk1Var, ExecutorService executorService) {
        this.f10459a = wo1Var;
        this.f10460b = uo1Var;
        this.f10461c = executorService;
        this.f10462d = zo1Var;
        this.f10463e = jp1Var;
        this.f10465g = bk1Var.H();
        this.f10466h = bk1Var.P();
        this.f10467i = bk1Var.O();
    }

    @Override // com.google.android.gms.internal.ads.wn1
    public final ov1 a(Context context, View view, Activity activity) {
        return ih1.A0(new bo0((wn1) this, context, view, activity, 4), this.f10461c);
    }

    @Override // com.google.android.gms.internal.ads.wn1
    public final void b(InputEvent inputEvent) {
        try {
            synchronized (this.f10464f) {
                try {
                    co1 co1Var = this.f10468j;
                    if (co1Var != null) {
                        HashMap map = new HashMap();
                        map.put("evt", inputEvent);
                        ((kd) co1Var.f10010d).c(co1Var.f10009c, Optional.of(map));
                    } else {
                        this.f10463e.b(20105);
                    }
                } finally {
                }
            }
        } catch (zzatp | zzatt e10) {
            this.f10463e.d(20104, e10);
        }
    }

    @Override // com.google.android.gms.internal.ads.wn1
    public final ov1 c(Context context, String str, View view) {
        return ih1.A0(new bo0((wn1) this, context, str, view, 5), this.f10461c);
    }

    /* JADX WARN: Removed duplicated region for block: B:49:0x008e A[ADDED_TO_REGION] */
    /* JADX WARN: Removed duplicated region for block: B:53:0x00a9  */
    /* JADX WARN: Removed duplicated region for block: B:75:0x00d2  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void d(Map map) {
        String strW0;
        ip1 ip1VarA;
        String str;
        map.put("v", this.f10465g);
        com.google.common.util.concurrent.w wVar = (com.google.common.util.concurrent.w) map.get("gs");
        com.google.common.util.concurrent.w wVar2 = (com.google.common.util.concurrent.w) map.get("ai");
        jp1 jp1Var = this.f10463e;
        byte[] bArrB = null;
        long jY0 = -1;
        if (wVar != null) {
            ip1VarA = jp1Var.a(20107);
            try {
                try {
                    ip1VarA.a();
                    pf pfVar = (pf) wVar.get(this.f10467i, TimeUnit.MILLISECONDS);
                    if (pfVar != null) {
                        bArrB = pfVar.B0().b();
                        strW0 = pfVar.w0().length() > 1 ? pfVar.w0() : "E";
                        try {
                            if (pfVar.x0()) {
                                jY0 = pfVar.y0();
                            }
                        } catch (ClassCastException e10) {
                            e = e10;
                            ip1VarA.b(e);
                        } catch (InterruptedException e11) {
                            e = e11;
                            ip1VarA.b(e);
                        } catch (ExecutionException e12) {
                            e = e12;
                            Throwable cause = e.getCause();
                            if (cause != null) {
                                e = cause;
                            }
                            ip1VarA.b(e);
                        } catch (TimeoutException e13) {
                            e = e13;
                            ip1VarA.b(e);
                        }
                    } else {
                        strW0 = "E";
                    }
                } finally {
                }
            } catch (ClassCastException e14) {
                e = e14;
                strW0 = "E";
                ip1VarA.b(e);
                ip1VarA.c();
                if (strW0.equals("E")) {
                    ip1VarA = jp1Var.a(20108);
                    try {
                        try {
                            ip1VarA.a();
                            str = (String) wVar2.get(this.f10466h, TimeUnit.MILLISECONDS);
                            if (true != ih1.B(str)) {
                            }
                        } catch (ClassCastException e15) {
                            e = e15;
                            ip1VarA.b(e);
                        } catch (InterruptedException e16) {
                            e = e16;
                            ip1VarA.b(e);
                        } catch (ExecutionException e17) {
                            e = e17;
                            Throwable cause2 = e.getCause();
                            if (cause2 != null) {
                                e = cause2;
                            }
                            ip1VarA.b(e);
                        } catch (TimeoutException e18) {
                            e = e18;
                            ip1VarA.b(e);
                        }
                    } finally {
                    }
                }
                map.put("int", strW0);
                if (bArrB != null) {
                }
                map.put("gv", Long.valueOf(jY0));
            } catch (InterruptedException e19) {
                e = e19;
                strW0 = "E";
                ip1VarA.b(e);
                ip1VarA.c();
                if (strW0.equals("E")) {
                }
                map.put("int", strW0);
                if (bArrB != null) {
                }
                map.put("gv", Long.valueOf(jY0));
            } catch (ExecutionException e20) {
                e = e20;
                strW0 = "E";
            } catch (TimeoutException e21) {
                e = e21;
                strW0 = "E";
                ip1VarA.b(e);
                ip1VarA.c();
                if (strW0.equals("E")) {
                }
                map.put("int", strW0);
                if (bArrB != null) {
                }
                map.put("gv", Long.valueOf(jY0));
            }
            ip1VarA.c();
        } else {
            strW0 = "E";
        }
        if (strW0.equals("E") && wVar2 != null) {
            ip1VarA = jp1Var.a(20108);
            ip1VarA.a();
            str = (String) wVar2.get(this.f10466h, TimeUnit.MILLISECONDS);
            if (true != ih1.B(str)) {
                strW0 = str;
            }
        }
        map.put("int", strW0);
        if (bArrB != null) {
            map.put("att", bArrB);
        }
        map.put("gv", Long.valueOf(jY0));
    }

    public final String e(HashMap map) {
        String strG;
        jp1 jp1Var = this.f10463e;
        try {
            jp1Var.a(20110).a();
            synchronized (this.f10464f) {
                try {
                    co1 co1Var = this.f10468j;
                    if (co1Var == null) {
                        jp1Var.b(20109);
                        strG = "";
                    } else {
                        byte[] bArr = (byte[]) ((kd) co1Var.f10010d).c(co1Var.f10008b, Optional.of(map));
                        ft1 ft1Var = gt1.f11872e;
                        if (ft1Var.f11875b != null) {
                            ft1Var = new ft1(ft1Var.f11874a, null);
                        }
                        strG = ft1Var.g(bArr, bArr.length);
                    }
                } finally {
                }
            }
            return strG;
        } finally {
        }
    }

    @Override // com.google.android.gms.internal.ads.wn1
    public final String zza() {
        synchronized (this.f10464f) {
            try {
                co1 co1Var = this.f10468j;
                if (co1Var == null) {
                    return "3.825731049.-1";
                }
                return co1Var.f10007a;
            } catch (Throwable th) {
                throw th;
            }
        }
    }

    @Override // com.google.android.gms.internal.ads.wn1
    public final wu1 zzb() {
        wu1 wu1VarS = wu1.s(this.f10460b.zzb());
        bo1 bo1Var = bo1.f9615a;
        ExecutorService executorService = this.f10461c;
        return ih1.e1(ih1.U0(wu1VarS, Throwable.class, bo1Var, executorService), new wt(this, 15), executorService);
    }

    @Override // com.google.android.gms.internal.ads.wn1
    public final ov1 zzc(Context context) {
        return ih1.A0(new hg(this, context, 12), this.f10461c);
    }

    @Override // com.google.android.gms.internal.ads.wn1
    public final int zzg() {
        return 4;
    }
}
