package n1;

import C4.f;
import Z0.o;
import com.google.firebase.crashlytics.internal.common.IdManager;
import java.util.ArrayList;

/* JADX INFO: renamed from: n1.b, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes.dex */
public class C2608b {

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final C2607a f21574d;

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public e f21571a = null;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public float f21572b = 0.0f;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final ArrayList f21573c = new ArrayList();

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public boolean f21575e = false;

    public C2608b(f fVar) {
        this.f21574d = new C2607a(this, fVar);
    }

    public final void a(C2609c c2609c, int i6) {
        this.f21574d.g(c2609c.j(i6), 1.0f);
        this.f21574d.g(c2609c.j(i6), -1.0f);
    }

    public final void b(e eVar, e eVar2, e eVar3, int i6) {
        boolean z6 = false;
        if (i6 != 0) {
            if (i6 < 0) {
                i6 *= -1;
                z6 = true;
            }
            this.f21572b = i6;
        }
        if (z6) {
            this.f21574d.g(eVar, 1.0f);
            this.f21574d.g(eVar2, -1.0f);
            this.f21574d.g(eVar3, -1.0f);
        } else {
            this.f21574d.g(eVar, -1.0f);
            this.f21574d.g(eVar2, 1.0f);
            this.f21574d.g(eVar3, 1.0f);
        }
    }

    public final void c(e eVar, e eVar2, e eVar3, int i6) {
        boolean z6 = false;
        if (i6 != 0) {
            if (i6 < 0) {
                i6 *= -1;
                z6 = true;
            }
            this.f21572b = i6;
        }
        if (z6) {
            this.f21574d.g(eVar, 1.0f);
            this.f21574d.g(eVar2, -1.0f);
            this.f21574d.g(eVar3, 1.0f);
        } else {
            this.f21574d.g(eVar, -1.0f);
            this.f21574d.g(eVar2, 1.0f);
            this.f21574d.g(eVar3, -1.0f);
        }
    }

    public e d(boolean[] zArr) {
        return f(zArr, null);
    }

    public boolean e() {
        return this.f21571a == null && this.f21572b == 0.0f && this.f21574d.d() == 0;
    }

    public final e f(boolean[] zArr, e eVar) {
        int i6;
        int iD = this.f21574d.d();
        e eVar2 = null;
        float f6 = 0.0f;
        for (int i7 = 0; i7 < iD; i7++) {
            float f7 = this.f21574d.f(i7);
            if (f7 < 0.0f) {
                e eVarE = this.f21574d.e(i7);
                if ((zArr == null || !zArr[eVarE.f21597b]) && eVarE != eVar && (((i6 = eVarE.f21606o) == 3 || i6 == 4) && f7 < f6)) {
                    f6 = f7;
                    eVar2 = eVarE;
                }
            }
        }
        return eVar2;
    }

    public final void g(e eVar) {
        e eVar2 = this.f21571a;
        if (eVar2 != null) {
            this.f21574d.g(eVar2, -1.0f);
            this.f21571a.f21598c = -1;
            this.f21571a = null;
        }
        float fH = this.f21574d.h(eVar, true) * (-1.0f);
        this.f21571a = eVar;
        if (fH == 1.0f) {
            return;
        }
        this.f21572b /= fH;
        C2607a c2607a = this.f21574d;
        int i6 = c2607a.f21568h;
        for (int i7 = 0; i6 != -1 && i7 < c2607a.f21561a; i7++) {
            float[] fArr = c2607a.f21567g;
            fArr[i6] = fArr[i6] / fH;
            i6 = c2607a.f21566f[i6];
        }
    }

    public final void h(C2609c c2609c, e eVar, boolean z6) {
        if (eVar == null || !eVar.f21601f) {
            return;
        }
        float fC = this.f21574d.c(eVar);
        this.f21572b = (eVar.f21600e * fC) + this.f21572b;
        this.f21574d.h(eVar, z6);
        if (z6) {
            eVar.b(this);
        }
        if (this.f21574d.d() == 0) {
            this.f21575e = true;
            c2609c.f21578b = true;
        }
    }

    public void i(C2609c c2609c, C2608b c2608b, boolean z6) {
        C2607a c2607a = this.f21574d;
        c2607a.getClass();
        float fC = c2607a.c(c2608b.f21571a);
        c2607a.h(c2608b.f21571a, z6);
        C2607a c2607a2 = c2608b.f21574d;
        int iD = c2607a2.d();
        for (int i6 = 0; i6 < iD; i6++) {
            e eVarE = c2607a2.e(i6);
            c2607a.a(eVarE, c2607a2.c(eVarE) * fC, z6);
        }
        this.f21572b = (c2608b.f21572b * fC) + this.f21572b;
        if (z6) {
            c2608b.f21571a.b(this);
        }
        if (this.f21571a == null || this.f21574d.d() != 0) {
            return;
        }
        this.f21575e = true;
        c2609c.f21578b = true;
    }

    /* JADX WARN: Removed duplicated region for block: B:29:0x007c  */
    /* JADX WARN: Removed duplicated region for block: B:30:0x0081  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public String toString() {
        boolean z6;
        String strN = o.n(this.f21571a == null ? "0" : "" + this.f21571a, " = ");
        if (this.f21572b != 0.0f) {
            StringBuilder sbT = o.t(strN);
            sbT.append(this.f21572b);
            strN = sbT.toString();
            z6 = true;
        } else {
            z6 = false;
        }
        int iD = this.f21574d.d();
        for (int i6 = 0; i6 < iD; i6++) {
            e eVarE = this.f21574d.e(i6);
            if (eVarE != null) {
                float f6 = this.f21574d.f(i6);
                if (f6 != 0.0f) {
                    String string = eVarE.toString();
                    if (!z6) {
                        if (f6 < 0.0f) {
                            strN = o.n(strN, "- ");
                            f6 *= -1.0f;
                        }
                        strN = f6 == 1.0f ? o.n(strN, string) : strN + f6 + " " + string;
                        z6 = true;
                    } else if (f6 > 0.0f) {
                        strN = o.n(strN, " + ");
                        if (f6 == 1.0f) {
                        }
                        z6 = true;
                    } else {
                        strN = o.n(strN, " - ");
                        f6 *= -1.0f;
                        if (f6 == 1.0f) {
                        }
                        z6 = true;
                    }
                }
            }
        }
        return !z6 ? o.n(strN, IdManager.DEFAULT_VERSION_NAME) : strN;
    }
}
