package android.support.constraint.i.j;

import android.support.constraint.i.j.e;

/* JADX INFO: compiled from: ResolutionAnchor.java */
/* JADX INFO: loaded from: classes.dex */
public class l extends n {

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

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    l f472d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    float f473e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    l f474f;
    float g;
    private l i;
    int h = 0;
    private m j = null;
    private int k = 1;
    private m l = null;
    private int m = 1;

    public l(e eVar) {
        this.f471c = eVar;
    }

    @Override // android.support.constraint.i.j.n
    public void e() {
        super.e();
        this.f472d = null;
        this.f473e = 0.0f;
        this.j = null;
        this.k = 1;
        this.l = null;
        this.m = 1;
        this.f474f = null;
        this.g = 0.0f;
        this.i = null;
        this.h = 0;
    }

    @Override // android.support.constraint.i.j.n
    public void f() {
        l lVar;
        l lVar2;
        l lVar3;
        l lVar4;
        l lVar5;
        l lVar6;
        float f2;
        float f3;
        float fD;
        float f4;
        l lVar7;
        boolean z = true;
        if (this.f477b == 1 || this.h == 4) {
            return;
        }
        m mVar = this.j;
        if (mVar != null) {
            if (mVar.f477b != 1) {
                return;
            } else {
                this.f473e = this.k * mVar.f475c;
            }
        }
        m mVar2 = this.l;
        if (mVar2 != null) {
            if (mVar2.f477b != 1) {
                return;
            } else {
                float f5 = mVar2.f475c;
            }
        }
        if (this.h == 1 && ((lVar7 = this.f472d) == null || lVar7.f477b == 1)) {
            l lVar8 = this.f472d;
            if (lVar8 == null) {
                this.f474f = this;
                this.g = this.f473e;
            } else {
                this.f474f = lVar8.f474f;
                this.g = lVar8.g + this.f473e;
            }
            b();
            return;
        }
        if (this.h != 2 || (lVar4 = this.f472d) == null || lVar4.f477b != 1 || (lVar5 = this.i) == null || (lVar6 = lVar5.f472d) == null || lVar6.f477b != 1) {
            if (this.h != 3 || (lVar = this.f472d) == null || lVar.f477b != 1 || (lVar2 = this.i) == null || (lVar3 = lVar2.f472d) == null || lVar3.f477b != 1) {
                if (this.h == 5) {
                    this.f471c.f449b.U();
                    return;
                }
                return;
            }
            if (android.support.constraint.i.e.x() != null) {
                android.support.constraint.i.e.x().w++;
            }
            l lVar9 = this.f472d;
            this.f474f = lVar9.f474f;
            l lVar10 = this.i;
            l lVar11 = lVar10.f472d;
            lVar10.f474f = lVar11.f474f;
            this.g = lVar9.g + this.f473e;
            lVar10.g = lVar11.g + lVar10.f473e;
            b();
            this.i.b();
            return;
        }
        if (android.support.constraint.i.e.x() != null) {
            android.support.constraint.i.e.x().v++;
        }
        this.f474f = this.f472d.f474f;
        l lVar12 = this.i;
        lVar12.f474f = lVar12.f472d.f474f;
        e.d dVar = this.f471c.f450c;
        int i = 0;
        if (dVar != e.d.RIGHT && dVar != e.d.BOTTOM) {
            z = false;
        }
        if (z) {
            f2 = this.f472d.g;
            f3 = this.i.f472d.g;
        } else {
            f2 = this.i.f472d.g;
            f3 = this.f472d.g;
        }
        float f6 = f2 - f3;
        e.d dVar2 = this.f471c.f450c;
        if (dVar2 == e.d.LEFT || dVar2 == e.d.RIGHT) {
            fD = f6 - this.f471c.f449b.D();
            f4 = this.f471c.f449b.V;
        } else {
            fD = f6 - r2.f449b.r();
            f4 = this.f471c.f449b.W;
        }
        int iD = this.f471c.d();
        int iD2 = this.i.f471c.d();
        if (this.f471c.i() == this.i.f471c.i()) {
            f4 = 0.5f;
            iD2 = 0;
        } else {
            i = iD;
        }
        float f7 = i;
        float f8 = iD2;
        float f9 = (fD - f7) - f8;
        if (z) {
            l lVar13 = this.i;
            lVar13.g = lVar13.f472d.g + f8 + (f9 * f4);
            this.g = (this.f472d.g - f7) - (f9 * (1.0f - f4));
        } else {
            this.g = this.f472d.g + f7 + (f9 * f4);
            l lVar14 = this.i;
            lVar14.g = (lVar14.f472d.g - f8) - (f9 * (1.0f - f4));
        }
        b();
        this.i.b();
    }

    void g(android.support.constraint.i.e eVar) {
        android.support.constraint.i.i iVarG = this.f471c.g();
        l lVar = this.f474f;
        if (lVar == null) {
            eVar.f(iVarG, (int) (this.g + 0.5f));
        } else {
            eVar.e(iVarG, eVar.r(lVar.f471c), (int) (this.g + 0.5f), 6);
        }
    }

    public void h(int i, l lVar, int i2) {
        this.h = i;
        this.f472d = lVar;
        this.f473e = i2;
        lVar.a(this);
    }

    public void i(l lVar, int i) {
        this.f472d = lVar;
        this.f473e = i;
        lVar.a(this);
    }

    public void j(l lVar, int i, m mVar) {
        this.f472d = lVar;
        lVar.a(this);
        this.j = mVar;
        this.k = i;
        mVar.a(this);
    }

    public float k() {
        return this.g;
    }

    public void l(l lVar, float f2) {
        if (this.f477b == 0 || !(this.f474f == lVar || this.g == f2)) {
            this.f474f = lVar;
            this.g = f2;
            if (this.f477b == 1) {
                c();
            }
            b();
        }
    }

    String m(int i) {
        return i == 1 ? "DIRECT" : i == 2 ? "CENTER" : i == 3 ? "MATCH" : i == 4 ? "CHAIN" : i == 5 ? "BARRIER" : "UNCONNECTED";
    }

    public void n(l lVar, float f2) {
        this.i = lVar;
    }

    public void o(l lVar, int i, m mVar) {
        this.i = lVar;
        this.l = mVar;
        this.m = i;
    }

    public void p(int i) {
        this.h = i;
    }

    public void q() {
        e eVarI = this.f471c.i();
        if (eVarI == null) {
            return;
        }
        if (eVarI.i() == this.f471c) {
            this.h = 4;
            eVarI.f().h = 4;
        }
        int iD = this.f471c.d();
        e.d dVar = this.f471c.f450c;
        if (dVar == e.d.RIGHT || dVar == e.d.BOTTOM) {
            iD = -iD;
        }
        i(eVarI.f(), iD);
    }

    public String toString() {
        if (this.f477b != 1) {
            return "{ " + this.f471c + " UNRESOLVED} type: " + m(this.h);
        }
        if (this.f474f == this) {
            return "[" + this.f471c + ", RESOLVED: " + this.g + "]  type: " + m(this.h);
        }
        return "[" + this.f471c + ", RESOLVED: " + this.f474f + ":" + this.g + "] type: " + m(this.h);
    }
}
