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

import android.content.Context;
import android.os.Bundle;
import android.os.Parcel;
import android.os.RemoteException;
import android.view.MotionEvent;
import android.view.View;
import android.widget.ImageView;
import androidx.annotation.Nullable;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

/* JADX INFO: loaded from: classes2.dex */
public final class rn0 implements sm0, qi0 {

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

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

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

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

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

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public final wa1 f16175f;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public final q7.a f16176g;

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

    /* JADX INFO: renamed from: i, reason: collision with root package name */
    public boolean f16178i = false;

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    public boolean f16179j = false;

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

    @Nullable
    private final kw zza;

    @Nullable
    private final gw zzm;

    @Nullable
    private final hw zzn;

    public rn0(@Nullable gw gwVar, @Nullable hw hwVar, @Nullable kw kwVar, gf0 gf0Var, ug0 ug0Var, te0 te0Var, ek0 ek0Var, Context context, wa1 wa1Var, q7.a aVar, ib1 ib1Var) {
        this.zzm = gwVar;
        this.zzn = hwVar;
        this.zza = kwVar;
        this.f16170a = gf0Var;
        this.f16171b = ug0Var;
        this.f16172c = te0Var;
        this.f16173d = ek0Var;
        this.f16174e = context;
        this.f16175f = wa1Var;
        this.f16176g = aVar;
        this.f16177h = ib1Var;
    }

    public static final HashMap l(Map map) {
        HashMap map2 = new HashMap();
        if (map != null) {
            synchronized (map) {
                try {
                    for (Map.Entry entry : map.entrySet()) {
                        View view = (View) ((WeakReference) entry.getValue()).get();
                        if (view != null) {
                            map2.put((String) entry.getKey(), view);
                        }
                    }
                } catch (Throwable th) {
                    throw th;
                }
            }
        }
        return map2;
    }

    @Override // com.google.android.gms.internal.ads.sm0
    public final void D() {
        q7.j.d("Mute This Ad is not supported for 3rd party ads");
    }

    @Override // com.google.android.gms.internal.ads.sm0
    public final void a(View view) {
    }

    @Override // com.google.android.gms.internal.ads.sm0
    public final void b(as asVar) {
    }

    @Override // com.google.android.gms.internal.ads.sm0
    public final int c() {
        return 0;
    }

    @Override // com.google.android.gms.internal.ads.sm0
    public final boolean d() {
        return true;
    }

    @Override // com.google.android.gms.internal.ads.qi0
    public final void e() {
        try {
            kw kwVar = this.zza;
            if (kwVar == null || !kwVar.zzt()) {
                return;
            }
            wa1 wa1Var = this.f16175f;
            if (wa1Var.f17979e == 4 || wa1Var.f18014v0) {
                kwVar.d();
                this.f16170a.zza();
            }
        } catch (RemoteException unused) {
        }
    }

    @Override // com.google.android.gms.internal.ads.sm0
    public final void f(n7.v1 v1Var) {
        q7.j.d("Mute This Ad is not supported for 3rd party ads");
    }

    @Override // com.google.android.gms.internal.ads.sm0
    public final void g() {
    }

    @Override // com.google.android.gms.internal.ads.sm0
    public final boolean h(Bundle bundle) {
        return false;
    }

    @Override // com.google.android.gms.internal.ads.sm0
    public final void i() {
        try {
            kw kwVar = this.zza;
            if (kwVar != null) {
                kwVar.zzC();
            }
        } catch (RemoteException unused) {
        }
    }

    @Override // com.google.android.gms.internal.ads.sm0
    public final void j() {
    }

    @Override // com.google.android.gms.internal.ads.qi0
    public final void k() {
    }

    @Override // com.google.android.gms.internal.ads.sm0
    public final void m() {
    }

    @Override // com.google.android.gms.internal.ads.sm0
    public final void n(String str) {
    }

