package k;

import java.util.ArrayList;
import k.d;
import k.i;

/* JADX INFO: compiled from: ArrayRow.java */
/* JADX INFO: loaded from: classes.dex */
public class b implements d.a {

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    boolean f5090c;

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

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    i f5088a = null;

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

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    ArrayList<i> f5091d = new ArrayList<>();

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    boolean f5093f = false;

    /* JADX INFO: compiled from: ArrayRow.java */
    public interface a {
        float a(int i3);

        float b(i iVar);

        float c(b bVar, boolean z2);

        void clear();

        void d(i iVar, float f3);

        i e(int i3);

        void f(i iVar, float f3, boolean z2);

        void g(float f3);

        float h(i iVar, boolean z2);

        boolean i(i iVar);

        void j();

        int k();
    }

    public b() {
    }

    private boolean u(i iVar, d dVar) {
        return iVar.f5146q <= 1;
    }

    private i w(boolean[] zArr, i iVar) {
        i.a aVar;
        int iK = this.f5092e.k();
        i iVar2 = null;
        float f3 = 0.0f;
        for (int i3 = 0; i3 < iK; i3++) {
            float fA = this.f5092e.a(i3);
            if (fA < 0.0f) {
                i iVarE = this.f5092e.e(i3);
                if ((zArr == null || !zArr[iVarE.f5136g]) && iVarE != iVar && (((aVar = iVarE.f5143n) == i.a.SLACK || aVar == i.a.ERROR) && fA < f3)) {
                    f3 = fA;
                    iVar2 = iVarE;
                }
            }
        }
        return iVar2;
    }

    public void A(d dVar, i iVar, boolean z2) {
        if (iVar == null || !iVar.f5140k) {
            return;
        }
        this.f5089b += iVar.f5139j * this.f5092e.b(iVar);
        this.f5092e.h(iVar, z2);
        if (z2) {
            iVar.d(this);
        }
        if (d.f5100t && this.f5092e.k() == 0) {
            this.f5093f = true;
            dVar.f5107a = true;
        }
    }

    public void B(d dVar, b bVar, boolean z2) {
        this.f5089b += bVar.f5089b * this.f5092e.c(bVar, z2);
        if (z2) {
            bVar.f5088a.d(this);
        }
        if (d.f5100t && this.f5088a != null && this.f5092e.k() == 0) {
            this.f5093f = true;
            dVar.f5107a = true;
        }
    }

    public void C(d dVar, i iVar, boolean z2) {
        if (iVar == null || !iVar.f5147r) {
            return;
        }
        float fB = this.f5092e.b(iVar);
        this.f5089b += iVar.f5149t * fB;
        this.f5092e.h(iVar, z2);
        if (z2) {
            iVar.d(this);
        }
        this.f5092e.f(dVar.f5120n.f5097d[iVar.f5148s], fB, z2);
        if (d.f5100t && this.f5092e.k() == 0) {
            this.f5093f = true;
            dVar.f5107a = true;
        }
    }

    public void D(d dVar) {
        if (dVar.f5113g.length == 0) {
            return;
        }
        boolean z2 = false;
        while (!z2) {
            int iK = this.f5092e.k();
            for (int i3 = 0; i3 < iK; i3++) {
                i iVarE = this.f5092e.e(i3);
                if (iVarE.f5137h != -1 || iVarE.f5140k || iVarE.f5147r) {
                    this.f5091d.add(iVarE);
                }
            }
            int size = this.f5091d.size();
            if (size > 0) {
                for (int i4 = 0; i4 < size; i4++) {
                    i iVar = this.f5091d.get(i4);
                    if (iVar.f5140k) {
                        A(dVar, iVar, true);
                    } else if (iVar.f5147r) {
                        C(dVar, iVar, true);
                    } else {
                        B(dVar, dVar.f5113g[iVar.f5137h], true);
                    }
                }
                this.f5091d.clear();
            } else {
                z2 = true;
            }
        }
        if (d.f5100t && this.f5088a != null && this.f5092e.k() == 0) {
            this.f5093f = true;
            dVar.f5107a = true;
        }
    }

    @Override // k.d.a
    public i a(d dVar, boolean[] zArr) {
        return w(zArr, null);
    }

    @Override // k.d.a
    public void b(d.a aVar) {
        if (aVar instanceof b) {
            b bVar = (b) aVar;
            this.f5088a = null;
            this.f5092e.clear();
            for (int i3 = 0; i3 < bVar.f5092e.k(); i3++) {
                this.f5092e.f(bVar.f5092e.e(i3), bVar.f5092e.a(i3), true);
            }
        }
    }

    @Override // k.d.a
    public void c(i iVar) {
        int i3 = iVar.f5138i;
        float f3 = 1.0f;
        if (i3 != 1) {
            if (i3 == 2) {
                f3 = 1000.0f;
            } else if (i3 == 3) {
                f3 = 1000000.0f;
            } else if (i3 == 4) {
                f3 = 1.0E9f;
            } else if (i3 == 5) {
                f3 = 1.0E12f;
            }
        }
        this.f5092e.d(iVar, f3);
    }

