package i3;

import f3.i;
import j3.o;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;

/* loaded from: classes.dex */
public class d {

    /* renamed from: b, reason: collision with root package name */
    private int f22324b;

    /* renamed from: c, reason: collision with root package name */
    private boolean f22325c;

    /* renamed from: d, reason: collision with root package name */
    public final e f22326d;

    /* renamed from: e, reason: collision with root package name */
    public final b f22327e;

    /* renamed from: f, reason: collision with root package name */
    public d f22328f;

    /* renamed from: i, reason: collision with root package name */
    f3.i f22331i;

    /* renamed from: a, reason: collision with root package name */
    private HashSet f22323a = null;

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

    /* renamed from: h, reason: collision with root package name */
    int f22330h = Integer.MIN_VALUE;

    /* JADX INFO: Access modifiers changed from: package-private */
    /* loaded from: classes.dex */
    public static /* synthetic */ class a {

        /* renamed from: a, reason: collision with root package name */
        static final /* synthetic */ int[] f22332a;

        static {
            int[] iArr = new int[b.values().length];
            f22332a = iArr;
            try {
                iArr[b.CENTER.ordinal()] = 1;
            } catch (NoSuchFieldError unused) {
            }
            try {
                f22332a[b.LEFT.ordinal()] = 2;
            } catch (NoSuchFieldError unused2) {
            }
            try {
                f22332a[b.RIGHT.ordinal()] = 3;
            } catch (NoSuchFieldError unused3) {
            }
            try {
                f22332a[b.TOP.ordinal()] = 4;
            } catch (NoSuchFieldError unused4) {
            }
            try {
                f22332a[b.BOTTOM.ordinal()] = 5;
            } catch (NoSuchFieldError unused5) {
            }
            try {
                f22332a[b.BASELINE.ordinal()] = 6;
            } catch (NoSuchFieldError unused6) {
            }
            try {
                f22332a[b.CENTER_X.ordinal()] = 7;
            } catch (NoSuchFieldError unused7) {
            }
            try {
                f22332a[b.CENTER_Y.ordinal()] = 8;
            } catch (NoSuchFieldError unused8) {
            }
            try {
                f22332a[b.NONE.ordinal()] = 9;
            } catch (NoSuchFieldError unused9) {
            }
        }
    }

    /* loaded from: classes.dex */
    public enum b {
        NONE,
        LEFT,
        TOP,
        RIGHT,
        BOTTOM,
        BASELINE,
        CENTER,
        CENTER_X,
        CENTER_Y
    }

    public d(e eVar, b bVar) {
        this.f22326d = eVar;
        this.f22327e = bVar;
    }

    public boolean a(d dVar, int i10, int i11, boolean z10) {
        if (dVar == null) {
            p();
            return true;
        }
        if (!z10 && !o(dVar)) {
            return false;
        }
        this.f22328f = dVar;
        if (dVar.f22323a == null) {
            dVar.f22323a = new HashSet();
        }
        HashSet hashSet = this.f22328f.f22323a;
        if (hashSet != null) {
            hashSet.add(this);
        }
        this.f22329g = i10;
        this.f22330h = i11;
        return true;
    }

    public void b(int i10, ArrayList arrayList, o oVar) {
        HashSet hashSet = this.f22323a;
        if (hashSet != null) {
            Iterator it = hashSet.iterator();
            while (it.hasNext()) {
                j3.i.a(((d) it.next()).f22326d, i10, arrayList, oVar);
            }
        }
    }

    public HashSet c() {
        return this.f22323a;
    }

    public int d() {
        if (this.f22325c) {
            return this.f22324b;
        }
        return 0;
    }

    public int e() {
        d dVar;
        if (this.f22326d.T() == 8) {
            return 0;
        }
        return (this.f22330h == Integer.MIN_VALUE || (dVar = this.f22328f) == null || dVar.f22326d.T() != 8) ? this.f22329g : this.f22330h;
    }

    public final d f() {
        switch (a.f22332a[this.f22327e.ordinal()]) {
            case 1:
            case 6:
            case 7:
            case 8:
            case 9:
                return null;
            case 2:
                return this.f22326d.Q;
            case 3:
                return this.f22326d.O;
            case 4:
                return this.f22326d.R;
            case 5:
                return this.f22326d.P;
            default:
                throw new AssertionError(this.f22327e.name());
        }
    }

    public e g() {
        return this.f22326d;
    }

    public f3.i h() {
        return this.f22331i;
    }

    public d i() {
        return this.f22328f;
    }

    public b j() {
        return this.f22327e;
    }

    public boolean k() {
        HashSet hashSet = this.f22323a;
        if (hashSet == null) {
            return false;
        }
        Iterator it = hashSet.iterator();
        while (it.hasNext()) {
            if (((d) it.next()).f().n()) {
                return true;
            }
        }
        return false;
    }

    public boolean l() {
        HashSet hashSet = this.f22323a;
        return hashSet != null && hashSet.size() > 0;
    }

    public boolean m() {
        return this.f22325c;
    }

    public boolean n() {
        return this.f22328f != null;
    }

    public boolean o(d dVar) {
        if (dVar == null) {
            return false;
        }
        b j10 = dVar.j();
        b bVar = this.f22327e;
        if (j10 == bVar) {
            return bVar != b.BASELINE || (dVar.g().X() && g().X());
        }
        switch (a.f22332a[bVar.ordinal()]) {
            case 1:
                return (j10 == b.BASELINE || j10 == b.CENTER_X || j10 == b.CENTER_Y) ? false : true;
            case 2:
            case 3:
                boolean z10 = j10 == b.LEFT || j10 == b.RIGHT;
                if (dVar.g() instanceof g) {
                    return z10 || j10 == b.CENTER_X;
                }
                return z10;
            case 4:
            case 5:
                boolean z11 = j10 == b.TOP || j10 == b.BOTTOM;
                if (dVar.g() instanceof g) {
                    return z11 || j10 == b.CENTER_Y;
                }
                return z11;
            case 6:
                return (j10 == b.LEFT || j10 == b.RIGHT) ? false : true;
            case 7:
            case 8:
            case 9:
                return false;
            default:
                throw new AssertionError(this.f22327e.name());
        }
    }

    public void p() {
        HashSet hashSet;
        d dVar = this.f22328f;
        if (dVar != null && (hashSet = dVar.f22323a) != null) {
            hashSet.remove(this);
            if (this.f22328f.f22323a.size() == 0) {
                this.f22328f.f22323a = null;
            }
        }
        this.f22323a = null;
        this.f22328f = null;
        this.f22329g = 0;
        this.f22330h = Integer.MIN_VALUE;
        this.f22325c = false;
        this.f22324b = 0;
    }

    public void q() {
        this.f22325c = false;
        this.f22324b = 0;
    }

    public void r(f3.c cVar) {
        f3.i iVar = this.f22331i;
        if (iVar == null) {
            this.f22331i = new f3.i(i.a.UNRESTRICTED, null);
        } else {
            iVar.r();
        }
    }

    public void s(int i10) {
        this.f22324b = i10;
        this.f22325c = true;
    }

    public String toString() {
        return this.f22326d.r() + ":" + this.f22327e.toString();
    }
}
