CamScanner.apk(点击下载) / ServerResponseWrapper.java


package com.ironsource.mediationsdk.utils;

import android.content.Context;
import android.text.TextUtils;
import androidx.work.WorkRequest;
import com.evernote.edam.limits.Constants;
import com.facebook.appevents.AppEventsConstants;
import com.google.logging.type.LogSeverity;
import com.intsig.camscanner.attention.PurhcaseUsingCoupon;
import com.ironsource.environment.StringUtils;
import com.ironsource.mediationsdk.IronSource;
import com.ironsource.mediationsdk.events.InterstitialEventsManager;
import com.ironsource.mediationsdk.events.RewardedVideoEventsManager;
import com.ironsource.mediationsdk.logger.IronSourceLogger;
import com.ironsource.mediationsdk.logger.IronSourceLoggerManager;
import com.ironsource.mediationsdk.model.ApplicationConfigurations;
import com.ironsource.mediationsdk.model.ApplicationCrashReporterSettings;
import com.ironsource.mediationsdk.model.ApplicationEvents;
import com.ironsource.mediationsdk.model.ApplicationExternalSettings;
import com.ironsource.mediationsdk.model.ApplicationLogger;
import com.ironsource.mediationsdk.model.BannerConfigurations;
import com.ironsource.mediationsdk.model.BannerPlacement;
import com.ironsource.mediationsdk.model.Configurations;
import com.ironsource.mediationsdk.model.InterstitialConfigurations;
import com.ironsource.mediationsdk.model.InterstitialPlacement;
import com.ironsource.mediationsdk.model.OfferwallConfigurations;
import com.ironsource.mediationsdk.model.OfferwallPlacement;
import com.ironsource.mediationsdk.model.Placement;
import com.ironsource.mediationsdk.model.PlacementAvailabilitySettings;
import com.ironsource.mediationsdk.model.PlacementCappingType;
import com.ironsource.mediationsdk.model.ProviderOrder;
import com.ironsource.mediationsdk.model.ProviderSettings;
import com.ironsource.mediationsdk.model.ProviderSettingsHolder;
import com.ironsource.mediationsdk.model.RewardedVideoConfigurations;
import com.ironsource.mediationsdk.model.ServerSegmetData;
import com.microsoft.aad.adal.ClientMetricsEndpointType;
import com.umeng.analytics.pro.d;
import com.vungle.warren.model.ReportDBAdapter;
import io.netty.handler.codec.rtsp.RtspHeaders;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

public class ServerResponseWrapper {
    private final String A = "offerwall";
    private final String A0 = "reporterURL";
    private final String B = "banner";
    private final String B0 = "reporterKeyword";
    private final String C = "integration";
    private final String C0 = "includeANR";
    private final String D = "loggers";
    private final String D0 = RtspHeaders.Values.TIMEOUT;
    private final String E = "segment";
    private final String E0 = "adSourceName";
    private final String F = d.ar;
    private final String F0 = "spId";
    private final String G = "crashReporter";
    private final String G0 = "mpis";
    private final String H = ClientMetricsEndpointType.TOKEN;
    private final String H0 = "auction";
    private final String I = "external";
    private final String I0 = "auctionData";
    private final String J = "mediationTypes";
    private final String J0 = "auctioneerURL";
    private final String K = "providerDefaultInstance";
    private final String K0 = "programmatic";
    private final String L = "settings";
    private final String L0 = "objectPerWaterfall";
    private final String M = "maxNumOfAdaptersToLoadOnStart";
    private final String M0 = "minTimeBeforeFirstAuction";
    private final String N = "advancedLoading";
    private final String N0 = "timeToWaitBeforeAuction";
    private final String O = "adapterTimeOutInSeconds";
    private final String O0 = "timeToWaitBeforeLoad";
    private final String P = "atim";
    private final String P0 = "auctionRetryInterval";
    private final String Q = "bannerInterval";
    private final String Q0 = "isAuctionOnShowStart";
    private final String R = "loadRVInterval";
    private final String R0 = "isLoadWhileShow";
    private final String S = "expiredDurationInMinutes";
    private final String S0 = "auctionTrials";
    private final String T = "server";
    private final String T0 = "auctionTimeout";
    private final String U = "publisher";
    private final String U0 = "auctionSavedHistory";
    private final String V = "console";
    private final String V0 = "disableLoadWhileShowSupportFor";
    private final String W = "sendUltraEvents";
    private final String W0 = "timeToDeleteOldWaterfallAfterAuction";
    private final String X = "sendEventsToggle";
    private final String X0 = "compressAuctionRequest";
    private final String Y = "serverEventsURL";
    private final String Y0 = "compressAuctionResponse";
    private final String Z = "serverEventsType";
    private final String Z0 = "optInKeys";

    /* renamed from: a  reason: collision with root package name */
    private final String f42425a = "error";

    /* renamed from: a0  reason: collision with root package name */
    private final String f42426a0 = "backupThreshold";

    /* renamed from: a1  reason: collision with root package name */
    private final String f42427a1 = "tokenGenericParams";

    /* renamed from: b  reason: collision with root package name */
    private final int f42428b = 3;

    /* renamed from: b0  reason: collision with root package name */
    private final String f42429b0 = "maxNumberOfEvents";

    /* renamed from: b1  reason: collision with root package name */
    private final String f42430b1 = "isExternalArmEventsEnabled";

    /* renamed from: c  reason: collision with root package name */
    private final int f42431c = 2;

    /* renamed from: c0  reason: collision with root package name */
    private final String f42432c0 = "maxEventsPerBatch";

    /* renamed from: c1  reason: collision with root package name */
    private final String f42433c1 = "externalArmEventsUrl";

    /* renamed from: d  reason: collision with root package name */
    private final int f42434d = 60;

    /* renamed from: d0  reason: collision with root package name */
    private final String f42435d0 = "optOut";

    /* renamed from: d1  reason: collision with root package name */
    private final String f42436d1 = "compressExternalToken";

    /* renamed from: e  reason: collision with root package name */
    private final int f42437e = 10000;

    /* renamed from: e0  reason: collision with root package name */
    private final String f42438e0 = "optIn";

    /* renamed from: e1  reason: collision with root package name */
    private ProviderOrder f42439e1;

    /* renamed from: f  reason: collision with root package name */
    private final int f42440f = Constants.EDAM_BUSINESS_NOTEBOOKS_MAX;

    /* renamed from: f0  reason: collision with root package name */
    private final String f42441f0 = "triggerEvents";

    /* renamed from: f1  reason: collision with root package name */
    private ProviderSettingsHolder f42442f1;

    /* renamed from: g  reason: collision with root package name */
    private final int f42443g = LogSeverity.NOTICE_VALUE;

    /* renamed from: g0  reason: collision with root package name */
    private final String f42444g0 = "nonConnectivityEvents";