    public final void o(View view) {
        try {
            kw kwVar = this.zza;
            ek0 ek0Var = this.f16173d;
            te0 te0Var = this.f16172c;
            if (kwVar != null && !kwVar.c()) {
                kwVar.J(new k8.b(view));
                te0Var.onAdClicked();
                if (((Boolean) n7.y.f31093e.f31096c.b(ao.Xb)).booleanValue()) {
                    ek0Var.w();
                    return;
                }
                return;
            }
            gw gwVar = this.zzm;
            if (gwVar != null) {
                Parcel parcelB0 = gwVar.B0(14, gwVar.O());
                ClassLoader classLoader = aj.f8714a;
                boolean z10 = parcelB0.readInt() != 0;
                parcelB0.recycle();
                if (!z10) {
                    k8.b bVar = new k8.b(view);
                    Parcel parcelO = gwVar.O();
                    aj.d(parcelO, bVar);
                    gwVar.O0(11, parcelO);
                    te0Var.onAdClicked();
                    if (((Boolean) n7.y.f31093e.f31096c.b(ao.Xb)).booleanValue()) {
                        ek0Var.w();
                        return;
                    }
                    return;
                }
            }
            hw hwVar = this.zzn;
            if (hwVar != null) {
                Parcel parcelB02 = hwVar.B0(12, hwVar.O());
                ClassLoader classLoader2 = aj.f8714a;
                boolean z11 = parcelB02.readInt() != 0;
                parcelB02.recycle();
                if (z11) {
                    return;
                }
                k8.b bVar2 = new k8.b(view);
                Parcel parcelO2 = hwVar.O();
                aj.d(parcelO2, bVar2);
                hwVar.O0(9, parcelO2);
                te0Var.onAdClicked();
                if (((Boolean) n7.y.f31093e.f31096c.b(ao.Xb)).booleanValue()) {
                    ek0Var.w();
                }
            }
        } catch (RemoteException unused) {
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:50:0x00ce A[Catch: JSONException -> 0x0045, RemoteException -> 0x0153, TRY_LEAVE, TryCatch #0 {RemoteException -> 0x0153, blocks: (B:2:0x0000, B:4:0x001c, B:8:0x0026, B:11:0x002f, B:13:0x0036, B:14:0x0045, B:16:0x004b, B:18:0x0057, B:21:0x0063, B:24:0x006a, B:26:0x0080, B:28:0x0088, B:43:0x00a7, B:33:0x0092, B:37:0x009b, B:46:0x00ae, B:47:0x00b2, B:48:0x00c8, B:50:0x00ce, B:54:0x00e0, B:56:0x00ee, B:58:0x00fc, B:60:0x0102, B:62:0x0129, B:64:0x012d), top: B:70:0x0000 }] */
    @Override // com.google.android.gms.internal.ads.sm0
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void zza(View view, @Nullable Map map, @Nullable Map map2, View.OnTouchListener onTouchListener, View.OnClickListener onClickListener) {
        Object obj;
        Iterator it;
        k8.a aVarZzq;
        try {
            k8.b bVar = new k8.b(view);
            JSONObject jSONObject = this.f16175f.f17980e0;
            boolean z10 = true;
            if (((Boolean) n7.y.f31093e.f31096c.b(ao.U1)).booleanValue() && jSONObject.length() != 0) {
                Map map3 = map == null ? new HashMap() : map;
                Map map4 = map2 == null ? new HashMap() : map2;
                HashMap map5 = new HashMap();
                map5.putAll(map3);
                map5.putAll(map4);
                Iterator<String> itKeys = jSONObject.keys();
                loop0: while (itKeys.hasNext()) {
                    String next = itKeys.next();
                    JSONArray jSONArrayOptJSONArray = jSONObject.optJSONArray(next);
                    if (jSONArrayOptJSONArray != null) {
                        WeakReference weakReference = (WeakReference) map5.get(next);
                        if (weakReference != null && (obj = weakReference.get()) != null) {
                            Class<?> cls = obj.getClass();
                            if (((Boolean) n7.y.f31093e.f31096c.b(ao.V1)).booleanValue() && next.equals("3010")) {
                                kw kwVar = this.zza;
                                Object objO = null;
                                if (kwVar != null) {
                                    try {
                                        aVarZzq = kwVar.zzq();
                                    } catch (RemoteException | IllegalArgumentException unused) {
                                    }
                                } else {
                                    gw gwVar = this.zzm;
                                    if (gwVar != null) {
                                        aVarZzq = gwVar.w1();
                                    } else {
                                        hw hwVar = this.zzn;
                                        aVarZzq = hwVar != null ? hwVar.c() : null;
                                    }
                                }
                                if (aVarZzq != null) {
                                    objO = k8.b.O(aVarZzq);
                                }
                                if (objO != null) {
                                    cls = objO.getClass();
                                    ArrayList arrayList = new ArrayList();
                                    p7.y.zza(jSONArrayOptJSONArray, arrayList);
                                    p7.r0 r0Var = m7.n.C.f30464c;
                                    ClassLoader classLoader = this.f16174e.getClassLoader();
                                    it = arrayList.iterator();
                                    while (it.hasNext()) {
                                    }
                                }
                            } else {
                                try {
                                    ArrayList arrayList2 = new ArrayList();
                                    p7.y.zza(jSONArrayOptJSONArray, arrayList2);
                                    p7.r0 r0Var2 = m7.n.C.f30464c;
                                    ClassLoader classLoader2 = this.f16174e.getClassLoader();
                                    it = arrayList2.iterator();
                                    while (it.hasNext()) {
                                        if (Class.forName((String) it.next(), false, classLoader2).isAssignableFrom(cls)) {
                                            break;
                                        }
                                    }
                                } catch (JSONException unused2) {
                                    continue;
                                }
                            }
                        }
                        z10 = false;
                        break;
                    }
                }
            }
            this.f16180k = z10;
            HashMap mapL = l(map);
            HashMap mapL2 = l(map2);
            kw kwVar2 = this.zza;
            if (kwVar2 != null) {
                kwVar2.t1(bVar, new k8.b(mapL), new k8.b(mapL2));
                return;
            }
            gw gwVar2 = this.zzm;
            if (gwVar2 != null) {
                k8.b bVar2 = new k8.b(mapL);
                k8.b bVar3 = new k8.b(mapL2);
                Parcel parcelO = gwVar2.O();
                aj.d(parcelO, bVar);
                aj.d(parcelO, bVar2);
                aj.d(parcelO, bVar3);
                gwVar2.O0(22, parcelO);
                Parcel parcelO2 = gwVar2.O();
                aj.d(parcelO2, bVar);
                gwVar2.O0(12, parcelO2);
                return;
            }
            hw hwVar2 = this.zzn;
            if (hwVar2 != null) {
                k8.b bVar4 = new k8.b(mapL);
                k8.b bVar5 = new k8.b(mapL2);
                Parcel parcelO3 = hwVar2.O();
                aj.d(parcelO3, bVar);
                aj.d(parcelO3, bVar4);
                aj.d(parcelO3, bVar5);
                hwVar2.O0(22, parcelO3);
                Parcel parcelO4 = hwVar2.O();
                aj.d(parcelO4, bVar);
                hwVar2.O0(10, parcelO4);
            }
        } catch (RemoteException unused3) {
        }
    }

    @Override // com.google.android.gms.internal.ads.sm0
    public final void zzb(View view, @Nullable Map map) {
        try {
            k8.b bVar = new k8.b(view);
            kw kwVar = this.zza;
            if (kwVar != null) {
                kwVar.a2(bVar);
                return;
            }
            gw gwVar = this.zzm;
            if (gwVar != null) {
                Parcel parcelO = gwVar.O();
                aj.d(parcelO, bVar);
                gwVar.O0(16, parcelO);
            } else {
                hw hwVar = this.zzn;
                if (hwVar != null) {
                    Parcel parcelO2 = hwVar.O();
                    aj.d(parcelO2, bVar);
                    hwVar.O0(14, parcelO2);
                }
            }
        } catch (RemoteException unused) {
        }
    }

    @Override // com.google.android.gms.internal.ads.sm0
    public final void zzc(View view, @Nullable View view2, @Nullable Map map, @Nullable Map map2, boolean z10, @Nullable ImageView.ScaleType scaleType) {
        if (this.f16179j && this.f16175f.I) {
            return;
        }
        o(view);
    }

    @Override // com.google.android.gms.internal.ads.sm0
    public final void zze(Bundle bundle) {
    }

    @Override // com.google.android.gms.internal.ads.sm0
    public final void zzf(View view, View view2, Map map, Map map2, boolean z10, @Nullable ImageView.ScaleType scaleType, int i10) {
        if (!this.f16179j) {
            q7.j.d("Custom click reporting for 3p ads failed. enableCustomClickGesture is not set.");
        } else if (this.f16175f.I) {
            o(view2);
        } else {
            q7.j.d("Custom click reporting for 3p ads failed. Ad unit id not in allow list.");
        }
    }

    @Override // com.google.android.gms.internal.ads.sm0
    public final void zzg() {
        this.f16179j = true;
    }

    @Override // com.google.android.gms.internal.ads.sm0
    public final boolean zzh() {
        return this.f16175f.I;
    }

    @Override // com.google.android.gms.internal.ads.sm0
    public final void zzj(View view, MotionEvent motionEvent, @Nullable View view2) {
    }

    @Override // com.google.android.gms.internal.ads.sm0
    public final void zzk(Bundle bundle) {
    }

    @Override // com.google.android.gms.internal.ads.sm0
    @Nullable
    public final JSONObject zzl(View view, Map map, Map map2, @Nullable ImageView.ScaleType scaleType) {
        return null;
    }

    @Override // com.google.android.gms.internal.ads.sm0
    @Nullable
    public final JSONObject zzm(View view, Map map, Map map2, @Nullable ImageView.ScaleType scaleType) {
        return null;
    }

    @Override // com.google.android.gms.internal.ads.sm0
    public final void zzr(@Nullable n7.x1 x1Var) {
        q7.j.d("Mute This Ad is not supported for 3rd party ads");
    }

    @Override // com.google.android.gms.internal.ads.sm0
    public final void zzw(@Nullable View view, @Nullable Map map, @Nullable Map map2, @Nullable ImageView.ScaleType scaleType) {
        try {
            boolean z10 = this.f16178i;
            wa1 wa1Var = this.f16175f;
            if (!z10) {
                this.f16178i = m7.n.C.f30476o.d(this.f16174e, this.f16176g.f32212a, wa1Var.f18021z.toString(), this.f16177h.f12455d);
            }
            if (this.f16180k) {
                kw kwVar = this.zza;
                gf0 gf0Var = this.f16170a;
                if (kwVar != null) {
                    if (wa1Var.f18014v0) {
                        if (kwVar.zzt()) {
                            return;
                        }
                        kwVar.d();
                        gf0Var.zza();
                        return;
                    }
                    if (kwVar.zzt() && wa1Var.f17979e == 4) {
                        this.f16171b.zza();
                        return;
                    } else {
                        kwVar.d();
                        gf0Var.zza();
                        return;
                    }
                }
                gw gwVar = this.zzm;
                if (gwVar != null) {
                    Parcel parcelB0 = gwVar.B0(13, gwVar.O());
                    ClassLoader classLoader = aj.f8714a;
                    boolean z11 = parcelB0.readInt() != 0;
                    parcelB0.recycle();
                    if (!z11) {
                        gwVar.O0(10, gwVar.O());
                        gf0Var.zza();
                        return;
                    }
                }
                hw hwVar = this.zzn;
                if (hwVar != null) {
                    Parcel parcelB02 = hwVar.B0(11, hwVar.O());
                    ClassLoader classLoader2 = aj.f8714a;
                    boolean z12 = parcelB02.readInt() != 0;
                    parcelB02.recycle();
                    if (z12) {
                        return;
                    }
                    hwVar.O0(8, hwVar.O());
                    gf0Var.zza();
                }
            }
        } catch (RemoteException unused) {
        }
    }

    @Override // com.google.android.gms.internal.ads.sm0
    public final void zzx(@Nullable View view, @Nullable Map map, @Nullable Map map2, @Nullable ImageView.ScaleType scaleType) {
    }
}
