package o;

import android.view.View;
import android.view.ViewGroup;
import androidx.constraintlayout.widget.ConstraintLayout;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* renamed from: o.Gl, reason: case insensitive filesystem */
/* loaded from: classes.dex */
public final class C0167Gl {
    public final ConstraintLayout a;
    public int b;
    public int c;
    public int d;
    public int e;
    public int f;
    public int g;
    public final /* synthetic */ ConstraintLayout h;

    public C0167Gl(ConstraintLayout constraintLayout, ConstraintLayout constraintLayout2) {
        this.h = constraintLayout;
        this.a = constraintLayout2;
    }

    public static boolean a(int i, int i2, int i3) {
        if (i == i2) {
            return true;
        }
        int mode = View.MeasureSpec.getMode(i);
        int mode2 = View.MeasureSpec.getMode(i2);
        int size = View.MeasureSpec.getSize(i2);
        if (mode2 == 1073741824) {
            return (mode == Integer.MIN_VALUE || mode == 0) && i3 == size;
        }
        return false;
    }

    public final void b(C0530Ul c0530Ul, C1778ld c1778ld) {
        int iMakeMeasureSpec;
        int iMakeMeasureSpec2;
        int iMax;
        boolean z;
        int measuredWidth;
        int baseline;
        int i;
        if (c0530Ul == null) {
            return;
        }
        C3123zl c3123zl = c0530Ul.K;
        C3123zl c3123zl2 = c0530Ul.I;
        if (c0530Ul.g0 == 8) {
            c1778ld.e = 0;
            c1778ld.f = 0;
            c1778ld.g = 0;
            return;
        }
        if (c0530Ul.T == null) {
            return;
        }
        C2787w80 c2787w80 = ConstraintLayout.A;
        int i2 = c1778ld.a;
        int i3 = c1778ld.b;
        int i4 = c1778ld.c;
        int i5 = c1778ld.d;
        int i6 = this.b + this.c;
        int i7 = this.d;
        View view = c0530Ul.f0;
        int iW = AbstractC2462sn.w(i2);
        if (iW == 0) {
            iMakeMeasureSpec = View.MeasureSpec.makeMeasureSpec(i4, 1073741824);
        } else if (iW == 1) {
            iMakeMeasureSpec = ViewGroup.getChildMeasureSpec(this.f, i7, -2);
        } else if (iW == 2) {
            iMakeMeasureSpec = ViewGroup.getChildMeasureSpec(this.f, i7, -2);
            boolean z2 = c0530Ul.r == 1;
            int i8 = c1778ld.j;
            if (i8 == 1 || i8 == 2) {
                boolean z3 = view.getMeasuredHeight() == c0530Ul.k();
                if (c1778ld.j == 2 || !z2 || ((z2 && z3) || c0530Ul.A())) {
                    iMakeMeasureSpec = View.MeasureSpec.makeMeasureSpec(c0530Ul.q(), 1073741824);
                }
            }
        } else if (iW != 3) {
            iMakeMeasureSpec = 0;
        } else {
            int i9 = this.f;
            int i10 = c3123zl2 != null ? c3123zl2.g : 0;
            if (c3123zl != null) {
                i10 += c3123zl.g;
            }
            iMakeMeasureSpec = ViewGroup.getChildMeasureSpec(i9, i7 + i10, -1);
        }
        int iW2 = AbstractC2462sn.w(i3);
        if (iW2 == 0) {
            iMakeMeasureSpec2 = View.MeasureSpec.makeMeasureSpec(i5, 1073741824);
        } else if (iW2 == 1) {
            iMakeMeasureSpec2 = ViewGroup.getChildMeasureSpec(this.g, i6, -2);
        } else if (iW2 == 2) {
            iMakeMeasureSpec2 = ViewGroup.getChildMeasureSpec(this.g, i6, -2);
            boolean z4 = c0530Ul.s == 1;
            int i11 = c1778ld.j;
            if (i11 == 1 || i11 == 2) {
                boolean z5 = view.getMeasuredWidth() == c0530Ul.q();
                if (c1778ld.j == 2 || !z4 || ((z4 && z5) || c0530Ul.B())) {
                    iMakeMeasureSpec2 = View.MeasureSpec.makeMeasureSpec(c0530Ul.k(), 1073741824);
                }
            }
        } else if (iW2 != 3) {
            iMakeMeasureSpec2 = 0;
        } else {
            int i12 = this.g;
            int i13 = c3123zl2 != null ? c0530Ul.J.g : 0;
            if (c3123zl != null) {
                i13 += c0530Ul.L.g;
            }
            iMakeMeasureSpec2 = ViewGroup.getChildMeasureSpec(i12, i6 + i13, -1);
        }
        C0556Vl c0556Vl = (C0556Vl) c0530Ul.T;
        ConstraintLayout constraintLayout = this.h;
        if (c0556Vl != null && AbstractC2539te.z(constraintLayout.t, 256) && view.getMeasuredWidth() == c0530Ul.q() && view.getMeasuredWidth() < c0556Vl.q() && view.getMeasuredHeight() == c0530Ul.k() && view.getMeasuredHeight() < c0556Vl.k() && view.getBaseline() == c0530Ul.a0 && !c0530Ul.z() && a(c0530Ul.G, iMakeMeasureSpec, c0530Ul.q()) && a(c0530Ul.H, iMakeMeasureSpec2, c0530Ul.k())) {
            c1778ld.e = c0530Ul.q();
            c1778ld.f = c0530Ul.k();
            c1778ld.g = c0530Ul.a0;
            return;
        }
        boolean z6 = i2 == 3;
        boolean z7 = i3 == 3;
        boolean z8 = i3 == 4 || i3 == 1;
        boolean z9 = i2 == 4 || i2 == 1;
        boolean z10 = z6 && c0530Ul.W > 0.0f;
        boolean z11 = z7 && c0530Ul.W > 0.0f;
        if (view == null) {
            return;
        }
        C0141Fl c0141Fl = (C0141Fl) view.getLayoutParams();
        int i14 = c1778ld.j;
        if (i14 != 1 && i14 != 2 && z6 && c0530Ul.r == 0 && z7 && c0530Ul.s == 0) {
            z = false;
            measuredWidth = 0;
            baseline = 0;
            i = -1;
            iMax = 0;
        } else {
            if ((view instanceof Bk0) && (c0530Ul instanceof C2199pz)) {
                ((Bk0) view).j((C2199pz) c0530Ul, iMakeMeasureSpec, iMakeMeasureSpec2);
            } else {
                view.measure(iMakeMeasureSpec, iMakeMeasureSpec2);
            }
            c0530Ul.G = iMakeMeasureSpec;
            c0530Ul.H = iMakeMeasureSpec2;
            c0530Ul.g = false;
            int measuredWidth2 = view.getMeasuredWidth();
            int measuredHeight = view.getMeasuredHeight();
            int baseline2 = view.getBaseline();
            int i15 = c0530Ul.u;
            int iMax2 = i15 > 0 ? Math.max(i15, measuredWidth2) : measuredWidth2;
            int i16 = c0530Ul.v;
            if (i16 > 0) {
                iMax2 = Math.min(i16, iMax2);
            }
            int i17 = c0530Ul.x;
            iMax = i17 > 0 ? Math.max(i17, measuredHeight) : measuredHeight;
            int i18 = iMakeMeasureSpec2;
            int i19 = c0530Ul.y;
            if (i19 > 0) {
                iMax = Math.min(i19, iMax);
            }
            if (!AbstractC2539te.z(constraintLayout.t, 1)) {
                if (z10 && z8) {
                    iMax2 = (int) ((iMax * c0530Ul.W) + 0.5f);
                } else if (z11 && z9) {
                    iMax = (int) ((iMax2 / c0530Ul.W) + 0.5f);
                }
            }
            if (measuredWidth2 == iMax2 && measuredHeight == iMax) {
                baseline = baseline2;
                measuredWidth = iMax2;
                z = false;
            } else {
                if (measuredWidth2 != iMax2) {
                    iMakeMeasureSpec = View.MeasureSpec.makeMeasureSpec(iMax2, 1073741824);
                }
                int iMakeMeasureSpec3 = measuredHeight != iMax ? View.MeasureSpec.makeMeasureSpec(iMax, 1073741824) : i18;
                view.measure(iMakeMeasureSpec, iMakeMeasureSpec3);
                c0530Ul.G = iMakeMeasureSpec;
                c0530Ul.H = iMakeMeasureSpec3;
                z = false;
                c0530Ul.g = false;
                measuredWidth = view.getMeasuredWidth();
                int measuredHeight2 = view.getMeasuredHeight();
                baseline = view.getBaseline();
                iMax = measuredHeight2;
            }
            i = -1;
        }
        boolean z12 = baseline != i ? true : z;
        c1778ld.i = (measuredWidth == c1778ld.c && iMax == c1778ld.d) ? z : true;
        boolean z13 = c0141Fl.c0 ? true : z12;
        if (z13 && baseline != -1 && c0530Ul.a0 != baseline) {
            c1778ld.i = true;
        }
        c1778ld.e = measuredWidth;
        c1778ld.f = iMax;
        c1778ld.h = z13;
        c1778ld.g = baseline;
    }
}