    /* renamed from: g1  reason: collision with root package name */
    private Configurations f42445g1;

    /* renamed from: h  reason: collision with root package name */
    private final int f42446h = 3;

    /* renamed from: h0  reason: collision with root package name */
    private final String f42447h0 = "placements";

    /* renamed from: h1  reason: collision with root package name */
    private String f42448h1;

    /* renamed from: i  reason: collision with root package name */
    private final int f42449i = 3;

    /* renamed from: i0  reason: collision with root package name */
    private final String f42450i0 = ReportDBAdapter.ReportColumns.COLUMN_PLACEMENT_ID;

    /* renamed from: i1  reason: collision with root package name */
    private String f42451i1;

    /* renamed from: j  reason: collision with root package name */
    private final int f42452j = 2;

    /* renamed from: j0  reason: collision with root package name */
    private final String f42453j0 = "placementName";

    /* renamed from: j1  reason: collision with root package name */
    private JSONObject f42454j1;

    /* renamed from: k  reason: collision with root package name */
    private final int f42455k = 15;

    /* renamed from: k0  reason: collision with root package name */
    private final String f42456k0 = "delivery";

    /* renamed from: k1  reason: collision with root package name */
    private Context f42457k1;

    /* renamed from: l  reason: collision with root package name */
    private final long f42458l = WorkRequest.MIN_BACKOFF_MILLIS;

    /* renamed from: l0  reason: collision with root package name */
    private final String f42459l0 = "isDefault";

    /* renamed from: m  reason: collision with root package name */
    private final int f42460m = 0;

    /* renamed from: m0  reason: collision with root package name */
    private final String f42461m0 = "capping";

    /* renamed from: n  reason: collision with root package name */
    private final boolean f42462n = false;

    /* renamed from: n0  reason: collision with root package name */
    private final String f42463n0 = "pacing";

    /* renamed from: o  reason: collision with root package name */
    private final int f42464o = 30000;

    /* renamed from: o0  reason: collision with root package name */
    private final String f42465o0 = "enabled";

    /* renamed from: p  reason: collision with root package name */
    private final int f42466p = -1;

    /* renamed from: p0  reason: collision with root package name */
    private final String f42467p0 = "maxImpressions";

    /* renamed from: q  reason: collision with root package name */
    private final int f42468q = Constants.EDAM_BUSINESS_NOTEBOOKS_MAX;

    /* renamed from: q0  reason: collision with root package name */
    private final String f42469q0 = "numOfSeconds";

    /* renamed from: r  reason: collision with root package name */
    private final String f42470r = "providerOrder";

    /* renamed from: r0  reason: collision with root package name */
    private final String f42471r0 = "unit";

    /* renamed from: s  reason: collision with root package name */
    private final String f42472s = "providerSettings";

    /* renamed from: s0  reason: collision with root package name */
    private final String f42473s0 = "virtualItemName";

    /* renamed from: t  reason: collision with root package name */
    private final String f42474t = "configurations";

    /* renamed from: t0  reason: collision with root package name */
    private final String f42475t0 = "virtualItemCount";

    /* renamed from: u  reason: collision with root package name */
    private final String f42476u = "genericParams";

    /* renamed from: u0  reason: collision with root package name */
    private final String f42477u0 = "backFill";

    /* renamed from: v  reason: collision with root package name */
    private final String f42478v = "adUnits";

    /* renamed from: v0  reason: collision with root package name */
    private final String f42479v0 = PurhcaseUsingCoupon.CTION_UPDATE_USER_INFO_TYPE_PREMIUM;

    /* renamed from: w  reason: collision with root package name */
    private final String f42480w = "providerLoadName";

    /* renamed from: w0  reason: collision with root package name */
    private final String f42481w0 = "uuidEnabled";

    /* renamed from: x  reason: collision with root package name */
    private final String f42482x = "application";

    /* renamed from: x0  reason: collision with root package name */
    private final String f42483x0 = "abt";

    /* renamed from: y  reason: collision with root package name */
    private final String f42484y = "rewardedVideo";

    /* renamed from: y0  reason: collision with root package name */
    private final String f42485y0 = "delayLoadFailure";

    /* renamed from: z  reason: collision with root package name */
    private final String f42486z = "interstitial";

    /* renamed from: z0  reason: collision with root package name */
    private final String f42487z0 = "keysToInclude";

    public ServerResponseWrapper(Context context, String str, String str2, String str3) {
        this.f42457k1 = context;
        try {
            if (TextUtils.isEmpty(str3)) {
                this.f42454j1 = new JSONObject();
            } else {
                this.f42454j1 = new JSONObject(str3);
            }
            p();
            n();
            o();
            this.f42448h1 = TextUtils.isEmpty(str) ? "" : str;
            this.f42451i1 = TextUtils.isEmpty(str2) ? "" : str2;
        } catch (JSONException e10) {
            e10.printStackTrace();
            a();
        }
    }

    public ServerResponseWrapper(ServerResponseWrapper serverResponseWrapper) {
        try {
            this.f42457k1 = serverResponseWrapper.getContext();
            this.f42454j1 = new JSONObject(serverResponseWrapper.f42454j1.toString());
            this.f42448h1 = serverResponseWrapper.f42448h1;
            this.f42451i1 = serverResponseWrapper.f42451i1;
            this.f42439e1 = serverResponseWrapper.g();
            this.f42442f1 = serverResponseWrapper.h();
            this.f42445g1 = serverResponseWrapper.b();
        } catch (Exception unused) {
            a();
        }
    }

    private void a() {
        this.f42454j1 = new JSONObject();
        this.f42448h1 = "";
        this.f42451i1 = "";
        this.f42439e1 = new ProviderOrder();
        this.f42442f1 = ProviderSettingsHolder.e();
        this.f42445g1 = new Configurations();
    }

    private int d(JSONObject jSONObject, JSONObject jSONObject2, String str, int i10) {
        int i11 = 0;
        if (jSONObject.has(str)) {
            i11 = jSONObject.optInt(str, 0);
        } else if (jSONObject2.has(str)) {
            i11 = jSONObject2.optInt(str, 0);
        }
        return i11 == 0 ? i10 : i11;
    }

    private long e(JSONObject jSONObject, JSONObject jSONObject2, String str, long j2) {
        long optLong = jSONObject.has(str) ? jSONObject.optLong(str, 0) : jSONObject2.has(str) ? jSONObject2.optLong(str, 0) : 0;
        return optLong == 0 ? j2 : optLong;
    }

