package j3;

import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import i3.d;
import i3.e;
import java.util.ArrayList;

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

    /* renamed from: a, reason: collision with root package name */
    private final ArrayList f23878a = new ArrayList();

    /* renamed from: b, reason: collision with root package name */
    private a f23879b = new a();

    /* renamed from: c, reason: collision with root package name */
    private i3.f f23880c;

    /* loaded from: classes.dex */
    public static class a {

        /* renamed from: k, reason: collision with root package name */
        public static int f23881k = 0;

        /* renamed from: l, reason: collision with root package name */
        public static int f23882l = 1;

        /* renamed from: m, reason: collision with root package name */
        public static int f23883m = 2;

        /* renamed from: a, reason: collision with root package name */
        public e.b f23884a;

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

        /* renamed from: c, reason: collision with root package name */
        public int f23886c;

        /* renamed from: d, reason: collision with root package name */
        public int f23887d;

        /* renamed from: e, reason: collision with root package name */
        public int f23888e;

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

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

        /* renamed from: h, reason: collision with root package name */
        public boolean f23891h;

        /* renamed from: i, reason: collision with root package name */
        public boolean f23892i;

        /* renamed from: j, reason: collision with root package name */
        public int f23893j;
    }

    /* renamed from: j3.b$b, reason: collision with other inner class name */
    /* loaded from: classes.dex */
    public interface InterfaceC0509b {
        void a();

        void b(i3.e eVar, a aVar);
    }

    public b(i3.f fVar) {
        this.f23880c = fVar;
    }

    private boolean a(InterfaceC0509b interfaceC0509b, i3.e eVar, int i10) {
        this.f23879b.f23884a = eVar.y();
        this.f23879b.f23885b = eVar.R();
        this.f23879b.f23886c = eVar.U();
        this.f23879b.f23887d = eVar.v();
        a aVar = this.f23879b;
        aVar.f23892i = false;
        aVar.f23893j = i10;
        e.b bVar = aVar.f23884a;
        e.b bVar2 = e.b.MATCH_CONSTRAINT;
        boolean z10 = bVar == bVar2;
        boolean z11 = aVar.f23885b == bVar2;
        boolean z12 = z10 && eVar.f22340d0 > BitmapDescriptorFactory.HUE_RED;
        boolean z13 = z11 && eVar.f22340d0 > BitmapDescriptorFactory.HUE_RED;
        if (z12 && eVar.f22381y[0] == 4) {
            aVar.f23884a = e.b.FIXED;
        }
        if (z13 && eVar.f22381y[1] == 4) {
            aVar.f23885b = e.b.FIXED;
        }
        interfaceC0509b.b(eVar, aVar);
        eVar.g1(this.f23879b.f23888e);
        eVar.I0(this.f23879b.f23889f);
        eVar.H0(this.f23879b.f23891h);
        eVar.x0(this.f23879b.f23890g);
        a aVar2 = this.f23879b;
        aVar2.f23893j = a.f23881k;
        return aVar2.f23892i;
    }

    /* JADX WARN: Code restructure failed: missing block: B:46:0x0089, code lost:
    
        if (r8 != r9) goto L54;
     */
    /* JADX WARN: Code restructure failed: missing block: B:48:0x0090, code lost:
    
        if (r5.f22340d0 <= com.google.android.gms.maps.model.BitmapDescriptorFactory.HUE_RED) goto L54;
     */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    private void b(i3.f fVar) {
        l lVar;
        n nVar;
        int size = fVar.L0.size();
        boolean O1 = fVar.O1(64);
        InterfaceC0509b E1 = fVar.E1();
        for (int i10 = 0; i10 < size; i10++) {
            i3.e eVar = (i3.e) fVar.L0.get(i10);
            if (!(eVar instanceof i3.g) && !(eVar instanceof i3.a) && !eVar.j0() && (!O1 || (lVar = eVar.f22341e) == null || (nVar = eVar.f22343f) == null || !lVar.f23953e.f23914j || !nVar.f23953e.f23914j)) {
                e.b s10 = eVar.s(0);
                boolean z10 = true;
                e.b s11 = eVar.s(1);
                e.b bVar = e.b.MATCH_CONSTRAINT;
                boolean z11 = s10 == bVar && eVar.f22377w != 1 && s11 == bVar && eVar.f22379x != 1;
                if (!z11 && fVar.O1(1)) {
                    if (s10 == bVar && eVar.f22377w == 0 && s11 != bVar && !eVar.g0()) {
                        z11 = true;
                    }
                    if (s11 == bVar && eVar.f22379x == 0 && s10 != bVar && !eVar.g0()) {
                        z11 = true;
                    }
                    if (s10 != bVar) {
                    }
                }
                z10 = z11;
                if (!z10) {
                    a(E1, eVar, a.f23881k);
                }
            }
        }
        E1.a();
    }

    private void c(i3.f fVar, String str, int i10, int i11, int i12) {
        int G = fVar.G();
        int F = fVar.F();
        fVar.W0(0);
        fVar.V0(0);
        fVar.g1(i11);
        fVar.I0(i12);
        fVar.W0(G);
        fVar.V0(F);
        this.f23880c.S1(i10);
        this.f23880c.o1();
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Type inference failed for: r10v2, types: [int] */
    /* JADX WARN: Type inference failed for: r10v5 */
    /* JADX WARN: Type inference failed for: r10v6 */
    /* JADX WARN: Type inference failed for: r12v5, types: [java.util.ArrayList] */
    public long d(i3.f fVar, int i10, int i11, int i12, int i13, int i14, int i15, int i16, int i17, int i18) {
        boolean z10;
        int i19;
        i3.f fVar2;
        int i20;
        boolean z11;
        int i21;
        b bVar = this;
        InterfaceC0509b E1 = fVar.E1();
        int size = fVar.L0.size();
        int U = fVar.U();
        int v10 = fVar.v();
        boolean b10 = i3.j.b(i10, 128);
        boolean z12 = false;
        boolean z13 = b10 || i3.j.b(i10, 64);
        if (z13) {
            for (int i22 = 0; i22 < size; i22++) {
                i3.e eVar = (i3.e) fVar.L0.get(i22);
                e.b y10 = eVar.y();
                e.b bVar2 = e.b.MATCH_CONSTRAINT;
                boolean z14 = (y10 == bVar2) && (eVar.R() == bVar2) && eVar.t() > BitmapDescriptorFactory.HUE_RED;
                if ((eVar.g0() && z14) || ((eVar.i0() && z14) || eVar.g0() || eVar.i0())) {
                    z13 = false;
                    break;
                }
            }
        }
        if (z13) {
            boolean z15 = f3.d.f17571r;
        }
        boolean z16 = z13 & ((i13 == 1073741824 && i15 == 1073741824) || b10);
        if (z16) {
            int min = Math.min(fVar.E(), i14);
            int min2 = Math.min(fVar.D(), i16);
            if (i13 == 1073741824 && fVar.U() != min) {
                fVar.g1(min);
                fVar.H1();
            }
            if (i15 == 1073741824 && fVar.v() != min2) {
                fVar.I0(min2);
                fVar.H1();
            }
            if (i13 == 1073741824 && i15 == 1073741824) {
                z10 = fVar.B1(b10);
                i19 = 2;
            } else {
                boolean C1 = fVar.C1(b10);
                if (i13 == 1073741824) {
                    C1 &= fVar.D1(b10, 0);
                    i19 = 1;
                } else {
                    i19 = 0;
                }
                if (i15 == 1073741824) {
                    z10 = fVar.D1(b10, 1) & C1;
                    i19++;
                } else {
                    z10 = C1;
                }
            }
            if (z10) {
                fVar.l1(i13 == 1073741824, i15 == 1073741824);
            }
        } else {
            z10 = false;
            i19 = 0;
        }
        if (z10 && i19 == 2) {
            return 0L;
        }
        int F1 = fVar.F1();
        if (size > 0) {
            b(fVar);
        }
        e(fVar);
        int size2 = bVar.f23878a.size();
        if (size > 0) {
            c(fVar, "First pass", 0, U, v10);
        }
        if (size2 > 0) {
            e.b y11 = fVar.y();
            e.b bVar3 = e.b.WRAP_CONTENT;
            boolean z17 = y11 == bVar3;
            boolean z18 = fVar.R() == bVar3;
            int max = Math.max(fVar.U(), bVar.f23880c.G());
            int max2 = Math.max(fVar.v(), bVar.f23880c.F());
            for (int i23 = 0; i23 < size2; i23++) {
            }
            int i24 = 0;
            for (int i25 = 2; i24 < i25; i25 = 2) {
                boolean z19 = z12;
                for (?? r10 = z12; r10 < size2; r10++) {
                    i3.e eVar2 = (i3.e) bVar.f23878a.get(r10);
                    int i26 = size2;
                    if ((eVar2 instanceof i3.h) || (eVar2 instanceof i3.g) || eVar2.T() == 8 || (z16 && eVar2.f22341e.f23953e.f23914j && eVar2.f22343f.f23953e.f23914j)) {
                        z11 = z16;
                        i21 = F1;
                    } else {
                        int U2 = eVar2.U();
                        int v11 = eVar2.v();
                        z11 = z16;
                        int n10 = eVar2.n();
                        int i27 = a.f23882l;
                        i21 = F1;
                        if (i24 == 1) {
                            i27 = a.f23883m;
                        }
                        boolean a10 = bVar.a(E1, eVar2, i27) | z19;
                        int U3 = eVar2.U();
                        int v12 = eVar2.v();
                        if (U3 != U2) {
                            eVar2.g1(U3);
                            if (z17 && eVar2.K() > max) {
                                max = Math.max(max, eVar2.K() + eVar2.m(d.b.RIGHT).e());
                            }
                            a10 = true;
                        }
                        if (v12 != v11) {
                            eVar2.I0(v12);
                            if (z18 && eVar2.p() > max2) {
                                max2 = Math.max(max2, eVar2.p() + eVar2.m(d.b.BOTTOM).e());
                            }
                            a10 = true;
                        }
                        z19 = (!eVar2.X() || n10 == eVar2.n()) ? a10 : true;
                    }
                    bVar = this;
                    size2 = i26;
                    z16 = z11;
                    F1 = i21;
                }
                boolean z20 = z16;
                int i28 = F1;
                int i29 = size2;
                if (!z19) {
                    fVar2 = fVar;
                    i20 = i28;
                    break;
                }
                i24++;
                c(fVar, "intermediate pass", i24, U, v10);
                bVar = this;
                size2 = i29;
                z16 = z20;
                F1 = i28;
                z12 = false;
            }
        }
        fVar2 = fVar;
        i20 = F1;
        fVar2.R1(i20);
        return 0L;
    }

    public void e(i3.f fVar) {
        this.f23878a.clear();
        int size = fVar.L0.size();
        for (int i10 = 0; i10 < size; i10++) {
            i3.e eVar = (i3.e) fVar.L0.get(i10);
            e.b y10 = eVar.y();
            e.b bVar = e.b.MATCH_CONSTRAINT;
            if (y10 == bVar || eVar.R() == bVar) {
                this.f23878a.add(eVar);
            }
        }
        fVar.H1();
    }
}
