package com.ss.android.ugc.aweme.crossplatform.business;

import X.0Gf;
import X.0Gp;
import X.2nK;
import X.7he;
import X.9EH;
import X.9c7;
import X.C2162KoL;
import X.C2273Kq8;
import X.C2407KsI;
import X.C2411KsM;
import X.C2412KsN;
import X.C2414KsP;
import X.C2416KsR;
import X.C2419KsU;
import X.C2422KsX;
import X.C2423KsY;
import X.C4329LiC;
import X.Crj;
import X.M12;
import android.os.Handler;
import android.text.TextUtils;
import android.webkit.WebView;
import com.bytedance.covode.number.Covode;
import com.ss.android.common.util.NetworkUtils;
import com.ss.android.ugc.aweme.global.config.settings.pojo.AdLandingPageConfig;
import java.lang.ref.WeakReference;
import java.net.URLDecoder;
import java.util.Map;
import kotlin.h.b.n;
import kotlin.o.y;
import kotlin.o.z;

public final class PassBackWebInfoBusiness extends BusinessService$Business {
    public AdLandingPageConfig LIZ;
    public boolean LIZIZ = true;
    public int LIZJ;
    public int LIZLLL;
    public int LJ = 2000;
    public String LJFF = "https://ads.tiktok.com/inspect/aegis/client/page/";
    public String LJI;
    public final Crj LJII = 7he.LIZ(C2412KsN.LIZ);
    public C2273Kq8 LJIIL;
    public final Crj LJIILIIL = 7he.LIZ(C2419KsU.LIZ);
    public final Crj LJIILJJIL = 7he.LIZ(C2414KsP.LIZ);
    public final Crj LJIILL = 7he.LIZ(C2416KsR.LIZ);

    static {
        Covode.recordClassIndex(62942);
    }

    public final Handler LIZ() {
        return (Handler) this.LJIILIIL.getValue();
    }

    public final Map<String, String> LIZIZ() {
        return (Map) this.LJIILJJIL.getValue();
    }

    public final Map<String, Map<String, String>> LIZJ() {
        return (Map) this.LJIILL.getValue();
    }

    private final void LJ() {
        0Gp.LIZ(new C2407KsI(this), 2nK.LIZ(), (0Gf) null);
    }

    public final boolean LIZLLL() {
        C2273Kq8 kq8;
        String str;
        if (this.LIZ == null || (kq8 = this.LJIIL) == null || !kq8.LJJIJ) {
            return false;
        }
        if (this.LIZIZ && NetworkUtils.getNetworkType(9EH.LJJIFFI.LIZ()) != 9c7.WIFI) {
            return false;
        }
        if ((this.LIZLLL > 0 && C4329LiC.LIZ.get() >= this.LIZLLL) || (str = this.LJI) == null || str.length() == 0) {
            return false;
        }
        return true;
    }

    public final String LIZ(String str) {
        String decode = URLDecoder.decode(str, "UTF-8");
        n.LIZIZ(decode, "");
        return decode;
    }

    /* JADX INFO: super call moved to the top of the method (can break code semantics) */
    public PassBackWebInfoBusiness(C2162KoL koL) {
        super(koL);
        M12.LIZ((Object) koL);
    }

    public final void LIZ(WeakReference<WebView> weakReference) {
        WebView webView = (WebView) weakReference.get();
        if (webView != null) {
            n.LIZIZ(webView, "");
            String url = webView.getUrl();
            if (TextUtils.isEmpty(url)) {
                LJ();
            } else {
                webView.evaluateJavascript("encodeURIComponent(document.documentElement.outerHTML)", new C2411KsM(this, url));
            }
        }
    }

    public final void LIZ(String str, String str2) {
        if (str2 != null) {
            LIZIZ().put(str, z.LIZJ(str2, (CharSequence) "\""));
        }
    }

    public final void LIZ(WebView webView, boolean z) {
        String url;
        if (LIZLLL() && LIZIZ().size() < this.LIZJ && webView != null && (url = webView.getUrl()) != null && !y.LIZ(url) && !n.LIZ("about:blank", webView.getUrl())) {
            WeakReference weakReference = new WeakReference(webView);
            if (z) {
                LIZ().postDelayed(new C2422KsX(this, weakReference), (long) this.LJ);
                LIZ().postDelayed(new C2423KsY(this, weakReference), 200);
                return;
            }
            LIZ((WeakReference<WebView>) weakReference);
        }
    }
}