    @Override // k.d.a
    public void clear() {
        this.f5092e.clear();
        this.f5088a = null;
        this.f5089b = 0.0f;
    }

    public b d(d dVar, int i3) {
        this.f5092e.d(dVar.o(i3, "ep"), 1.0f);
        this.f5092e.d(dVar.o(i3, "em"), -1.0f);
        return this;
    }

    b e(i iVar, int i3) {
        this.f5092e.d(iVar, i3);
        return this;
    }

    boolean f(d dVar) {
        boolean z2;
        i iVarG = g(dVar);
        if (iVarG == null) {
            z2 = true;
        } else {
            x(iVarG);
            z2 = false;
        }
        if (this.f5092e.k() == 0) {
            this.f5093f = true;
        }
        return z2;
    }

    i g(d dVar) {
        int iK = this.f5092e.k();
        i iVar = null;
        boolean z2 = false;
        boolean z3 = false;
        float f3 = 0.0f;
        float f4 = 0.0f;
        i iVar2 = null;
        for (int i3 = 0; i3 < iK; i3++) {
            float fA = this.f5092e.a(i3);
            i iVarE = this.f5092e.e(i3);
            if (iVarE.f5143n == i.a.UNRESTRICTED) {
                if (iVar == null || f3 > fA) {
                    boolean zU = u(iVarE, dVar);
                    z2 = zU;
                    f3 = fA;
                    iVar = iVarE;
                } else if (!z2 && u(iVarE, dVar)) {
                    f3 = fA;
                    iVar = iVarE;
                    z2 = true;
                }
            } else if (iVar == null && fA < 0.0f) {
                if (iVar2 == null || f4 > fA) {
                    boolean zU2 = u(iVarE, dVar);
                    z3 = zU2;
                    f4 = fA;
                    iVar2 = iVarE;
                } else if (!z3 && u(iVarE, dVar)) {
                    f4 = fA;
                    iVar2 = iVarE;
                    z3 = true;
                }
            }
        }
        return iVar != null ? iVar : iVar2;
    }

    @Override // k.d.a
    public i getKey() {
        return this.f5088a;
    }

    b h(i iVar, i iVar2, int i3, float f3, i iVar3, i iVar4, int i4) {
        if (iVar2 == iVar3) {
            this.f5092e.d(iVar, 1.0f);
            this.f5092e.d(iVar4, 1.0f);
            this.f5092e.d(iVar2, -2.0f);
            return this;
        }
        if (f3 == 0.5f) {
            this.f5092e.d(iVar, 1.0f);
            this.f5092e.d(iVar2, -1.0f);
            this.f5092e.d(iVar3, -1.0f);
            this.f5092e.d(iVar4, 1.0f);
            if (i3 > 0 || i4 > 0) {
                this.f5089b = (-i3) + i4;
            }
        } else if (f3 <= 0.0f) {
            this.f5092e.d(iVar, -1.0f);
            this.f5092e.d(iVar2, 1.0f);
            this.f5089b = i3;
        } else if (f3 >= 1.0f) {
            this.f5092e.d(iVar4, -1.0f);
            this.f5092e.d(iVar3, 1.0f);
            this.f5089b = -i4;
        } else {
            float f4 = 1.0f - f3;
            this.f5092e.d(iVar, f4 * 1.0f);
            this.f5092e.d(iVar2, f4 * (-1.0f));
            this.f5092e.d(iVar3, (-1.0f) * f3);
            this.f5092e.d(iVar4, 1.0f * f3);
            if (i3 > 0 || i4 > 0) {
                this.f5089b = ((-i3) * f4) + (i4 * f3);
            }
        }
        return this;
    }

    b i(i iVar, int i3) {
        this.f5088a = iVar;
        float f3 = i3;
        iVar.f5139j = f3;
        this.f5089b = f3;
        this.f5093f = true;
        return this;
    }

    @Override // k.d.a
    public boolean isEmpty() {
        return this.f5088a == null && this.f5089b == 0.0f && this.f5092e.k() == 0;
    }

    b j(i iVar, i iVar2, float f3) {
        this.f5092e.d(iVar, -1.0f);
        this.f5092e.d(iVar2, f3);
        return this;
    }

    public b k(i iVar, i iVar2, i iVar3, i iVar4, float f3) {
        this.f5092e.d(iVar, -1.0f);
        this.f5092e.d(iVar2, 1.0f);
        this.f5092e.d(iVar3, f3);
        this.f5092e.d(iVar4, -f3);
        return this;
    }