    /* JADX WARNING: Code restructure failed: missing block: B:11:0x0042, code lost:
        if (r7.toString().equals(r6) != false) goto L_0x0036;
     */
    private PlacementAvailabilitySettings f(JSONObject jSONObject) {
        PlacementCappingType placementCappingType = null;
        if (jSONObject == null) {
            return null;
        }
        PlacementAvailabilitySettings.PlacementAvailabilitySettingsBuilder placementAvailabilitySettingsBuilder = new PlacementAvailabilitySettings.PlacementAvailabilitySettingsBuilder();
        boolean z10 = true;
        placementAvailabilitySettingsBuilder.c(jSONObject.optBoolean("delivery", true));
        JSONObject optJSONObject = jSONObject.optJSONObject("capping");
        if (optJSONObject != null) {
            String optString = optJSONObject.optString("unit");
            if (!TextUtils.isEmpty(optString)) {
                PlacementCappingType placementCappingType2 = PlacementCappingType.PER_DAY;
                if (!placementCappingType2.toString().equals(optString)) {
                    placementCappingType2 = PlacementCappingType.PER_HOUR;
                }
                placementCappingType = placementCappingType2;
            }
            int optInt = optJSONObject.optInt("maxImpressions", 0);
            placementAvailabilitySettingsBuilder.b(optJSONObject.optBoolean("enabled", false) && optInt > 0, placementCappingType, optInt);
        }
        JSONObject optJSONObject2 = jSONObject.optJSONObject("pacing");
        if (optJSONObject2 != null) {
            int optInt2 = optJSONObject2.optInt("numOfSeconds", 0);
            if (!optJSONObject2.optBoolean("enabled", false) || optInt2 <= 0) {
                z10 = false;
            }
            placementAvailabilitySettingsBuilder.d(z10, optInt2);
        }
        return placementAvailabilitySettingsBuilder.a();
    }

    private Context getContext() {
        return this.f42457k1;
    }

    private JSONObject k(JSONObject jSONObject, String str) {
        if (jSONObject != null) {
            return jSONObject.optJSONObject(str);
        }
        return null;
    }

    private boolean l() {
        JSONObject k10 = k(k(this.f42454j1, "configurations"), "adUnits");
        JSONArray names = k10.names();
        if (names == null) {
            return false;
        }
        for (int i10 = 0; i10 < names.length(); i10++) {
            JSONArray optJSONArray = k(k10, names.optString(i10)).optJSONArray("placements");
            if (optJSONArray == null || optJSONArray.length() == 0) {
                return false;
            }
        }
        return true;
    }

