package com.bytedance.sdk.component.DSW.tN;

import android.content.Context;
import android.text.TextUtils;
import java.util.HashMap;
import java.util.Iterator;
import org.json.JSONArray;
import org.json.JSONObject;
/* loaded from: classes8.dex */
public class wN {
    private static final Object AlY = new Object();
    private AlY Sg = new AlY();
    private Context YFl;
    private boolean tN;
    private int wN;

    public AlY tN() {
        return this.Sg;
    }

    public wN(Context context, boolean z, int i) {
        this.YFl = context;
        this.tN = z;
        this.wN = i;
    }

    /* JADX WARN: Removed duplicated region for block: B:35:0x00b0 A[Catch: all -> 0x0134, TryCatch #1 {all -> 0x0134, blocks: (B:6:0x0017, B:10:0x0022, B:14:0x003c, B:15:0x0042, B:17:0x0048, B:19:0x0064, B:20:0x006d, B:21:0x0070, B:23:0x0076, B:24:0x007f, B:26:0x0085, B:27:0x008f, B:29:0x0095, B:31:0x00a4, B:38:0x00c2, B:51:0x00fe, B:41:0x00c9, B:35:0x00b0, B:37:0x00bd), top: B:80:0x0017 }] */
    /* JADX WARN: Removed duplicated region for block: B:36:0x00bb  */
    /* JADX WARN: Removed duplicated region for block: B:40:0x00c8  */
    /* JADX WARN: Removed duplicated region for block: B:41:0x00c9 A[Catch: all -> 0x0134, TRY_LEAVE, TryCatch #1 {all -> 0x0134, blocks: (B:6:0x0017, B:10:0x0022, B:14:0x003c, B:15:0x0042, B:17:0x0048, B:19:0x0064, B:20:0x006d, B:21:0x0070, B:23:0x0076, B:24:0x007f, B:26:0x0085, B:27:0x008f, B:29:0x0095, B:31:0x00a4, B:38:0x00c2, B:51:0x00fe, B:41:0x00c9, B:35:0x00b0, B:37:0x00bd), top: B:80:0x0017 }] */
    /* JADX WARN: Removed duplicated region for block: B:43:0x00ce  */
    /* JADX WARN: Removed duplicated region for block: B:51:0x00fe A[Catch: all -> 0x0134, TRY_ENTER, TRY_LEAVE, TryCatch #1 {all -> 0x0134, blocks: (B:6:0x0017, B:10:0x0022, B:14:0x003c, B:15:0x0042, B:17:0x0048, B:19:0x0064, B:20:0x006d, B:21:0x0070, B:23:0x0076, B:24:0x007f, B:26:0x0085, B:27:0x008f, B:29:0x0095, B:31:0x00a4, B:38:0x00c2, B:51:0x00fe, B:41:0x00c9, B:35:0x00b0, B:37:0x00bd), top: B:80:0x0017 }] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public void YFl(org.json.JSONObject r10) {
        /*
            Method dump skipped, instructions count: 412
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: com.bytedance.sdk.component.DSW.tN.wN.YFl(org.json.JSONObject):void");
    }

    public void YFl() {
        if (this.tN) {
            String string = this.YFl.getSharedPreferences(qsH.YFl().YFl(this.wN).YFl(), 0).getString("tnc_config_str", null);
            if (TextUtils.isEmpty(string)) {
                return;
            }
            try {
                AlY Sg = Sg(new JSONObject(string));
                if (Sg != null) {
                    this.Sg = Sg;
                }
                if (Sg == null) {
                    return;
                }
                Sg.toString();
            } catch (Throwable th) {
                th.getMessage();
            }
        }
    }

    public void Sg() {
        try {
            String YFl = com.bytedance.sdk.component.DSW.AlY.AlY.YFl(this.YFl, 1, this.wN);
            if (TextUtils.isEmpty(YFl)) {
                return;
            }
            AlY Sg = Sg(new JSONObject(YFl));
            if (Sg != null) {
                Sg.toString();
            }
            if (Sg != null) {
                this.Sg = Sg;
            }
        } catch (Throwable th) {
            th.getMessage();
        }
    }

    private AlY Sg(JSONObject jSONObject) {
        try {
            AlY alY = new AlY();
            if (jSONObject.has("local_enable")) {
                alY.YFl = jSONObject.getInt("local_enable") != 0;
            }
            if (jSONObject.has("probe_enable")) {
                alY.Sg = jSONObject.getInt("probe_enable") != 0;
            }
            if (jSONObject.has("local_host_filter")) {
                JSONArray jSONArray = jSONObject.getJSONArray("local_host_filter");
                HashMap hashMap = new HashMap();
                if (jSONArray.length() > 0) {
                    for (int i = 0; i < jSONArray.length(); i++) {
                        String string = jSONArray.getString(i);
                        if (!TextUtils.isEmpty(string)) {
                            hashMap.put(string, 0);
                        }
                    }
                }
                alY.tN = hashMap;
            } else {
                alY.tN = null;
            }
            if (jSONObject.has("host_replace_map")) {
                JSONObject jSONObject2 = jSONObject.getJSONObject("host_replace_map");
                HashMap hashMap2 = new HashMap();
                if (jSONObject2.length() > 0) {
                    Iterator<String> keys = jSONObject2.keys();
                    while (keys.hasNext()) {
                        String next = keys.next();
                        String string2 = jSONObject2.getString(next);
                        if (!TextUtils.isEmpty(next) && !TextUtils.isEmpty(string2)) {
                            hashMap2.put(next, string2);
                        }
                    }
                }
                alY.AlY = hashMap2;
            } else {
                alY.AlY = null;
            }
            alY.wN = jSONObject.optInt("req_to_cnt", alY.wN);
            alY.vc = jSONObject.optInt("req_to_api_cnt", alY.vc);
            alY.DSW = jSONObject.optInt("req_to_ip_cnt", alY.DSW);
            alY.qsH = jSONObject.optInt("req_err_cnt", alY.qsH);
            alY.NjR = jSONObject.optInt("req_err_api_cnt", alY.NjR);
            alY.nc = jSONObject.optInt("req_err_ip_cnt", alY.nc);
            alY.eT = jSONObject.optInt("update_interval", alY.eT);
            alY.YoT = jSONObject.optInt("update_random_range", alY.YoT);
            alY.GA = jSONObject.optString("http_code_black", alY.GA);
            return alY;
        } catch (Throwable unused) {
            return null;
        }
    }
}
