package U4;

import O6.p;
import a0.C0393g;
import android.util.Log;
import com.google.android.gms.internal.measurement.C1;
import n4.u0;
import org.json.JSONException;
import org.json.JSONObject;

/* JADX INFO: loaded from: classes.dex */
public final class c extends G6.i implements p {

    /* JADX INFO: renamed from: u, reason: collision with root package name */
    public P6.m f6726u;

    /* JADX INFO: renamed from: v, reason: collision with root package name */
    public P6.m f6727v;

    /* JADX INFO: renamed from: w, reason: collision with root package name */
    public int f6728w;

    /* JADX INFO: renamed from: x, reason: collision with root package name */
    public /* synthetic */ Object f6729x;

    /* JADX INFO: renamed from: y, reason: collision with root package name */
    public final /* synthetic */ e f6730y;

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public c(e eVar, E6.d dVar) {
        super(2, dVar);
        this.f6730y = eVar;
    }

    @Override // O6.p
    public final Object k(Object obj, Object obj2) {
        return ((c) m((E6.d) obj2, (JSONObject) obj)).p(A6.n.f457a);
    }

    @Override // G6.a
    public final E6.d m(E6.d dVar, Object obj) {
        c cVar = new c(this.f6730y, dVar);
        cVar.f6729x = obj;
        return cVar;
    }