    private void n() {
        JSONObject jSONObject;
        JSONObject jSONObject2;
        String str;
        String str2;
        String str3;
        JSONObject jSONObject3;
        RewardedVideoConfigurations rewardedVideoConfigurations;
        String str4;
        String str5;
        String str6;
        String str7;
        String str8;
        String str9;
        InterstitialConfigurations interstitialConfigurations;
        String str10;
        String str11;
        String str12;
        JSONObject jSONObject4;
        String str13;
        String str14;
        String str15;
        String str16;
        String str17;
        String str18;
        String str19;
        JSONObject jSONObject5;
        JSONObject jSONObject6;
        String str20;
        BannerConfigurations bannerConfigurations;
        String str21;
        String str22;
        JSONObject jSONObject7;
        String str23;
        String str24;
        String str25;
        String str26;
        OfferwallConfigurations offerwallConfigurations;
        String str27;
        ApplicationExternalSettings applicationExternalSettings;
        JSONObject k10;
        int[] iArr;
        int[] iArr2;
        int[] iArr3;
        int[] iArr4;
        int[] iArr5;
        int[] iArr6;
        int[] iArr7;
        int[] iArr8;
        AuctionSettings auctionSettings;
        AuctionSettings auctionSettings2;
        boolean z10;
        int i10;
        int[] iArr9;
        int[] iArr10;
        int[] iArr11;
        int[] iArr12;
        AuctionSettings auctionSettings3;
        boolean z11;
        int i11;
        int[] iArr13;
        int[] iArr14;
        int[] iArr15;
        int[] iArr16;
        AuctionSettings auctionSettings4;
        try {
            JSONObject k11 = k(this.f42454j1, "configurations");
            JSONObject k12 = k(k11, "adUnits");
            JSONObject k13 = k(k11, "application");
            JSONObject k14 = k(k12, "rewardedVideo");
            JSONObject k15 = k(k12, "interstitial");
            JSONObject k16 = k(k12, "offerwall");
            JSONObject k17 = k(k12, "banner");
            JSONObject k18 = k(k13, d.ar);
            JSONObject k19 = k(k13, "loggers");
            JSONObject k20 = k(k13, ClientMetricsEndpointType.TOKEN);
            JSONObject k21 = k(k13, "segment");
            JSONObject k22 = k(k13, "auction");
            JSONObject k23 = k(k13, "crashReporter");
            JSONObject k24 = k(k13, "settings");
            JSONObject k25 = k(k13, "external");
            if (k13 != null) {
                jSONObject2 = k25;
                jSONObject = k23;
                IronSourceUtils.W(this.f42457k1, "uuidEnabled", k13.optBoolean("uuidEnabled", true));
            } else {
                jSONObject2 = k25;
                jSONObject = k23;
            }
            if (k18 != null) {
                String optString = k18.optString("abt");
                if (!TextUtils.isEmpty(optString)) {
                    InterstitialEventsManager.u0().S(optString);
                    RewardedVideoEventsManager.u0().S(optString);
                }
            }
            String str28 = "nonConnectivityEvents";
            String str29 = "triggerEvents";
            String str30 = "optIn";
            if (k14 != null) {
                JSONArray optJSONArray = k14.optJSONArray("placements");
                str7 = "placements";
                JSONObject k26 = k(k14, d.ar);
                str6 = d.ar;
                int d10 = d(k14, k13, "maxNumOfAdaptersToLoadOnStart", 2);
                str4 = "maxNumOfAdaptersToLoadOnStart";
                int d11 = d(k14, k13, "advancedLoading", 0);
                if (d11 > 0) {
                    i11 = d11;
                    z11 = true;
                } else {
                    i11 = d10;
                    z11 = false;
                }
                int d12 = d(k14, k13, "adapterTimeOutInSeconds", 60);
                int d13 = d(k14, k13, "loadRVInterval", LogSeverity.NOTICE_VALUE);
                int d14 = d(k14, k13, "expiredDurationInMinutes", -1);
                JSONObject U2 = IronSourceUtils.U(k26, k18);
                boolean optBoolean = U2.optBoolean("sendUltraEvents", false);
                boolean optBoolean2 = U2.optBoolean("sendEventsToggle", false);
                String optString2 = U2.optString("serverEventsURL", "");
                String optString3 = U2.optString("serverEventsType", "");
                int optInt = U2.optInt("backupThreshold", -1);
                int optInt2 = U2.optInt("maxNumberOfEvents", -1);
                int optInt3 = U2.optInt("maxEventsPerBatch", Constants.EDAM_BUSINESS_NOTEBOOKS_MAX);
                JSONArray optJSONArray2 = U2.optJSONArray("optOut");
                if (optJSONArray2 != null) {
                    int[] iArr17 = new int[optJSONArray2.length()];
                    str = "maxEventsPerBatch";
                    str5 = "optOut";
                    for (int i12 = 0; i12 < optJSONArray2.length(); i12++) {
                        iArr17[i12] = optJSONArray2.optInt(i12);
                    }
                    iArr13 = iArr17;
                } else {
                    str = "maxEventsPerBatch";
                    str5 = "optOut";
                    iArr13 = null;
                }
                JSONArray optJSONArray3 = U2.optJSONArray(str30);
                if (optJSONArray3 != null) {
                    int[] iArr18 = new int[optJSONArray3.length()];
                    str30 = str30;
                    for (int i13 = 0; i13 < optJSONArray3.length(); i13++) {
                        iArr18[i13] = optJSONArray3.optInt(i13);
                    }
                    iArr14 = iArr18;
                } else {
                    str30 = str30;
                    iArr14 = null;
                }
                JSONArray optJSONArray4 = U2.optJSONArray(str29);
                if (optJSONArray4 != null) {
                    int[] iArr19 = new int[optJSONArray4.length()];
                    str29 = str29;
                    for (int i14 = 0; i14 < optJSONArray4.length(); i14++) {
                        iArr19[i14] = optJSONArray4.optInt(i14);
                    }
                    iArr15 = iArr19;
                } else {
                    str29 = str29;
                    iArr15 = null;
                }
                JSONArray optJSONArray5 = U2.optJSONArray(str28);
                if (optJSONArray5 != null) {
                    int[] iArr20 = new int[optJSONArray5.length()];
                    for (int i15 = 0; i15 < optJSONArray5.length(); i15++) {
                        iArr20[i15] = optJSONArray5.optInt(i15);
                    }
                    iArr16 = iArr20;
                } else {
                    iArr16 = null;
                }
                ApplicationEvents applicationEvents = new ApplicationEvents(optBoolean, optBoolean2, optString2, optString3, optInt, optInt2, optInt3, iArr13, iArr14, iArr15, iArr16);
                if (k22 != null) {
                    JSONObject k27 = k(k22, "rewardedVideo");
                    str28 = str28;
                    str8 = "maxNumberOfEvents";
                    jSONObject3 = k22;
                    str3 = "backupThreshold";
                    str2 = "serverEventsType";
                    str9 = "serverEventsURL";
                    AuctionSettings auctionSettings5 = new AuctionSettings(k22.optString("auctionData", ""), k22.optString("auctioneerURL", ""), k22.optInt("auctionTrials", 2), k22.optInt("auctionSavedHistory", 15), k22.optLong("auctionTimeout", WorkRequest.MIN_BACKOFF_MILLIS), k27.optBoolean("programmatic", false), (long) k27.optInt("minTimeBeforeFirstAuction", 2000), (long) k27.optInt("auctionRetryInterval", 30000), (long) k27.optInt("timeToWaitBeforeAuction", Constants.EDAM_BUSINESS_NOTEBOOKS_MAX), (long) k27.optInt("timeToWaitBeforeLoad", 50), k27.optBoolean("isAuctionOnShowStart", false), k27.optBoolean("isLoadWhileShow", false), k27.optInt("timeToDeleteOldWaterfallAfterAuction", 30000), k22.optBoolean("compressAuctionRequest", false), k22.optBoolean("compressAuctionResponse", false), false);
                    JSONArray optJSONArray6 = k27.optJSONArray("disableLoadWhileShowSupportFor");
                    if (optJSONArray6 != null) {
                        for (int i16 = 0; i16 < optJSONArray6.length(); i16++) {
                            auctionSettings5.a(optJSONArray6.optString(i16));
                        }
                    }
                    auctionSettings4 = auctionSettings5;
                } else {
                    str9 = "serverEventsURL";
                    str28 = str28;
                    str3 = "backupThreshold";
                    str2 = "serverEventsType";
                    jSONObject3 = k22;
                    str8 = "maxNumberOfEvents";
                    auctionSettings4 = new AuctionSettings();
                }
                RewardedVideoConfigurations rewardedVideoConfigurations2 = new RewardedVideoConfigurations(i11, z11, d12, d13, d14, applicationEvents, auctionSettings4);
                if (optJSONArray != null) {
                    for (int i17 = 0; i17 < optJSONArray.length(); i17++) {
                        Placement t10 = t(optJSONArray.optJSONObject(i17));
                        if (t10 != null) {
                            rewardedVideoConfigurations2.a(t10);
                        }
                    }
                }
                String optString4 = k14.optString("backFill");
                if (!TextUtils.isEmpty(optString4)) {
                    rewardedVideoConfigurations2.l(optString4);
                }
                String optString5 = k14.optString(PurhcaseUsingCoupon.CTION_UPDATE_USER_INFO_TYPE_PREMIUM);
                if (!TextUtils.isEmpty(optString5)) {
                    rewardedVideoConfigurations2.m(optString5);
                }
                rewardedVideoConfigurations = rewardedVideoConfigurations2;
            } else {
                str6 = d.ar;
                str4 = "maxNumOfAdaptersToLoadOnStart";
                str7 = "placements";
                str3 = "backupThreshold";
                str2 = "serverEventsType";
                str = "maxEventsPerBatch";
                str5 = "optOut";
                jSONObject3 = k22;
                str9 = "serverEventsURL";
                str8 = "maxNumberOfEvents";
                rewardedVideoConfigurations = null;
            }
            if (k15 != null) {
                str16 = str7;
                JSONArray optJSONArray7 = k15.optJSONArray(str16);
                str14 = str6;
                JSONObject k28 = k(k15, str14);
                str15 = str4;
                int d15 = d(k15, k13, str15, 2);
                int d16 = d(k15, k13, "advancedLoading", 0);
                if (d16 > 0) {
                    i10 = d16;
                    z10 = true;
                } else {
                    i10 = d15;
                    z10 = false;
                }
                int d17 = d(k15, k13, "adapterTimeOutInSeconds", 60);
                int d18 = d(k15, k13, "delayLoadFailure", 3);
                JSONObject U3 = IronSourceUtils.U(k28, k18);
                boolean optBoolean3 = U3.optBoolean("sendEventsToggle", false);
                String optString6 = U3.optString(str9, "");
                str13 = str2;
                String optString7 = U3.optString(str13, "");
                int optInt4 = U3.optInt(str3, -1);
                int optInt5 = U3.optInt(str8, -1);
                str12 = str9;
                int optInt6 = U3.optInt(str, Constants.EDAM_BUSINESS_NOTEBOOKS_MAX);
                str = str;
                JSONArray optJSONArray8 = U3.optJSONArray(str5);
                if (optJSONArray8 != null) {
                    str5 = str5;
                    int[] iArr21 = new int[optJSONArray8.length()];
                    str10 = str8;
                    str3 = str3;
                    for (int i18 = 0; i18 < optJSONArray8.length(); i18++) {
                        iArr21[i18] = optJSONArray8.optInt(i18);
                    }
                    iArr9 = iArr21;
                } else {
                    str10 = str8;
                    str5 = str5;
                    str3 = str3;
                    iArr9 = null;
                }
                JSONArray optJSONArray9 = U3.optJSONArray(str30);
                if (optJSONArray9 != null) {
                    int[] iArr22 = new int[optJSONArray9.length()];
                    str30 = str30;
                    for (int i19 = 0; i19 < optJSONArray9.length(); i19++) {
                        iArr22[i19] = optJSONArray9.optInt(i19);
                    }
                    iArr10 = iArr22;
                } else {
                    str30 = str30;
                    iArr10 = null;
                }
                JSONArray optJSONArray10 = U3.optJSONArray(str29);
                if (optJSONArray10 != null) {
                    int[] iArr23 = new int[optJSONArray10.length()];
                    str29 = str29;
                    for (int i20 = 0; i20 < optJSONArray10.length(); i20++) {
                        iArr23[i20] = optJSONArray10.optInt(i20);
                    }
                    iArr11 = iArr23;
                } else {
                    str29 = str29;
                    iArr11 = null;
                }
                str17 = str28;
                JSONArray optJSONArray11 = U3.optJSONArray(str17);
                if (optJSONArray11 != null) {
                    int[] iArr24 = new int[optJSONArray11.length()];
                    for (int i21 = 0; i21 < optJSONArray11.length(); i21++) {
                        iArr24[i21] = optJSONArray11.optInt(i21);
                    }
                    iArr12 = iArr24;
                } else {
                    iArr12 = null;
                }
                ApplicationEvents applicationEvents2 = new ApplicationEvents(false, optBoolean3, optString6, optString7, optInt4, optInt5, optInt6, iArr9, iArr10, iArr11, iArr12);
                if (jSONObject3 != null) {
                    jSONObject4 = jSONObject3;
                    JSONObject k29 = k(jSONObject4, "interstitial");
                    str11 = "sendEventsToggle";
                    auctionSettings3 = new AuctionSettings(jSONObject4.optString("auctionData", ""), jSONObject4.optString("auctioneerURL", ""), jSONObject4.optInt("auctionTrials", 2), jSONObject4.optInt("auctionSavedHistory", 15), jSONObject4.optLong("auctionTimeout", WorkRequest.MIN_BACKOFF_MILLIS), k29.optBoolean("programmatic", false), (long) k29.optInt("minTimeBeforeFirstAuction", 2000), 0, 0, 0, true, true, 0, jSONObject4.optBoolean("compressAuctionRequest", false), jSONObject4.optBoolean("compressAuctionResponse", false), k29.optBoolean("objectPerWaterfall", false));
                } else {
                    str11 = "sendEventsToggle";
                    jSONObject4 = jSONObject3;
                    auctionSettings3 = new AuctionSettings();
                }
                InterstitialConfigurations interstitialConfigurations2 = new InterstitialConfigurations(i10, z10, d17, applicationEvents2, auctionSettings3, d18);
                if (optJSONArray7 != null) {
                    for (int i22 = 0; i22 < optJSONArray7.length(); i22++) {
                        InterstitialPlacement r10 = r(optJSONArray7.optJSONObject(i22));
                        if (r10 != null) {
                            interstitialConfigurations2.a(r10);
                        }
                    }
                }
                String optString8 = k15.optString("backFill");
                if (!TextUtils.isEmpty(optString8)) {
                    interstitialConfigurations2.j(optString8);
                }
                String optString9 = k15.optString(PurhcaseUsingCoupon.CTION_UPDATE_USER_INFO_TYPE_PREMIUM);
                if (!TextUtils.isEmpty(optString9)) {
                    interstitialConfigurations2.k(optString9);
                }
                interstitialConfigurations = interstitialConfigurations2;
            } else {
                str17 = str28;
                str16 = str7;
                str14 = str6;
                str15 = str4;
                str13 = str2;
                str11 = "sendEventsToggle";
                str10 = str8;
                str12 = str9;
                jSONObject4 = jSONObject3;
                interstitialConfigurations = null;
            }
            if (k17 != null) {
                JSONArray optJSONArray12 = k17.optJSONArray(str16);
                JSONObject k30 = k(k17, str14);
                int d19 = d(k17, k13, str15, 1);
                str20 = str16;
                str21 = str14;
                jSONObject6 = jSONObject;
                jSONObject5 = k24;
                long e10 = e(k17, k13, "atim", WorkRequest.MIN_BACKOFF_MILLIS);
                int d20 = d(k17, k13, "delayLoadFailure", 3);
                int d21 = d(k17, k13, "bannerInterval", 60);
                JSONObject U4 = IronSourceUtils.U(k30, k18);
                str26 = str11;
                boolean optBoolean4 = U4.optBoolean(str26, false);
                str25 = str12;
                str24 = "";
                String optString10 = U4.optString(str25, str24);
                String optString11 = U4.optString(str13, str24);
                str23 = str3;
                int optInt7 = U4.optInt(str23, -1);
                int optInt8 = U4.optInt(str10, -1);
                int optInt9 = U4.optInt(str, Constants.EDAM_BUSINESS_NOTEBOOKS_MAX);
                JSONArray optJSONArray13 = U4.optJSONArray(str5);
                if (optJSONArray13 != null) {
                    jSONObject7 = k13;
                    int[] iArr25 = new int[optJSONArray13.length()];
                    str = str;
                    str5 = str5;
                    for (int i23 = 0; i23 < optJSONArray13.length(); i23++) {
                        iArr25[i23] = optJSONArray13.optInt(i23);
                    }
                    iArr5 = iArr25;
                } else {
                    jSONObject7 = k13;
                    str = str;
                    str5 = str5;
                    iArr5 = null;
                }
                JSONArray optJSONArray14 = U4.optJSONArray(str30);
                if (optJSONArray14 != null) {
                    int[] iArr26 = new int[optJSONArray14.length()];
                    str18 = str30;
                    for (int i24 = 0; i24 < optJSONArray14.length(); i24++) {
                        iArr26[i24] = optJSONArray14.optInt(i24);
                    }
                    iArr6 = iArr26;
                } else {
                    str18 = str30;
                    iArr6 = null;
                }
                JSONArray optJSONArray15 = U4.optJSONArray(str29);
                if (optJSONArray15 != null) {
                    int[] iArr27 = new int[optJSONArray15.length()];
                    str19 = str29;
                    for (int i25 = 0; i25 < optJSONArray15.length(); i25++) {
                        iArr27[i25] = optJSONArray15.optInt(i25);
                    }
                    iArr7 = iArr27;
                } else {
                    str19 = str29;
                    iArr7 = null;
                }
                JSONArray optJSONArray16 = U4.optJSONArray(str17);
                if (optJSONArray16 != null) {
                    int[] iArr28 = new int[optJSONArray16.length()];
                    for (int i26 = 0; i26 < optJSONArray16.length(); i26++) {
                        iArr28[i26] = optJSONArray16.optInt(i26);
                    }
                    iArr8 = iArr28;
                } else {
                    iArr8 = null;
                }
                ApplicationEvents applicationEvents3 = new ApplicationEvents(false, optBoolean4, optString10, optString11, optInt7, optInt8, optInt9, iArr5, iArr6, iArr7, iArr8);
                if (jSONObject4 != null) {
                    JSONObject k31 = k(jSONObject4, "banner");
                    if (k31 != null) {
                        str22 = str10;
                        auctionSettings2 = new AuctionSettings(jSONObject4.optString("auctionData", str24), jSONObject4.optString("auctioneerURL", str24), jSONObject4.optInt("auctionTrials", 2), jSONObject4.optInt("auctionSavedHistory", 15), jSONObject4.optLong("auctionTimeout", WorkRequest.MIN_BACKOFF_MILLIS), k31.optBoolean("programmatic", false), (long) k31.optInt("minTimeBeforeFirstAuction", 2000), 0, 0, 0, true, true, 0, jSONObject4.optBoolean("compressAuctionRequest", false), jSONObject4.optBoolean("compressAuctionResponse", false), false);
                    } else {
                        str22 = str10;
                        auctionSettings2 = new AuctionSettings();
                    }
                    auctionSettings = auctionSettings2;
                } else {
                    str22 = str10;
                    auctionSettings = new AuctionSettings();
                }
                BannerConfigurations bannerConfigurations2 = new BannerConfigurations(d19, e10, applicationEvents3, d21, auctionSettings, d20);
                if (optJSONArray12 != null) {
                    for (int i27 = 0; i27 < optJSONArray12.length(); i27++) {
                        BannerPlacement q10 = q(optJSONArray12.optJSONObject(i27));
                        if (q10 != null) {
                            bannerConfigurations2.a(q10);
                        }
                    }
                }
                bannerConfigurations = bannerConfigurations2;
            } else {
                str20 = str16;
                str24 = "";
                jSONObject7 = k13;
                str21 = str14;
                jSONObject6 = jSONObject;
                jSONObject5 = k24;
                str25 = str12;
                str26 = str11;
                str19 = str29;
                str18 = str30;
                str22 = str10;
                str23 = str3;
                bannerConfigurations = null;
            }
            if (k16 != null) {
                str27 = str21;
                JSONObject U5 = IronSourceUtils.U(k(k16, str27), k18);
                boolean optBoolean5 = U5.optBoolean(str26, false);
                String optString12 = U5.optString(str25, str24);
                String optString13 = U5.optString(str13, str24);
                int optInt10 = U5.optInt(str23, -1);
                int optInt11 = U5.optInt(str22, -1);
                int optInt12 = U5.optInt(str, Constants.EDAM_BUSINESS_NOTEBOOKS_MAX);
                JSONArray optJSONArray17 = U5.optJSONArray(str5);
                if (optJSONArray17 != null) {
                    int[] iArr29 = new int[optJSONArray17.length()];
                    for (int i28 = 0; i28 < optJSONArray17.length(); i28++) {
                        iArr29[i28] = optJSONArray17.optInt(i28);
                    }
                    iArr = iArr29;
                } else {
                    iArr = null;
                }
                JSONArray optJSONArray18 = U5.optJSONArray(str18);
                if (optJSONArray18 != null) {
                    int[] iArr30 = new int[optJSONArray18.length()];
                    for (int i29 = 0; i29 < optJSONArray18.length(); i29++) {
                        iArr30[i29] = optJSONArray18.optInt(i29);
                    }
                    iArr2 = iArr30;
                } else {
                    iArr2 = null;
                }
                JSONArray optJSONArray19 = U5.optJSONArray(str19);
                if (optJSONArray19 != null) {
                    int[] iArr31 = new int[optJSONArray19.length()];
                    for (int i30 = 0; i30 < optJSONArray19.length(); i30++) {
                        iArr31[i30] = optJSONArray19.optInt(i30);
                    }
                    iArr3 = iArr31;
                } else {
                    iArr3 = null;
                }
                JSONArray optJSONArray20 = U5.optJSONArray(str17);
                if (optJSONArray20 != null) {
                    int[] iArr32 = new int[optJSONArray20.length()];
                    for (int i31 = 0; i31 < optJSONArray20.length(); i31++) {
                        iArr32[i31] = optJSONArray20.optInt(i31);
                    }
                    iArr4 = iArr32;
                } else {
                    iArr4 = null;
                }
                OfferwallConfigurations offerwallConfigurations2 = new OfferwallConfigurations(new ApplicationEvents(false, optBoolean5, optString12, optString13, optInt10, optInt11, optInt12, iArr, iArr2, iArr3, iArr4));
                offerwallConfigurations2.d(k16);
                JSONArray optJSONArray21 = k16.optJSONArray(str20);
                if (optJSONArray21 != null) {
                    for (int i32 = 0; i32 < optJSONArray21.length(); i32++) {
                        OfferwallPlacement s10 = s(optJSONArray21.optJSONObject(i32));
                        if (s10 != null) {
                            offerwallConfigurations2.a(s10);
                        }
                    }
                }
                offerwallConfigurations = offerwallConfigurations2;
            } else {
                str27 = str21;
                offerwallConfigurations = null;
            }
            TokenSettings tokenSettings = new TokenSettings();
            if (k20 != null) {
                JSONArray optJSONArray22 = k20.optJSONArray("optInKeys");
                if (optJSONArray22 != null) {
                    for (int i33 = 0; i33 < optJSONArray22.length(); i33++) {
                        tokenSettings.a(optJSONArray22.optString(i33));
                    }
                }
                JSONObject optJSONObject = k20.optJSONObject("tokenGenericParams");
                if (optJSONObject != null) {
                    tokenSettings.b(optJSONObject);
                }
            }
            ApplicationLogger applicationLogger = new ApplicationLogger(k19.optInt("server", 3), k19.optInt("publisher", 3), k19.optInt("console", 3));
            ApplicationCrashReporterSettings applicationCrashReporterSettings = new ApplicationCrashReporterSettings();
            if (jSONObject6 != null) {
                applicationCrashReporterSettings.i(jSONObject6.optBoolean("enabled", false));
                applicationCrashReporterSettings.k(jSONObject6.optString("reporterURL", str24));
                applicationCrashReporterSettings.j(jSONObject6.optString("reporterKeyword", str24));
                applicationCrashReporterSettings.l(jSONObject6.optBoolean("includeANR", false));
                applicationCrashReporterSettings.h(jSONObject6.optInt(RtspHeaders.Values.TIMEOUT, Constants.EDAM_BUSINESS_NOTEBOOKS_MAX));
                JSONArray optJSONArray23 = jSONObject6.optJSONArray("keysToInclude");
                if (optJSONArray23 != null) {
                    for (int i34 = 0; i34 < optJSONArray23.length(); i34++) {
                        applicationCrashReporterSettings.a(optJSONArray23.optString(i34));
                    }
                }
            }
            ServerSegmetData serverSegmetData = k21 != null ? new ServerSegmetData(k21.optString("name", str24), k21.optString("id", "-1"), k21.optJSONObject("custom")) : null;
            ApplicationGeneralSettings applicationGeneralSettings = jSONObject5 != null ? new ApplicationGeneralSettings(jSONObject5.optBoolean("isExternalArmEventsEnabled", true), jSONObject5.optString("externalArmEventsUrl", "http://outcome-arm-ext-med-ext.sonic-us.supersonicads.com/aemData")) : new ApplicationGeneralSettings();
            ApplicationExternalSettings applicationExternalSettings2 = new ApplicationExternalSettings();
            if (jSONObject2 != null) {
                JSONObject optJSONObject2 = jSONObject2.optJSONObject("mediationTypes");
                Map hashMap = new HashMap();
                if (optJSONObject2 != null) {
                    hashMap = IronSourceUtils.V(optJSONObject2);
                }
                applicationExternalSettings = new ApplicationExternalSettings(jSONObject2.optBoolean("compressExternalToken", false), hashMap);
            } else {
                applicationExternalSettings = applicationExternalSettings2;
            }
            this.f42445g1 = new Configurations(rewardedVideoConfigurations, interstitialConfigurations, offerwallConfigurations, bannerConfigurations, new ApplicationConfigurations(applicationLogger, serverSegmetData, tokenSettings, jSONObject7.optBoolean("integration", false), applicationCrashReporterSettings, applicationGeneralSettings, applicationExternalSettings));
            JSONObject k32 = k(k18, "genericParams");
            if (!(k32 == null || (k10 = k(k32, str27)) == null)) {
                k32.remove(str27);
                Map<String, String> V2 = IronSourceUtils.V(k10);
                RewardedVideoEventsManager.u0().X(V2);
                InterstitialEventsManager.u0().X(V2);
            }
            if (k32 != null) {
                Map<String, String> V3 = IronSourceUtils.V(k32);
                RewardedVideoEventsManager.u0().U(V3);
                InterstitialEventsManager.u0().U(V3);
            }
        } catch (Exception e11) {
            e11.printStackTrace();
        }
    }

