package defpackage;

import android.os.Build;
import android.util.Log;
import androidx.credentials.exceptions.publickeycredential.DomExceptionUtils;
import androidx.media3.container.NalUnitUtil;
import androidx.media3.exoplayer.upstream.CmcdData;
import defpackage.pn4;
import java.util.Arrays;
import java.util.Map;
import kotlin.Metadata;
import kotlin.coroutines.Continuation;
import kotlin.coroutines.jvm.internal.ContinuationImpl;

/* JADX INFO: loaded from: classes2.dex */
@Metadata(d1 = {"\u0000\f\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\b\u0000\u0018\u00002\u00020\u0001:\u0001\u0002¨\u0006\u0003"}, d2 = {"Lby7;", "Lao8;", CmcdData.OBJECT_TYPE_AUDIO_ONLY, "com.google.firebase-firebase-sessions"}, k = 1, mv = {1, 8, 0}, xi = NalUnitUtil.H265_NAL_UNIT_TYPE_UNSPECIFIED)
@vx8
public final class by7 implements ao8 {
    public final gj1 a;
    public final m13 b;
    public final hy7 c;
    public final j65 d;
    public final ng6 e = rg6.a();

    @Metadata(d1 = {"\u0000\u0010\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\u0010\u000e\n\u0002\b\u0004\b\u0082\u0003\u0018\u00002\u00020\u0001R\u0014\u0010\u0003\u001a\u00020\u00028\u0006X\u0086T¢\u0006\u0006\n\u0004\b\u0003\u0010\u0004R\u0014\u0010\u0005\u001a\u00020\u00028\u0006X\u0086T¢\u0006\u0006\n\u0004\b\u0005\u0010\u0004¨\u0006\u0006"}, d2 = {"Lby7$a;", "", "", "FORWARD_SLASH_STRING", "Ljava/lang/String;", "TAG", "com.google.firebase-firebase-sessions"}, k = 1, mv = {1, 8, 0}, xi = NalUnitUtil.H265_NAL_UNIT_TYPE_UNSPECIFIED)
    public static final class a {
    }

    public by7(gj1 gj1Var, m13 m13Var, zq zqVar, hy7 hy7Var, br1 br1Var) {
        this.a = gj1Var;
        this.b = m13Var;
        this.c = hy7Var;
        this.d = v65.a(new dy7(br1Var));
    }

    public final Boolean a() {
        gk8 gk8Var = b().b;
        if (gk8Var != null) {
            return gk8Var.a;
        }
        cr4.n("sessionConfigs");
        throw null;
    }