    public b l(float f3, float f4, float f5, i iVar, i iVar2, i iVar3, i iVar4) {
        this.f5089b = 0.0f;
        if (f4 == 0.0f || f3 == f5) {
            this.f5092e.d(iVar, 1.0f);
            this.f5092e.d(iVar2, -1.0f);
            this.f5092e.d(iVar4, 1.0f);
            this.f5092e.d(iVar3, -1.0f);
        } else if (f3 == 0.0f) {
            this.f5092e.d(iVar, 1.0f);
            this.f5092e.d(iVar2, -1.0f);
        } else if (f5 == 0.0f) {
            this.f5092e.d(iVar3, 1.0f);
            this.f5092e.d(iVar4, -1.0f);
        } else {
            float f6 = (f3 / f4) / (f5 / f4);
            this.f5092e.d(iVar, 1.0f);
            this.f5092e.d(iVar2, -1.0f);
            this.f5092e.d(iVar4, f6);
            this.f5092e.d(iVar3, -f6);
        }
        return this;
    }

    public b m(i iVar, int i3) {
        if (i3 < 0) {
            this.f5089b = i3 * (-1);
            this.f5092e.d(iVar, 1.0f);
        } else {
            this.f5089b = i3;
            this.f5092e.d(iVar, -1.0f);
        }
        return this;
    }

    public b n(i iVar, i iVar2, int i3) {
        boolean z2 = false;
        if (i3 != 0) {
            if (i3 < 0) {
                i3 *= -1;
                z2 = true;
            }
            this.f5089b = i3;
        }
        if (z2) {
            this.f5092e.d(iVar, 1.0f);
            this.f5092e.d(iVar2, -1.0f);
        } else {
            this.f5092e.d(iVar, -1.0f);
            this.f5092e.d(iVar2, 1.0f);
        }
        return this;
    }

    public b o(i iVar, i iVar2, i iVar3, int i3) {
        boolean z2 = false;
        if (i3 != 0) {
            if (i3 < 0) {
                i3 *= -1;
                z2 = true;
            }
            this.f5089b = i3;
        }
        if (z2) {
            this.f5092e.d(iVar, 1.0f);
            this.f5092e.d(iVar2, -1.0f);
            this.f5092e.d(iVar3, -1.0f);
        } else {
            this.f5092e.d(iVar, -1.0f);
            this.f5092e.d(iVar2, 1.0f);
            this.f5092e.d(iVar3, 1.0f);
        }
        return this;
    }

    public b p(i iVar, i iVar2, i iVar3, int i3) {
        boolean z2 = false;
        if (i3 != 0) {
            if (i3 < 0) {
                i3 *= -1;
                z2 = true;
            }
            this.f5089b = i3;
        }
        if (z2) {
            this.f5092e.d(iVar, 1.0f);
            this.f5092e.d(iVar2, -1.0f);
            this.f5092e.d(iVar3, 1.0f);
        } else {
            this.f5092e.d(iVar, -1.0f);
            this.f5092e.d(iVar2, 1.0f);
            this.f5092e.d(iVar3, -1.0f);
        }
        return this;
    }

    public b q(i iVar, i iVar2, i iVar3, i iVar4, float f3) {
        this.f5092e.d(iVar3, 0.5f);
        this.f5092e.d(iVar4, 0.5f);
        this.f5092e.d(iVar, -0.5f);
        this.f5092e.d(iVar2, -0.5f);
        this.f5089b = -f3;
        return this;
    }

    void r() {
        float f3 = this.f5089b;
        if (f3 < 0.0f) {
            this.f5089b = f3 * (-1.0f);
            this.f5092e.j();
        }
    }

    boolean s() {
        i iVar = this.f5088a;
        return iVar != null && (iVar.f5143n == i.a.UNRESTRICTED || this.f5089b >= 0.0f);
    }

    boolean t(i iVar) {
        return this.f5092e.i(iVar);
    }

    public String toString() {
        return z();
    }

    public i v(i iVar) {
        return w(null, iVar);
    }

    void x(i iVar) {
        i iVar2 = this.f5088a;
        if (iVar2 != null) {
            this.f5092e.d(iVar2, -1.0f);
            this.f5088a.f5137h = -1;
            this.f5088a = null;
        }
        float fH = this.f5092e.h(iVar, true) * (-1.0f);
        this.f5088a = iVar;
        if (fH == 1.0f) {
            return;
        }
        this.f5089b /= fH;
        this.f5092e.g(fH);
    }

    public void y() {
        this.f5088a = null;
        this.f5092e.clear();
        this.f5089b = 0.0f;
        this.f5093f = false;
    }

    /* JADX WARN: Removed duplicated region for block: B:29:0x00bf  */
    /* JADX WARN: Removed duplicated region for block: B:30:0x00cf  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    java.lang.String z() {
        /*
            Method dump skipped, instruction units count: 255
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: k.b.z():java.lang.String");
    }

    public b(c cVar) {
        this.f5092e = new k.a(this, cVar);
    }
}