    private void o() {
        try {
            JSONObject k10 = k(this.f42454j1, "providerOrder");
            JSONArray optJSONArray = k10.optJSONArray("rewardedVideo");
            JSONArray optJSONArray2 = k10.optJSONArray("interstitial");
            JSONArray optJSONArray3 = k10.optJSONArray("banner");
            this.f42439e1 = new ProviderOrder();
            if (!(optJSONArray == null || b() == null || b().e() == null)) {
                String b10 = b().e().b();
                String f10 = b().e().f();
                for (int i10 = 0; i10 < optJSONArray.length(); i10++) {
                    String optString = optJSONArray.optString(i10);
                    if (optString.equals(b10)) {
                        this.f42439e1.k(b10);
                    } else {
                        if (optString.equals(f10)) {
                            this.f42439e1.l(f10);
                        }
                        this.f42439e1.c(optString);
                        ProviderSettings d10 = ProviderSettingsHolder.e().d(optString);
                        if (d10 != null) {
                            d10.D(i10);
                        }
                    }
                }
            }
            if (!(optJSONArray2 == null || b() == null || b().c() == null)) {
                String b11 = b().c().b();
                String i11 = b().c().i();
                for (int i12 = 0; i12 < optJSONArray2.length(); i12++) {
                    String optString2 = optJSONArray2.optString(i12);
                    if (optString2.equals(b11)) {
                        this.f42439e1.i(b11);
                    } else {
                        if (optString2.equals(i11)) {
                            this.f42439e1.j(i11);
                        }
                        this.f42439e1.b(optString2);
                        ProviderSettings d11 = ProviderSettingsHolder.e().d(optString2);
                        if (d11 != null) {
                            d11.z(i12);
                        }
                    }
                }
            }
            if (optJSONArray3 != null) {
                for (int i13 = 0; i13 < optJSONArray3.length(); i13++) {
                    String optString3 = optJSONArray3.optString(i13);
                    this.f42439e1.a(optString3);
                    ProviderSettings d12 = ProviderSettingsHolder.e().d(optString3);
                    if (d12 != null) {
                        d12.w(i13);
                    }
                }
            }
        } catch (Exception e10) {
            e10.printStackTrace();
        }
    }

