package com.chartboost.sdk.impl;

import com.chartboost.sdk.privacy.model.CCPA;
import com.chartboost.sdk.privacy.model.COPPA;
import com.chartboost.sdk.privacy.model.LGPD;
import com.ironsource.y8;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
/* loaded from: classes2.dex */
public class p9 {
    public b A;
    public final String B;
    public final ja C;
    public final nb D;
    public final o7 E;

    /* renamed from: a  reason: collision with root package name */
    public final String f1784a;
    public final boolean b;
    public final boolean c;
    public final List d;
    public final boolean e;
    public final boolean f;
    public final boolean g;
    public final boolean h;
    public final boolean i;
    public final boolean j;
    public final boolean k;
    public final boolean l;
    public final int m;
    public final int n;
    public final int o;
    public final List p;
    public final boolean q;
    public final boolean r;
    public final boolean s;
    public final int t;
    public final boolean u;
    public final int v;
    public final boolean w;
    public final String x;
    public final String y;
    public final a z;

    public a a() {
        return this.z;
    }

    public o7 b() {
        return this.E;
    }

    public nb c() {
        return this.D;
    }

    public boolean d() {
        return this.b;
    }

    public boolean e() {
        return this.c;
    }

    public String f() {
        return this.B;
    }

    public ja g() {
        return this.C;
    }

    public boolean h() {
        return this.q;
    }

    public boolean j() {
        return this.u;
    }

    public n3 k() {
        return new n3(this.f1784a, this.q, this.x);
    }

    public p9(JSONObject jSONObject) {
        this.f1784a = jSONObject.optString("configVariant");
        this.b = jSONObject.optBoolean("prefetchDisable");
        this.c = jSONObject.optBoolean("publisherDisable");
        this.z = a.a(jSONObject);
        try {
            this.A = b.a(jSONObject);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        this.B = jSONObject.optString("publisherWarning", null);
        ArrayList arrayList = new ArrayList();
        JSONArray optJSONArray = jSONObject.optJSONArray("invalidateFolderList");
        if (optJSONArray != null) {
            int length = optJSONArray.length();
            for (int i = 0; i < length; i++) {
                String optString = optJSONArray.optString(i);
                if (!optString.isEmpty()) {
                    arrayList.add(optString);
                }
            }
        }
        this.d = Collections.unmodifiableList(arrayList);
        JSONObject optJSONObject = jSONObject.optJSONObject("trackingLevels");
        optJSONObject = optJSONObject == null ? new JSONObject() : optJSONObject;
        this.e = optJSONObject.optBoolean("critical", true);
        this.l = optJSONObject.optBoolean("includeStackTrace", true);
        this.f = optJSONObject.optBoolean("error");
        this.g = optJSONObject.optBoolean("debug");
        this.h = optJSONObject.optBoolean("session");
        this.i = optJSONObject.optBoolean("system");
        this.j = optJSONObject.optBoolean("timing");
        this.k = optJSONObject.optBoolean("user");
        this.C = ka.b(jSONObject);
        JSONObject optJSONObject2 = jSONObject.optJSONObject("videoPreCaching");
        this.D = nb.a(optJSONObject2 == null ? new JSONObject() : optJSONObject2);
        JSONObject optJSONObject3 = jSONObject.optJSONObject("omSdk");
        this.E = p7.b(optJSONObject3 == null ? new JSONObject() : optJSONObject3);
        JSONObject optJSONObject4 = jSONObject.optJSONObject(y8.h.K);
        optJSONObject4 = optJSONObject4 == null ? new JSONObject() : optJSONObject4;
        this.m = optJSONObject4.optInt("cacheMaxBytes", 104857600);
        int optInt = optJSONObject4.optInt("cacheMaxUnits", 10);
        this.n = optInt > 0 ? optInt : 10;
        this.o = (int) TimeUnit.SECONDS.toDays(optJSONObject4.optInt("cacheTTLs", r1.f1800a));
        ArrayList arrayList2 = new ArrayList();
        JSONArray optJSONArray2 = optJSONObject4.optJSONArray("directories");
        if (optJSONArray2 != null) {
            int length2 = optJSONArray2.length();
            for (int i2 = 0; i2 < length2; i2++) {
                String optString2 = optJSONArray2.optString(i2);
                if (!optString2.isEmpty()) {
                    arrayList2.add(optString2);
                }
            }
        }
        this.p = Collections.unmodifiableList(arrayList2);
        this.q = optJSONObject4.optBoolean("enabled", i());
        this.r = optJSONObject4.optBoolean("inplayEnabled", true);
        this.s = optJSONObject4.optBoolean("interstitialEnabled", true);
        int optInt2 = optJSONObject4.optInt("invalidatePendingImpression", 3);
        this.t = optInt2 <= 0 ? 3 : optInt2;
        this.u = optJSONObject4.optBoolean("lockOrientation", true);
        this.v = optJSONObject4.optInt("prefetchSession", 3);
        this.w = optJSONObject4.optBoolean("rewardVideoEnabled", true);
        String optString3 = optJSONObject4.optString("version", "v2");
        this.x = optString3;
        this.y = String.format("%s/%s%s", y8.h.K, optString3, "/prefetch");
    }

    public static boolean i() {
        int[] iArr = {4, 4, 2};
        String a2 = v0.b().a();
        if (a2 != null && a2.length() > 0) {
            String[] split = a2.replaceAll("[^\\d.]", "").split("\\.");
            for (int i = 0; i < split.length && i < 3; i++) {
                try {
                    if (Integer.parseInt(split[i]) > iArr[i]) {
                        return true;
                    }
                    if (Integer.parseInt(split[i]) < iArr[i]) {
                        return false;
                    }
                } catch (NumberFormatException unused) {
                }
            }
        }
        return false;
    }

    /* loaded from: classes2.dex */
    public static class b {

        /* renamed from: a  reason: collision with root package name */
        public HashSet f1786a;

        public HashSet a() {
            return this.f1786a;
        }

        public static void a(HashSet hashSet, int i) {
            if (i == 0) {
                hashSet.clear();
            }
        }

        public static void a(JSONArray jSONArray, HashSet hashSet, int i) {
            for (int i2 = 0; i2 < i; i2++) {
                hashSet.add(jSONArray.getString(i2));
            }
        }

        public static b a(JSONObject jSONObject) {
            b bVar = new b();
            HashSet hashSet = new HashSet();
            hashSet.add(CCPA.CCPA_STANDARD);
            hashSet.add(COPPA.COPPA_STANDARD);
            hashSet.add(LGPD.LGPD_STANDARD);
            JSONArray optJSONArray = jSONObject.optJSONArray("privacyStandards");
            if (optJSONArray != null) {
                int length = optJSONArray.length();
                a(optJSONArray, hashSet, length);
                a(hashSet, length);
            }
            bVar.f1786a = hashSet;
            return bVar;
        }
    }

    /* loaded from: classes2.dex */
    public static class a {

        /* renamed from: a  reason: collision with root package name */
        public boolean f1785a;

        public boolean a() {
            return this.f1785a;
        }

        public static a a(JSONObject jSONObject) {
            a aVar = new a();
            aVar.f1785a = jSONObject.optBoolean("bannerEnable", true);
            return aVar;
        }
    }
}