    public final ln8 b() {
        return (ln8) this.d.getValue();
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Removed duplicated region for block: B:44:0x00b2 A[Catch: all -> 0x0054, TRY_LEAVE, TryCatch #0 {all -> 0x0054, blocks: (B:21:0x0050, B:42:0x00a8, B:44:0x00b2, B:47:0x00bd, B:35:0x0088, B:39:0x0096), top: B:58:0x002e }] */
    /* JADX WARN: Removed duplicated region for block: B:47:0x00bd A[Catch: all -> 0x0054, TRY_ENTER, TRY_LEAVE, TryCatch #0 {all -> 0x0054, blocks: (B:21:0x0050, B:42:0x00a8, B:44:0x00b2, B:47:0x00bd, B:35:0x0088, B:39:0x0096), top: B:58:0x002e }] */
    /* JADX WARN: Removed duplicated region for block: B:7:0x001b  */
    /* JADX WARN: Type inference failed for: r6v0, types: [int] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object c(Continuation continuation) throws Throwable {
        ey7 ey7Var;
        mg6 mg6Var;
        mg6 mg6Var2;
        by7 by7Var;
        String str;
        mg6 mg6Var3;
        if (continuation instanceof ey7) {
            ey7Var = (ey7) continuation;
            int i = ey7Var.e;
            if ((i & Integer.MIN_VALUE) != 0) {
                ey7Var.e = i - Integer.MIN_VALUE;
            } else {
                ey7Var = new ey7(this, (ContinuationImpl) continuation);
            }
        }
        Object objA = ey7Var.c;
        ck1 ck1Var = ck1.a;
        ?? r6 = ey7Var.e;
        e6a e6aVar = e6a.a;
        try {
            if (r6 == 0) {
                s38.b(objA);
                ng6 ng6Var = this.e;
                if (!ng6Var.e() && !b().b()) {
                    return e6aVar;
                }
                ey7Var.a = this;
                ey7Var.b = ng6Var;
                ey7Var.e = 1;
                if (ng6Var.a(ey7Var) != ck1Var) {
                    mg6Var2 = ng6Var;
                    by7Var = this;
                }
                return ck1Var;
            }
            if (r6 != 1) {
                if (r6 != 2) {
                    if (r6 != 3) {
                        throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                    }
                    mg6Var = (mg6) ey7Var.a;
                    try {
                        s38.b(objA);
                        mg6Var3 = mg6Var;
                        mg6Var3.c(null);
                        return e6aVar;
                    } catch (Throwable th) {
                        th = th;
                        mg6Var.c(null);
                        throw th;
                    }
                }
                mg6Var2 = ey7Var.b;
                by7Var = (by7) ey7Var.a;
                s38.b(objA);
                str = ((pn4) objA).a;
                if (!str.equals("")) {
                    Log.w("SessionConfigFetcher", "Error getting Firebase Installation ID. Skipping this Session Event.");
                    mg6Var2.c(null);
                    return e6aVar;
                }
                q07 q07Var = new q07("X-Crashlytics-Installation-ID", str);
                String str2 = String.format("%s/%s", Arrays.copyOf(new Object[]{Build.MANUFACTURER, Build.MODEL}, 2));
                by7Var.getClass();
                q07 q07Var2 = new q07("X-Crashlytics-Device-Model", new pw7(DomExceptionUtils.SEPARATOR).f("", str2));
                String str3 = Build.VERSION.INCREMENTAL;
                cr4.f(str3, "INCREMENTAL");
                q07 q07Var3 = new q07("X-Crashlytics-OS-Build-Version", new pw7(DomExceptionUtils.SEPARATOR).f("", str3));
                String str4 = Build.VERSION.RELEASE;
                cr4.f(str4, "RELEASE");
                Map mapJ = wo5.j(q07Var, q07Var2, q07Var3, new q07("X-Crashlytics-OS-Display-Version", new pw7(DomExceptionUtils.SEPARATOR).f("", str4)), new q07("X-Crashlytics-API-Client-Version", "2.0.7"));
                hy7 hy7Var = by7Var.c;
                fy7 fy7Var = new fy7(by7Var, null);
                gy7 gy7Var = new gy7(2, null);
                ey7Var.a = mg6Var2;
                ey7Var.b = null;
                ey7Var.e = 3;
                Object objF = wj0.f(hy7Var.b, new iy7(hy7Var, mapJ, fy7Var, gy7Var, null), ey7Var);
                if (objF != ck1Var) {
                    objF = e6aVar;
                }
                if (objF != ck1Var) {
                    mg6Var3 = mg6Var2;
                    mg6Var3.c(null);
                    return e6aVar;
                }
                return ck1Var;
            }
            mg6Var2 = ey7Var.b;
            by7Var = (by7) ey7Var.a;
            s38.b(objA);
            if (!by7Var.b().b()) {
                mg6Var2.c(null);
                return e6aVar;
            }
            pn4.a aVar = pn4.c;
            m13 m13Var = by7Var.b;
            ey7Var.a = by7Var;
            ey7Var.b = mg6Var2;
            ey7Var.e = 2;
            objA = aVar.a(m13Var, ey7Var);
            if (objA != ck1Var) {
                str = ((pn4) objA).a;
                if (!str.equals("")) {
                }
            }
            return ck1Var;
        } catch (Throwable th2) {
            th = th2;
            mg6Var = r6;
        }
    }
}