    private void p() {
        JSONObject jSONObject;
        try {
            this.f42442f1 = ProviderSettingsHolder.e();
            JSONObject k10 = k(this.f42454j1, "providerSettings");
            Iterator<String> keys = k10.keys();
            while (keys.hasNext()) {
                String next = keys.next();
                JSONObject optJSONObject = k10.optJSONObject(next);
                if (optJSONObject != null) {
                    boolean optBoolean = optJSONObject.optBoolean("mpis", false);
                    String optString = optJSONObject.optString("spId", AppEventsConstants.EVENT_PARAM_VALUE_NO);
                    String optString2 = optJSONObject.optString("adSourceName", null);
                    String optString3 = optJSONObject.optString("providerLoadName", next);
                    String optString4 = optJSONObject.optString("providerDefaultInstance", optString3);
                    JSONObject k11 = k(optJSONObject, "adUnits");
                    JSONObject k12 = k(optJSONObject, "application");
                    JSONObject k13 = k(k11, "rewardedVideo");
                    JSONObject k14 = k(k11, "interstitial");
                    JSONObject k15 = k(k11, "banner");
                    JSONObject U2 = IronSourceUtils.U(k13, k12);
                    JSONObject U3 = IronSourceUtils.U(k14, k12);
                    JSONObject U4 = IronSourceUtils.U(k15, k12);
                    if (this.f42442f1.b(next)) {
                        ProviderSettings d10 = this.f42442f1.d(next);
                        JSONObject o10 = d10.o();
                        JSONObject h10 = d10.h();
                        JSONObject d11 = d10.d();
                        d10.F(IronSourceUtils.U(o10, U2));
                        d10.B(IronSourceUtils.U(h10, U3));
                        d10.y(IronSourceUtils.U(d11, U4));
                        d10.C(optBoolean);
                        d10.G(optString);
                        d10.u(optString2);
                    } else {
                        if (u(optString3)) {
                            ProviderSettings d12 = this.f42442f1.d("Mediation");
                            JSONObject o11 = d12.o();
                            JSONObject h11 = d12.h();
                            JSONObject d13 = d12.d();
                            jSONObject = k10;
                            ProviderSettings providerSettings = new ProviderSettings(next, optString3, optString4, k12, IronSourceUtils.U(new JSONObject(o11.toString()), U2), IronSourceUtils.U(new JSONObject(h11.toString()), U3), IronSourceUtils.U(new JSONObject(d13.toString()), U4));
                            providerSettings.C(optBoolean);
                            providerSettings.G(optString);
                            providerSettings.u(optString2);
                            this.f42442f1.a(providerSettings);
                        } else {
                            jSONObject = k10;
                            ProviderSettings providerSettings2 = new ProviderSettings(next, optString3, optString4, k12, U2, U3, U4);
                            providerSettings2.C(optBoolean);
                            providerSettings2.G(optString);
                            providerSettings2.u(optString2);
                            this.f42442f1.a(providerSettings2);
                        }
                        k10 = jSONObject;
                    }
                }
                jSONObject = k10;
                k10 = jSONObject;
            }
            this.f42442f1.c();
        } catch (Exception e10) {
            e10.printStackTrace();
        }
    }

