package w;

import androidx.constraintlayout.core.SolverVariable$Type;
import androidx.constraintlayout.core.widgets.ConstraintAnchor$Type;
import g7.z;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;

/* JADX INFO: loaded from: classes.dex */
public final class c {

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public int f34020b;

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

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

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public final ConstraintAnchor$Type f34023e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public c f34024f;

    /* JADX INFO: renamed from: i, reason: collision with root package name */
    public u.k f34027i;

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

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public int f34025g = 0;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public int f34026h = Integer.MIN_VALUE;

    public c(d dVar, ConstraintAnchor$Type constraintAnchor$Type) {
        this.f34022d = dVar;
        this.f34023e = constraintAnchor$Type;
    }

    public final void a(c cVar, int i10) {
        b(cVar, i10, Integer.MIN_VALUE, false);
    }

    public final boolean b(c cVar, int i10, int i11, boolean z10) {
        if (cVar == null) {
            j();
            return true;
        }
        if (!z10 && !i(cVar)) {
            return false;
        }
        this.f34024f = cVar;
        if (cVar.f34019a == null) {
            cVar.f34019a = new HashSet();
        }
        HashSet hashSet = this.f34024f.f34019a;
        if (hashSet != null) {
            hashSet.add(this);
        }
        this.f34025g = i10;
        this.f34026h = i11;
        return true;
    }

    public final void c(int i10, x.j jVar, ArrayList arrayList) {
        HashSet hashSet = this.f34019a;
        if (hashSet != null) {
            Iterator it = hashSet.iterator();
            while (it.hasNext()) {
                z.c(((c) it.next()).f34022d, i10, arrayList, jVar);
            }
        }
    }

    public final int d() {
        if (this.f34021c) {
            return this.f34020b;
        }
        return 0;
    }

    public final int e() {
        c cVar;
        if (this.f34022d.f34045i0 == 8) {
            return 0;
        }
        int i10 = this.f34026h;
        return (i10 == Integer.MIN_VALUE || (cVar = this.f34024f) == null || cVar.f34022d.f34045i0 != 8) ? this.f34025g : i10;
    }

    public final c f() {
        ConstraintAnchor$Type constraintAnchor$Type = this.f34023e;
        int iOrdinal = constraintAnchor$Type.ordinal();
        d dVar = this.f34022d;
        switch (iOrdinal) {
            case 0:
            case 5:
            case 6:
            case 7:
            case 8:
                return null;
            case 1:
                return dVar.L;
            case 2:
                return dVar.M;
            case 3:
                return dVar.J;
            case 4:
                return dVar.K;
            default:
                throw new AssertionError(constraintAnchor$Type.name());
        }
    }

    public final boolean g() {
        HashSet hashSet = this.f34019a;
        if (hashSet == null) {
            return false;
        }
        Iterator it = hashSet.iterator();
        while (it.hasNext()) {
            if (((c) it.next()).f().h()) {
                return true;
            }
        }
        return false;
    }

    public final boolean h() {
        return this.f34024f != null;
    }

    public final boolean i(c cVar) {
        if (cVar == null) {
            return false;
        }
        ConstraintAnchor$Type constraintAnchor$Type = ConstraintAnchor$Type.f1007e;
        ConstraintAnchor$Type constraintAnchor$Type2 = this.f34023e;
        d dVar = cVar.f34022d;
        ConstraintAnchor$Type constraintAnchor$Type3 = cVar.f34023e;
        if (constraintAnchor$Type3 == constraintAnchor$Type2) {
            return constraintAnchor$Type2 != constraintAnchor$Type || (dVar.E && this.f34022d.E);
        }
        int iOrdinal = constraintAnchor$Type2.ordinal();
        ConstraintAnchor$Type constraintAnchor$Type4 = ConstraintAnchor$Type.f1005c;
        ConstraintAnchor$Type constraintAnchor$Type5 = ConstraintAnchor$Type.f1003a;
        ConstraintAnchor$Type constraintAnchor$Type6 = ConstraintAnchor$Type.f1010h;
        ConstraintAnchor$Type constraintAnchor$Type7 = ConstraintAnchor$Type.f1009g;
        switch (iOrdinal) {
            case 0:
            case 7:
            case 8:
                return false;
            case 1:
            case 3:
                boolean z10 = constraintAnchor$Type3 == constraintAnchor$Type5 || constraintAnchor$Type3 == constraintAnchor$Type4;
                if (dVar instanceof h) {
                    return z10 || constraintAnchor$Type3 == constraintAnchor$Type7;
                }
                return z10;
            case 2:
            case 4:
                boolean z11 = constraintAnchor$Type3 == ConstraintAnchor$Type.f1004b || constraintAnchor$Type3 == ConstraintAnchor$Type.f1006d;
                if (dVar instanceof h) {
                    return z11 || constraintAnchor$Type3 == constraintAnchor$Type6;
                }
                return z11;
            case 5:
                return (constraintAnchor$Type3 == constraintAnchor$Type5 || constraintAnchor$Type3 == constraintAnchor$Type4) ? false : true;
            case 6:
                return (constraintAnchor$Type3 == constraintAnchor$Type || constraintAnchor$Type3 == constraintAnchor$Type7 || constraintAnchor$Type3 == constraintAnchor$Type6) ? false : true;
            default:
                throw new AssertionError(constraintAnchor$Type2.name());
        }
    }

    public final void j() {
        HashSet hashSet;
        c cVar = this.f34024f;
        if (cVar != null && (hashSet = cVar.f34019a) != null) {
            hashSet.remove(this);
            if (this.f34024f.f34019a.size() == 0) {
                this.f34024f.f34019a = null;
            }
        }
        this.f34019a = null;
        this.f34024f = null;
        this.f34025g = 0;
        this.f34026h = Integer.MIN_VALUE;
        this.f34021c = false;
        this.f34020b = 0;
    }

    public final void k() {
        u.k kVar = this.f34027i;
        if (kVar == null) {
            this.f34027i = new u.k(SolverVariable$Type.f998a);
        } else {
            kVar.c();
        }
    }

    public final void l(int i10) {
        this.f34020b = i10;
        this.f34021c = true;
    }

    public final String toString() {
        return this.f34022d.f34049k0 + ":" + this.f34023e.toString();
    }
}
