package com.bytedance.sdk.component.fm;

import android.webkit.WebView;
import com.bytedance.sdk.component.fm.lb;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Set;

/* JADX INFO: loaded from: classes.dex */
public class fhx {
    private final fm fm;
    private volatile boolean jnr;

    /* JADX INFO: renamed from: lb, reason: collision with root package name */
    private final ef f6619lb;
    private final WebView ro;
    private final List<duv> yz;

    public fhx(ef efVar) {
        ArrayList arrayList = new ArrayList();
        this.yz = arrayList;
        this.jnr = false;
        this.f6619lb = efVar;
        if (efVar.fm != null) {
            fm fmVar = efVar.ro;
            if (fmVar == null) {
                this.fm = new wey();
            } else {
                this.fm = fmVar;
            }
        } else {
            this.fm = efVar.ro;
        }
        this.fm.lb(efVar);
        this.ro = efVar.fm;
        arrayList.add(efVar.f6617ef);
        gqi.fm(efVar.wsy);
    }

    public static ef fm(WebView webView) {
        return new ef(webView);
    }

    private void ro() {
        if (this.jnr) {
            wu.fm(new IllegalStateException("JsBridge2 is already released!!!"));
        }
    }

    public fhx fm(String str, yz<?, ?> yzVar) {
        return fm(str, (String) null, yzVar);
    }

    public fhx fm(Set<String> set, gof<?, ?> gofVar) {
        return fm(set, (String) null, gofVar);
    }

    public fhx fm(String str, String str2, yz<?, ?> yzVar) {
        ro();
        this.fm.wsy.fm(str, yzVar);
        return this;
    }

    public fhx fm(Set<String> set, String str, gof<?, ?> gofVar) {
        ro();
        this.fm.wsy.fm(set, gofVar);
        return this;
    }

    public fhx fm(String str, lb.ro roVar) {
        return fm(str, (String) null, roVar);
    }

    public fhx fm(String str, String str2, lb.ro roVar) {
        ro();
        this.fm.wsy.fm(str, roVar);
        return this;
    }

    public void fm() {
        if (this.jnr) {
            return;
        }
        this.fm.ro();
        this.jnr = true;
        Iterator<duv> it = this.yz.iterator();
        while (it.hasNext()) {
            it.next();
        }
    }
}
