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

import android.net.Uri;
import android.view.View;
import android.webkit.WebView;
import androidx.annotation.Nullable;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;

/* JADX INFO: loaded from: classes2.dex */
public final class wf1 {

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

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

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

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

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

    public wf1(xf1 xf1Var, WebView webView) {
        HashMap map = new HashMap();
        this.f18038d = map;
        this.f18039e = new gg1();
        ni.p();
        this.f18035a = xf1Var;
        this.f18036b = webView;
        if (zzc() != webView) {
            Iterator it = map.values().iterator();
            while (it.hasNext()) {
                ((sf1) it.next()).zzb(webView);
            }
            this.f18037c = new yg1(webView);
        }
        if (!z3.c0.a("WEB_MESSAGE_LISTENER")) {
            throw new UnsupportedOperationException("The JavaScriptSessionService cannot be supported in this WebView version.");
        }
        Uri uri = z3.b0.f37032a;
        if (!a4.k0.L.b()) {
            throw a4.k0.a();
        }
        z3.b0.e(this.f18036b).f346a.removeWebMessageListener("omidJsSessionService");
        z3.b0.b(this.f18036b, "omidJsSessionService", new HashSet(Arrays.asList("*")), new jc1(this));
    }

    /* JADX WARN: Multi-variable type inference failed */
    public final void a(String str) {
        zzfso zzfsoVar = zzfso.DEFINED_BY_JAVASCRIPT;
        zzfsr zzfsrVar = zzfsr.DEFINED_BY_JAVASCRIPT;
        zzfsw zzfswVar = zzfsw.JAVASCRIPT;
        uf1 uf1Var = new uf1(n5.r.d(zzfsoVar, zzfsrVar, zzfswVar, zzfswVar, false), tf1.zza(this.f18035a, this.f18036b, null, null), str);
        this.f18038d.put(str, uf1Var);
        uf1Var.zzb(zzc());
        for (fg1 fg1Var : this.f18039e.f11742a) {
            uf1Var.zzd((View) fg1Var.f11212a.get(), fg1Var.f11214c, fg1Var.f11215d);
        }
        uf1Var.a();
    }

    /* JADX WARN: Multi-variable type inference failed */
    @Nullable
    public final View zzc() {
        yg1 yg1Var = this.f18037c;
        if (yg1Var == null) {
            return null;
        }
        return (View) yg1Var.get();
    }

    public final void zzd(View view, zzfsq zzfsqVar, @Nullable String str) {
        Iterator it = this.f18038d.values().iterator();
        while (it.hasNext()) {
            ((sf1) it.next()).zzd(view, zzfsqVar, "Ad overlay");
        }
        this.f18039e.zzb(view, zzfsqVar, "Ad overlay");
    }
}