    /* JADX WARN: Code restructure failed: missing block: B:69:0x015f, code lost:
    
        if (r0 == r5) goto L85;
     */
    /* JADX WARN: Removed duplicated region for block: B:49:0x00fc  */
    /* JADX WARN: Removed duplicated region for block: B:55:0x011b A[PHI: r0 r2
      0x011b: PHI (r0v15 P6.m) = (r0v12 P6.m), (r0v12 P6.m), (r0v16 P6.m) binds: [B:48:0x00fa, B:53:0x0117, B:11:0x0037] A[DONT_GENERATE, DONT_INLINE]
      0x011b: PHI (r2v13 P6.m) = (r2v9 P6.m), (r2v9 P6.m), (r2v20 P6.m) binds: [B:48:0x00fa, B:53:0x0117, B:11:0x0037] A[DONT_GENERATE, DONT_INLINE]] */
    /* JADX WARN: Removed duplicated region for block: B:57:0x0121  */
    /* JADX WARN: Removed duplicated region for block: B:63:0x0140 A[PHI: r0
      0x0140: PHI (r0v17 P6.m) = (r0v15 P6.m), (r0v15 P6.m), (r0v25 P6.m) binds: [B:56:0x011f, B:61:0x013c, B:10:0x002e] A[DONT_GENERATE, DONT_INLINE]] */
    /* JADX WARN: Removed duplicated region for block: B:65:0x0146  */
    /* JADX WARN: Removed duplicated region for block: B:72:0x0164  */
    /* JADX WARN: Removed duplicated region for block: B:74:0x0167  */
    /* JADX WARN: Removed duplicated region for block: B:80:0x0187  */
    /* JADX WARN: Removed duplicated region for block: B:83:0x01a6  */
    /* JADX WARN: Removed duplicated region for block: B:86:0x01aa A[RETURN] */
    @Override // G6.a
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object p(Object obj) throws Throwable {
        P6.m mVar;
        Boolean bool;
        P6.m mVar2;
        P6.m mVar3;
        P6.m mVar4;
        P6.m mVar5;
        A6.n nVar;
        Object objC;
        F6.a aVar = F6.a.f2580q;
        int i = this.f6728w;
        A6.n nVar2 = A6.n.f457a;
        e eVar = this.f6730y;
        C0393g c0393g = n.f6768f;
        switch (i) {
            case u0.f15495q /* 0 */:
                C1.N(obj);
                JSONObject jSONObject = (JSONObject) this.f6729x;
                Log.d("SessionConfigFetcher", "Fetched settings: " + jSONObject);
                P6.m mVar6 = new P6.m();
                mVar = new P6.m();
                P6.m mVar7 = new P6.m();
                if (jSONObject.has("app_quality")) {
                    Object obj2 = jSONObject.get("app_quality");
                    P6.g.c(obj2, "null cannot be cast to non-null type org.json.JSONObject");
                    JSONObject jSONObject2 = (JSONObject) obj2;
                    try {
                        bool = jSONObject2.has("sessions_enabled") ? (Boolean) jSONObject2.get("sessions_enabled") : null;
                    } catch (JSONException e8) {
                        e = e8;
                        bool = null;
                    }
                    try {
                        if (jSONObject2.has("sampling_rate")) {
                            mVar6.f5535q = (Double) jSONObject2.get("sampling_rate");
                        }
                        if (jSONObject2.has("session_timeout_seconds")) {
                            mVar.f5535q = (Integer) jSONObject2.get("session_timeout_seconds");
                        }
                        if (jSONObject2.has("cache_duration")) {
                            mVar7.f5535q = (Integer) jSONObject2.get("cache_duration");
                        }
                    } catch (JSONException e9) {
                        e = e9;
                        Log.e("SessionConfigFetcher", "Error parsing the configs remotely fetched: ", e);
                    }
                    break;
                } else {
                    bool = null;
                }
                if (bool == null) {
                    mVar2 = mVar6;
                    mVar3 = mVar7;
                    if (((Integer) mVar.f5535q) != null) {
                    }
                    return aVar;
                }
                n nVarE = eVar.e();
                this.f6729x = mVar6;
                this.f6726u = mVar;
                this.f6727v = mVar7;
                this.f6728w = 1;
                Object objC2 = nVarE.c(n.f6765c, bool, this);
                if (objC2 != aVar) {
                    objC2 = nVar2;
                }
                if (objC2 != aVar) {
                    mVar4 = mVar6;
                    mVar5 = mVar;
                    mVar3 = mVar7;
                    mVar = mVar5;
                    mVar2 = mVar4;
                    if (((Integer) mVar.f5535q) != null) {
                        n nVarE2 = eVar.e();
                        Integer num = (Integer) mVar.f5535q;
                        this.f6729x = mVar2;
                        this.f6726u = mVar3;
                        this.f6727v = null;
                        this.f6728w = 2;
                        Object objC3 = nVarE2.c(n.f6767e, num, this);
                        if (objC3 != aVar) {
                            objC3 = nVar2;
                        }
                        if (objC3 != aVar) {
                            if (((Double) mVar2.f5535q) == null) {
                                n nVarE3 = eVar.e();
                                Double d8 = (Double) mVar2.f5535q;
                                this.f6729x = mVar3;
                                this.f6726u = null;
                                this.f6727v = null;
                                this.f6728w = 3;
                                Object objC4 = nVarE3.c(n.f6766d, d8, this);
                                if (objC4 != aVar) {
                                    objC4 = nVar2;
                                }
                                if (objC4 != aVar) {
                                    if (((Integer) mVar3.f5535q) == null) {
                                        n nVarE4 = eVar.e();
                                        Integer num2 = (Integer) mVar3.f5535q;
                                        this.f6729x = null;
                                        this.f6726u = null;
                                        this.f6727v = null;
                                        this.f6728w = 4;
                                        Object objC5 = nVarE4.c(c0393g, num2, this);
                                        if (objC5 != aVar) {
                                            objC5 = nVar2;
                                        }
                                        break;
                                    } else {
                                        nVar = null;
                                        if (nVar != null) {
                                            n nVarE5 = eVar.e();
                                            Integer num3 = new Integer(86400);
                                            this.f6729x = null;
                                            this.f6726u = null;
                                            this.f6727v = null;
                                            this.f6728w = 5;
                                            Object objC6 = nVarE5.c(c0393g, num3, this);
                                            if (objC6 != aVar) {
                                                objC6 = nVar2;
                                            }
                                            if (objC6 != aVar) {
                                                n nVarE6 = eVar.e();
                                                Long l8 = new Long(System.currentTimeMillis());
                                                this.f6729x = null;
                                                this.f6726u = null;
                                                this.f6727v = null;
                                                this.f6728w = 6;
                                                objC = nVarE6.c(n.f6769g, l8, this);
                                                if (objC != aVar) {
                                                    objC = nVar2;
                                                }
                                                if (objC != aVar) {
                                                    return nVar2;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                return aVar;
            case 1:
                mVar3 = this.f6727v;
                mVar5 = this.f6726u;
                mVar4 = (P6.m) this.f6729x;
                C1.N(obj);
                mVar = mVar5;
                mVar2 = mVar4;
                if (((Integer) mVar.f5535q) != null) {
                }
                return aVar;
            case 2:
                mVar3 = this.f6726u;
                mVar2 = (P6.m) this.f6729x;
                C1.N(obj);
                if (((Double) mVar2.f5535q) == null) {
                }
                return aVar;
            case 3:
                mVar3 = (P6.m) this.f6729x;
                C1.N(obj);
                if (((Integer) mVar3.f5535q) == null) {
                }
                break;
            case 4:
                C1.N(obj);
                nVar = nVar2;
                if (nVar != null) {
                }
                return aVar;
            case 5:
                C1.N(obj);
                n nVarE62 = eVar.e();
                Long l82 = new Long(System.currentTimeMillis());
                this.f6729x = null;
                this.f6726u = null;
                this.f6727v = null;
                this.f6728w = 6;
                objC = nVarE62.c(n.f6769g, l82, this);
                if (objC != aVar) {
                }
                if (objC != aVar) {
                    return aVar;
                }
                break;
            case Z.g.STRING_SET_FIELD_NUMBER /* 6 */:
                C1.N(obj);
                return nVar2;
            default:
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
        }
    }
}
