package j3;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

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

    /* renamed from: d, reason: collision with root package name */
    p f23908d;

    /* renamed from: f, reason: collision with root package name */
    int f23910f;

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

    /* renamed from: a, reason: collision with root package name */
    public d f23905a = null;

    /* renamed from: b, reason: collision with root package name */
    public boolean f23906b = false;

    /* renamed from: c, reason: collision with root package name */
    public boolean f23907c = false;

    /* renamed from: e, reason: collision with root package name */
    a f23909e = a.UNKNOWN;

    /* renamed from: h, reason: collision with root package name */
    int f23912h = 1;

    /* renamed from: i, reason: collision with root package name */
    g f23913i = null;

    /* renamed from: j, reason: collision with root package name */
    public boolean f23914j = false;

    /* renamed from: k, reason: collision with root package name */
    List f23915k = new ArrayList();

    /* renamed from: l, reason: collision with root package name */
    List f23916l = new ArrayList();

    /* loaded from: classes.dex */
    enum a {
        UNKNOWN,
        HORIZONTAL_DIMENSION,
        VERTICAL_DIMENSION,
        LEFT,
        RIGHT,
        TOP,
        BOTTOM,
        BASELINE
    }

    public f(p pVar) {
        this.f23908d = pVar;
    }

    @Override // j3.d
    public void a(d dVar) {
        Iterator it = this.f23916l.iterator();
        while (it.hasNext()) {
            if (!((f) it.next()).f23914j) {
                return;
            }
        }
        this.f23907c = true;
        d dVar2 = this.f23905a;
        if (dVar2 != null) {
            dVar2.a(this);
        }
        if (this.f23906b) {
            this.f23908d.a(this);
            return;
        }
        f fVar = null;
        int i10 = 0;
        for (f fVar2 : this.f23916l) {
            if (!(fVar2 instanceof g)) {
                i10++;
                fVar = fVar2;
            }
        }
        if (fVar != null && i10 == 1 && fVar.f23914j) {
            g gVar = this.f23913i;
            if (gVar != null) {
                if (!gVar.f23914j) {
                    return;
                } else {
                    this.f23910f = this.f23912h * gVar.f23911g;
                }
            }
            d(fVar.f23911g + this.f23910f);
        }
        d dVar3 = this.f23905a;
        if (dVar3 != null) {
            dVar3.a(this);
        }
    }

    public void b(d dVar) {
        this.f23915k.add(dVar);
        if (this.f23914j) {
            dVar.a(dVar);
        }
    }

    public void c() {
        this.f23916l.clear();
        this.f23915k.clear();
        this.f23914j = false;
        this.f23911g = 0;
        this.f23907c = false;
        this.f23906b = false;
    }

    public void d(int i10) {
        if (this.f23914j) {
            return;
        }
        this.f23914j = true;
        this.f23911g = i10;
        for (d dVar : this.f23915k) {
            dVar.a(dVar);
        }
    }

    public String toString() {
        StringBuilder sb2 = new StringBuilder();
        sb2.append(this.f23908d.f23950b.r());
        sb2.append(":");
        sb2.append(this.f23909e);
        sb2.append("(");
        sb2.append(this.f23914j ? Integer.valueOf(this.f23911g) : "unresolved");
        sb2.append(") <t=");
        sb2.append(this.f23916l.size());
        sb2.append(":d=");
        sb2.append(this.f23915k.size());
        sb2.append(">");
        return sb2.toString();
    }
}