    private BannerPlacement q(JSONObject jSONObject) {
        if (jSONObject != null) {
            int optInt = jSONObject.optInt(ReportDBAdapter.ReportColumns.COLUMN_PLACEMENT_ID, -1);
            String optString = jSONObject.optString("placementName", "");
            boolean optBoolean = jSONObject.optBoolean("isDefault", false);
            PlacementAvailabilitySettings f10 = f(jSONObject);
            if (optInt >= 0 && !TextUtils.isEmpty(optString)) {
                BannerPlacement bannerPlacement = new BannerPlacement(optInt, optString, optBoolean, f10);
                if (f10 == null) {
                    return bannerPlacement;
                }
                CappingManager.a(this.f42457k1, bannerPlacement);
                return bannerPlacement;
            }
        }
        return null;
    }

    private InterstitialPlacement r(JSONObject jSONObject) {
        if (jSONObject != null) {
            int optInt = jSONObject.optInt(ReportDBAdapter.ReportColumns.COLUMN_PLACEMENT_ID, -1);
            String optString = jSONObject.optString("placementName", "");
            boolean optBoolean = jSONObject.optBoolean("isDefault", false);
            PlacementAvailabilitySettings f10 = f(jSONObject);
            if (optInt >= 0 && !TextUtils.isEmpty(optString)) {
                InterstitialPlacement interstitialPlacement = new InterstitialPlacement(optInt, optString, optBoolean, f10);
                if (f10 == null) {
                    return interstitialPlacement;
                }
                CappingManager.b(this.f42457k1, interstitialPlacement);
                return interstitialPlacement;
            }
        }
        return null;
    }

    private OfferwallPlacement s(JSONObject jSONObject) {
        if (jSONObject != null) {
            int optInt = jSONObject.optInt(ReportDBAdapter.ReportColumns.COLUMN_PLACEMENT_ID, -1);
            String optString = jSONObject.optString("placementName", "");
            boolean optBoolean = jSONObject.optBoolean("isDefault", false);
            if (optInt >= 0 && !TextUtils.isEmpty(optString)) {
                return new OfferwallPlacement(optInt, optString, optBoolean);
            }
        }
        return null;
    }

    private Placement t(JSONObject jSONObject) {
        if (jSONObject != null) {
            int optInt = jSONObject.optInt(ReportDBAdapter.ReportColumns.COLUMN_PLACEMENT_ID, -1);
            String optString = jSONObject.optString("placementName", "");
            boolean optBoolean = jSONObject.optBoolean("isDefault", false);
            String optString2 = jSONObject.optString("virtualItemName", "");
            int optInt2 = jSONObject.optInt("virtualItemCount", -1);
            PlacementAvailabilitySettings f10 = f(jSONObject);
            if (optInt >= 0 && !TextUtils.isEmpty(optString) && !TextUtils.isEmpty(optString2) && optInt2 > 0) {
                Placement placement = new Placement(optInt, optString, optBoolean, optString2, optInt2, f10);
                if (f10 == null) {
                    return placement;
                }
                CappingManager.c(this.f42457k1, placement);
                return placement;
            }
        }
        return null;
    }

    private boolean u(String str) {
        String a10 = StringUtils.a(str);
        return this.f42442f1.b("Mediation") && (StringUtils.a("SupersonicAds").equals(a10) || StringUtils.a("IronSource").equals(a10));
    }

    public Configurations b() {
        return this.f42445g1;
    }

    public List<IronSource.AD_UNIT> c() {
        ProviderOrder providerOrder;
        ProviderOrder providerOrder2;
        if (this.f42454j1 == null || this.f42445g1 == null) {
            return null;
        }
        ArrayList arrayList = new ArrayList();
        if (!(this.f42445g1.e() == null || (providerOrder2 = this.f42439e1) == null || providerOrder2.h().size() <= 0)) {
            arrayList.add(IronSource.AD_UNIT.REWARDED_VIDEO);
        }
        if (!(this.f42445g1.c() == null || (providerOrder = this.f42439e1) == null || providerOrder.e().size() <= 0)) {
            arrayList.add(IronSource.AD_UNIT.INTERSTITIAL);
        }
        if (this.f42445g1.d() != null) {
            arrayList.add(IronSource.AD_UNIT.OFFERWALL);
        }
        if (this.f42445g1.b() != null) {
            arrayList.add(IronSource.AD_UNIT.BANNER);
        }
        return arrayList;
    }

    public ProviderOrder g() {
        return this.f42439e1;
    }

    public ProviderSettingsHolder h() {
        return this.f42442f1;
    }

    public String i() {
        try {
            return this.f42439e1.f();
        } catch (Exception e10) {
            IronSourceLoggerManager.i().e(IronSourceLogger.IronSourceTag.INTERNAL, "getRVBackFillProvider", e10);
            return null;
        }
    }

    public String j() {
        try {
            return this.f42439e1.g();
        } catch (Exception e10) {
            IronSourceLoggerManager.i().e(IronSourceLogger.IronSourceTag.INTERNAL, "getRVPremiumProvider", e10);
            return null;
        }
    }

    public boolean m() {
        JSONObject jSONObject = this.f42454j1;
        return (((((jSONObject != null) && !jSONObject.has("error")) && this.f42439e1 != null) && this.f42442f1 != null) && this.f42445g1 != null) && l();
    }

    public String toString() {
        JSONObject jSONObject = new JSONObject();
        try {
            jSONObject.put("appKey", this.f42448h1);
            jSONObject.put("userId", this.f42451i1);
            jSONObject.put("response", this.f42454j1);
        } catch (JSONException e10) {
            e10.printStackTrace();
        }
        return jSONObject.toString();
    }
}