package u1;

import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;
import m1.p;
import n1.C2609c;
import v1.AbstractC3095h;
import v1.C3089b;
import v1.C3092e;
import v1.l;

/* JADX INFO: loaded from: classes.dex */
public final class e extends d {

    /* JADX INFO: renamed from: A0, reason: collision with root package name */
    public WeakReference f24489A0;

    /* JADX INFO: renamed from: B0, reason: collision with root package name */
    public WeakReference f24490B0;

    /* JADX INFO: renamed from: C0, reason: collision with root package name */
    public HashSet f24491C0;

    /* JADX INFO: renamed from: D0, reason: collision with root package name */
    public C3089b f24492D0;

    /* JADX INFO: renamed from: n0, reason: collision with root package name */
    public ArrayList f24493n0;

    /* JADX INFO: renamed from: o0, reason: collision with root package name */
    public o4.f f24494o0;

    /* JADX INFO: renamed from: p0, reason: collision with root package name */
    public C3092e f24495p0;

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

    /* JADX INFO: renamed from: r0, reason: collision with root package name */
    public p f24497r0;

    /* JADX INFO: renamed from: s0, reason: collision with root package name */
    public C2609c f24498s0;

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

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

    /* JADX INFO: renamed from: v0, reason: collision with root package name */
    public C2961b[] f24501v0;

    /* JADX INFO: renamed from: w0, reason: collision with root package name */
    public C2961b[] f24502w0;

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

    /* JADX INFO: renamed from: y0, reason: collision with root package name */
    public WeakReference f24504y0;

    /* JADX INFO: renamed from: z0, reason: collision with root package name */
    public WeakReference f24505z0;

    public static void Q(d dVar, p pVar, C3089b c3089b) {
        int i6;
        int i7;
        if (pVar == null) {
            return;
        }
        if (dVar.f24462d0 == 8 || (dVar instanceof h) || (dVar instanceof C2960a)) {
            c3089b.f25246e = 0;
            c3089b.f25247f = 0;
            return;
        }
        int[] iArr = dVar.f24475m0;
        c3089b.f25242a = iArr[0];
        c3089b.f25243b = iArr[1];
        c3089b.f25244c = dVar.o();
        c3089b.f25245d = dVar.l();
        c3089b.f25250i = false;
        c3089b.f25251j = 0;
        boolean z6 = c3089b.f25242a == 3;
        boolean z7 = c3089b.f25243b == 3;
        boolean z8 = z6 && dVar.f24450T > 0.0f;
        boolean z9 = z7 && dVar.f24450T > 0.0f;
        if (z6 && dVar.r(0) && dVar.f24480r == 0 && !z8) {
            c3089b.f25242a = 2;
            if (z7 && dVar.f24481s == 0) {
                c3089b.f25242a = 1;
            }
            z6 = false;
        }
        if (z7 && dVar.r(1) && dVar.f24481s == 0 && !z9) {
            c3089b.f25243b = 2;
            if (z6 && dVar.f24480r == 0) {
                c3089b.f25243b = 1;
            }
            z7 = false;
        }
        if (dVar.y()) {
            c3089b.f25242a = 1;
            z6 = false;
        }
        if (dVar.z()) {
            c3089b.f25243b = 1;
            z7 = false;
        }
        int[] iArr2 = dVar.f24482t;
        if (z8) {
            if (iArr2[0] == 4) {
                c3089b.f25242a = 1;
            } else if (!z7) {
                if (c3089b.f25243b == 1) {
                    i7 = c3089b.f25245d;
                } else {
                    c3089b.f25242a = 2;
                    pVar.a(dVar, c3089b);
                    i7 = c3089b.f25247f;
                }
                c3089b.f25242a = 1;
                c3089b.f25244c = (int) (dVar.f24450T * i7);
            }
        }
        if (z9) {
            if (iArr2[1] == 4) {
                c3089b.f25243b = 1;
            } else if (!z6) {
                if (c3089b.f25242a == 1) {
                    i6 = c3089b.f25244c;
                } else {
                    c3089b.f25243b = 2;
                    pVar.a(dVar, c3089b);
                    i6 = c3089b.f25246e;
                }
                c3089b.f25243b = 1;
                if (dVar.f24451U == -1) {
                    c3089b.f25245d = (int) (i6 / dVar.f24450T);
                } else {
                    c3089b.f25245d = (int) (dVar.f24450T * i6);
                }
            }
        }
        pVar.a(dVar, c3089b);
        dVar.K(c3089b.f25246e);
        dVar.H(c3089b.f25247f);
        dVar.f24435E = c3089b.f25249h;
        dVar.E(c3089b.f25248g);
        c3089b.f25251j = 0;
    }

    @Override // u1.d
    public final void A() {
        this.f24498s0.t();
        this.f24493n0.clear();
        super.A();
    }

    @Override // u1.d
    public final void D(C4.f fVar) {
        super.D(fVar);
        int size = this.f24493n0.size();
        for (int i6 = 0; i6 < size; i6++) {
            ((d) this.f24493n0.get(i6)).D(fVar);
        }
    }

    @Override // u1.d
    public final void L(boolean z6, boolean z7) {
        super.L(z6, z7);
        int size = this.f24493n0.size();
        for (int i6 = 0; i6 < size; i6++) {
            ((d) this.f24493n0.get(i6)).L(z6, z7);
        }
    }

    public final void N(d dVar, int i6) {
        if (i6 == 0) {
            int i7 = this.f24499t0 + 1;
            C2961b[] c2961bArr = this.f24502w0;
            if (i7 >= c2961bArr.length) {
                this.f24502w0 = (C2961b[]) Arrays.copyOf(c2961bArr, c2961bArr.length * 2);
            }
            C2961b[] c2961bArr2 = this.f24502w0;
            int i8 = this.f24499t0;
            c2961bArr2[i8] = new C2961b(dVar, 0);
            this.f24499t0 = i8 + 1;
            return;
        }
        if (i6 == 1) {
            int i9 = this.f24500u0 + 1;
            C2961b[] c2961bArr3 = this.f24501v0;
            if (i9 >= c2961bArr3.length) {
                this.f24501v0 = (C2961b[]) Arrays.copyOf(c2961bArr3, c2961bArr3.length * 2);
            }
            C2961b[] c2961bArr4 = this.f24501v0;
            int i10 = this.f24500u0;
            c2961bArr4[i10] = new C2961b(dVar, 1);
            this.f24500u0 = i10 + 1;
        }
    }

    public final void O(C2609c c2609c) {
        e eVar;
        C2609c c2609c2;
        boolean zR = R(64);
        c(c2609c, zR);
        int size = this.f24493n0.size();
        boolean z6 = false;
        for (int i6 = 0; i6 < size; i6++) {
            d dVar = (d) this.f24493n0.get(i6);
            boolean[] zArr = dVar.f24446P;
            zArr[0] = false;
            zArr[1] = false;
            if (dVar instanceof C2960a) {
                z6 = true;
            }
        }
        if (z6) {
            for (int i7 = 0; i7 < size; i7++) {
                d dVar2 = (d) this.f24493n0.get(i7);
                if (dVar2 instanceof C2960a) {
                    C2960a c2960a = (C2960a) dVar2;
                    for (int i8 = 0; i8 < c2960a.f24552o0; i8++) {
                        d dVar3 = c2960a.f24551n0[i8];
                        if (c2960a.f24404q0 || dVar3.d()) {
                            int i9 = c2960a.f24403p0;
                            if (i9 == 0 || i9 == 1) {
                                dVar3.f24446P[0] = true;
                            } else if (i9 == 2 || i9 == 3) {
                                dVar3.f24446P[1] = true;
                            }
                        }
                    }
                }
            }
        }
        HashSet hashSet = this.f24491C0;
        hashSet.clear();
        for (int i10 = 0; i10 < size; i10++) {
            d dVar4 = (d) this.f24493n0.get(i10);
            dVar4.getClass();
            boolean z7 = dVar4 instanceof k;
            if (z7 || (dVar4 instanceof h)) {
                if (z7) {
                    hashSet.add(dVar4);
                } else {
                    dVar4.c(c2609c, zR);
                }
            }
        }
        while (hashSet.size() > 0) {
            int size2 = hashSet.size();
            Iterator it = hashSet.iterator();
            while (true) {
                if (!it.hasNext()) {
                    break;
                }
                k kVar = (k) ((d) it.next());
                for (int i11 = 0; i11 < kVar.f24552o0; i11++) {
                    if (hashSet.contains(kVar.f24551n0[i11])) {
                        kVar.c(c2609c, zR);
                        hashSet.remove(kVar);
                        break;
                    }
                }
            }
            if (size2 == hashSet.size()) {
                Iterator it2 = hashSet.iterator();
                while (it2.hasNext()) {
                    ((d) it2.next()).c(c2609c, zR);
                }
                hashSet.clear();
            }
        }
        if (C2609c.f21576q) {
            HashSet<d> hashSet2 = new HashSet();
            for (int i12 = 0; i12 < size; i12++) {
                d dVar5 = (d) this.f24493n0.get(i12);
                dVar5.getClass();
                if (!(dVar5 instanceof k) && !(dVar5 instanceof h)) {
                    hashSet2.add(dVar5);
                }
            }
            eVar = this;
            c2609c2 = c2609c;
            eVar.b(this, c2609c2, hashSet2, this.f24475m0[0] == 2 ? 0 : 1, false);
            for (d dVar6 : hashSet2) {
                j.b(this, c2609c2, dVar6);
                dVar6.c(c2609c2, zR);
            }
        } else {
            eVar = this;
            c2609c2 = c2609c;
            for (int i13 = 0; i13 < size; i13++) {
                d dVar7 = (d) eVar.f24493n0.get(i13);
                if (dVar7 instanceof e) {
                    int[] iArr = dVar7.f24475m0;
                    int i14 = iArr[0];
                    int i15 = iArr[1];
                    if (i14 == 2) {
                        dVar7.I(1);
                    }
                    if (i15 == 2) {
                        dVar7.J(1);
                    }
                    dVar7.c(c2609c2, zR);
                    if (i14 == 2) {
                        dVar7.I(i14);
                    }
                    if (i15 == 2) {
                        dVar7.J(i15);
                    }
                } else {
                    j.b(this, c2609c2, dVar7);
                    if (!(dVar7 instanceof k) && !(dVar7 instanceof h)) {
                        dVar7.c(c2609c2, zR);
                    }
                }
            }
        }
        if (eVar.f24499t0 > 0) {
            j.a(this, c2609c2, null, 0);
        }
        if (eVar.f24500u0 > 0) {
            j.a(this, c2609c2, null, 1);
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:359:0x05f2  */
    /* JADX WARN: Removed duplicated region for block: B:371:0x061d  */
    /* JADX WARN: Removed duplicated region for block: B:437:0x0707  */
    /* JADX WARN: Removed duplicated region for block: B:45:0x00d8  */
    /* JADX WARN: Removed duplicated region for block: B:481:0x07bc  */
    /* JADX WARN: Removed duplicated region for block: B:490:0x07fd  */
    /* JADX WARN: Removed duplicated region for block: B:496:0x081a A[ADDED_TO_REGION] */
    /* JADX WARN: Removed duplicated region for block: B:501:0x0827 A[LOOP:14: B:500:0x0825->B:501:0x0827, LOOP_END] */
    /* JADX WARN: Removed duplicated region for block: B:513:0x088f  */
    /* JADX WARN: Removed duplicated region for block: B:514:0x089d  */
    /* JADX WARN: Removed duplicated region for block: B:517:0x08af  */
    /* JADX WARN: Removed duplicated region for block: B:519:0x08ba  */
    /* JADX WARN: Removed duplicated region for block: B:532:0x08ef  */
    /* JADX WARN: Removed duplicated region for block: B:534:0x08f3  */
    /* JADX WARN: Removed duplicated region for block: B:58:0x0102  */
    /* JADX WARN: Removed duplicated region for block: B:608:0x08f5 A[SYNTHETIC] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void P() {
        int[] iArr;
        C2962c c2962c;
        int i6;
        int i7;
        int i8;
        char c6;
        C2962c c2962c2;
        int i9;
        boolean[] zArr;
        int i10;
        int iMax;
        int i11;
        int iMax2;
        int i12;
        int i13;
        int iMax3;
        int iMax4;
        char c7;
        C2609c c2609c;
        char c8;
        l lVar;
        int iB;
        int iB2;
        int i14;
        l lVar2;
        l lVar3;
        boolean z6;
        ArrayList arrayList;
        ArrayList arrayList2;
        ArrayList arrayList3;
        ArrayList arrayList4;
        ArrayList arrayList5;
        this.f24452V = 0;
        this.f24453W = 0;
        int size = this.f24493n0.size();
        int iMax5 = Math.max(0, o());
        int iMax6 = Math.max(0, l());
        int[] iArr2 = this.f24475m0;
        int i15 = 1;
        int i16 = iArr2[1];
        int i17 = iArr2[0];
        int i18 = this.f24496q0;
        C2962c c2962c3 = this.f24437G;
        C2962c c2962c4 = this.f24436F;
        if (i18 == 0 && (this.f24503x0 & 1) == 1) {
            p pVar = this.f24497r0;
            C();
            ArrayList arrayList6 = this.f24493n0;
            int size2 = arrayList6.size();
            for (int i19 = 0; i19 < size2; i19++) {
                ((d) arrayList6.get(i19)).C();
            }
            if (i17 == 1) {
                F(0, o());
            } else {
                c2962c4.l(0);
                this.f24452V = 0;
            }
            int i20 = 0;
            boolean z7 = false;
            boolean z8 = false;
            while (i20 < size2) {
                d dVar = (d) arrayList6.get(i20);
                if (dVar instanceof h) {
                    h hVar = (h) dVar;
                    if (hVar.f24549r0 == i15) {
                        int i21 = hVar.f24546o0;
                        if (i21 != -1) {
                            hVar.N(i21);
                        } else if (hVar.f24547p0 != -1 && y()) {
                            hVar.N(o() - hVar.f24547p0);
                        } else if (y()) {
                            hVar.N((int) ((hVar.f24545n0 * o()) + 0.5f));
                        }
                        z7 = true;
                    }
                } else if ((dVar instanceof C2960a) && ((C2960a) dVar).Q() == 0) {
                    z8 = true;
                }
                i20++;
                i15 = 1;
            }
            if (z7) {
                for (int i22 = 0; i22 < size2; i22++) {
                    d dVar2 = (d) arrayList6.get(i22);
                    if (dVar2 instanceof h) {
                        h hVar2 = (h) dVar2;
                        if (hVar2.f24549r0 == 1) {
                            AbstractC3095h.c(0, pVar, hVar2);
                        }
                    }
                }
            }
            AbstractC3095h.c(0, pVar, this);
            if (z8) {
                for (int i23 = 0; i23 < size2; i23++) {
                    d dVar3 = (d) arrayList6.get(i23);
                    if (dVar3 instanceof C2960a) {
                        C2960a c2960a = (C2960a) dVar3;
                        if (c2960a.Q() == 0 && c2960a.P()) {
                            AbstractC3095h.c(1, pVar, c2960a);
                        }
                    }
                }
            }
            if (i16 == 1) {
                G(0, l());
            } else {
                c2962c3.l(0);
                this.f24453W = 0;
            }
            int i24 = 0;
            boolean z9 = false;
            boolean z10 = false;
            while (i24 < size2) {
                d dVar4 = (d) arrayList6.get(i24);
                int i25 = i24;
                if (dVar4 instanceof h) {
                    h hVar3 = (h) dVar4;
                    if (hVar3.f24549r0 == 0) {
                        int i26 = hVar3.f24546o0;
                        if (i26 != -1) {
                            hVar3.N(i26);
                        } else if (hVar3.f24547p0 != -1 && z()) {
                            hVar3.N(l() - hVar3.f24547p0);
                        } else if (z()) {
                            hVar3.N((int) ((hVar3.f24545n0 * l()) + 0.5f));
                        }
                        z9 = true;
                    }
                } else if ((dVar4 instanceof C2960a) && ((C2960a) dVar4).Q() == 1) {
                    z10 = true;
                }
                i24 = i25 + 1;
            }
            if (z9) {
                for (int i27 = 0; i27 < size2; i27++) {
                    d dVar5 = (d) arrayList6.get(i27);
                    if (dVar5 instanceof h) {
                        h hVar4 = (h) dVar5;
                        if (hVar4.f24549r0 == 0) {
                            AbstractC3095h.i(1, pVar, hVar4);
                        }
                    }
                }
            }
            AbstractC3095h.i(0, pVar, this);
            if (z10) {
                for (int i28 = 0; i28 < size2; i28++) {
                    d dVar6 = (d) arrayList6.get(i28);
                    if (dVar6 instanceof C2960a) {
                        C2960a c2960a2 = (C2960a) dVar6;
                        if (c2960a2.Q() == 1 && c2960a2.P()) {
                            AbstractC3095h.i(1, pVar, c2960a2);
                        }
                    }
                }
            }
            for (int i29 = 0; i29 < size2; i29++) {
                d dVar7 = (d) arrayList6.get(i29);
                if (dVar7.x() && AbstractC3095h.a(dVar7)) {
                    Q(dVar7, pVar, AbstractC3095h.f25272a);
                    if (!(dVar7 instanceof h)) {
                        AbstractC3095h.c(0, pVar, dVar7);
                        AbstractC3095h.i(0, pVar, dVar7);
                    } else if (((h) dVar7).f24549r0 == 0) {
                        AbstractC3095h.i(0, pVar, dVar7);
                    } else {
                        AbstractC3095h.c(0, pVar, dVar7);
                    }
                }
            }
            for (int i30 = 0; i30 < size; i30++) {
                d dVar8 = (d) this.f24493n0.get(i30);
                if (dVar8.x() && !(dVar8 instanceof h) && !(dVar8 instanceof C2960a) && !(dVar8 instanceof k)) {
                    int iK = dVar8.k(0);
                    int iK2 = dVar8.k(1);
                    if (iK != 3 || dVar8.f24480r == 1 || iK2 != 3 || dVar8.f24481s == 1) {
                        Q(dVar8, this.f24497r0, new C3089b());
                    }
                }
            }
        }
        C2609c c2609c2 = this.f24498s0;
        if (size <= 2 || !((i17 == 2 || i16 == 2) && (this.f24503x0 & 1024) == 1024)) {
            iArr = iArr2;
            c2962c = c2962c4;
        } else {
            p pVar2 = this.f24497r0;
            ArrayList arrayList7 = this.f24493n0;
            int size3 = arrayList7.size();
            int i31 = 0;
            while (true) {
                if (i31 < size3) {
                    d dVar9 = (d) arrayList7.get(i31);
                    int i32 = iArr2[0];
                    iArr = iArr2;
                    int i33 = iArr[1];
                    int i34 = i31;
                    int[] iArr3 = dVar9.f24475m0;
                    c2962c = c2962c4;
                    if (!AbstractC3095h.h(i32, i33, iArr3[0], iArr3[1]) || (dVar9 instanceof g)) {
                        break;
                    }
                    i31 = i34 + 1;
                    iArr2 = iArr;
                    c2962c4 = c2962c;
                } else {
                    iArr = iArr2;
                    c2962c = c2962c4;
                    int i35 = 0;
                    ArrayList arrayList8 = null;
                    ArrayList arrayList9 = null;
                    ArrayList arrayList10 = null;
                    ArrayList arrayList11 = null;
                    ArrayList arrayList12 = null;
                    ArrayList arrayList13 = null;
                    while (i35 < size3) {
                        int i36 = i35;
                        d dVar10 = (d) arrayList7.get(i35);
                        ArrayList arrayList14 = arrayList8;
                        int i37 = iArr[0];
                        ArrayList arrayList15 = arrayList9;
                        int i38 = iArr[1];
                        ArrayList arrayList16 = arrayList10;
                        int[] iArr4 = dVar10.f24475m0;
                        ArrayList arrayList17 = arrayList11;
                        if (!AbstractC3095h.h(i37, i38, iArr4[0], iArr4[1])) {
                            Q(dVar10, pVar2, this.f24492D0);
                        }
                        boolean z11 = dVar10 instanceof h;
                        if (z11) {
                            h hVar5 = (h) dVar10;
                            if (hVar5.f24549r0 == 0) {
                                arrayList5 = arrayList15 == null ? new ArrayList() : arrayList15;
                                arrayList5.add(hVar5);
                            } else {
                                arrayList5 = arrayList15;
                            }
                            z6 = z11;
                            if (hVar5.f24549r0 == 1) {
                                ArrayList arrayList18 = arrayList13 == null ? new ArrayList() : arrayList13;
                                arrayList18.add(hVar5);
                                arrayList13 = arrayList18;
                            }
                            arrayList = arrayList5;
                        } else {
                            z6 = z11;
                            arrayList = arrayList15;
                        }
                        if (!(dVar10 instanceof i)) {
                            arrayList2 = arrayList;
                            arrayList8 = arrayList14;
                            arrayList10 = arrayList16;
                        } else if (dVar10 instanceof C2960a) {
                            C2960a c2960a3 = (C2960a) dVar10;
                            if (c2960a3.Q() == 0) {
                                arrayList3 = arrayList14 == null ? new ArrayList() : arrayList14;
                                arrayList3.add(c2960a3);
                            } else {
                                arrayList3 = arrayList14;
                            }
                            arrayList2 = arrayList;
                            if (c2960a3.Q() == 1) {
                                arrayList4 = arrayList16 == null ? new ArrayList() : arrayList16;
                                arrayList4.add(c2960a3);
                            } else {
                                arrayList4 = arrayList16;
                            }
                            arrayList8 = arrayList3;
                            arrayList10 = arrayList4;
                        } else {
                            arrayList2 = arrayList;
                            i iVar = (i) dVar10;
                            ArrayList arrayList19 = arrayList14 == null ? new ArrayList() : arrayList14;
                            arrayList19.add(iVar);
                            arrayList10 = arrayList16 == null ? new ArrayList() : arrayList16;
                            arrayList10.add(iVar);
                            arrayList8 = arrayList19;
                        }
                        if (dVar10.f24436F.f24427f != null || dVar10.f24438H.f24427f != null || z6 || (dVar10 instanceof C2960a)) {
                            arrayList11 = arrayList17;
                        } else {
                            arrayList11 = arrayList17 == null ? new ArrayList() : arrayList17;
                            arrayList11.add(dVar10);
                        }
                        if (dVar10.f24437G.f24427f == null && dVar10.f24439I.f24427f == null && dVar10.f24440J.f24427f == null && !z6 && !(dVar10 instanceof C2960a)) {
                            if (arrayList12 == null) {
                                arrayList12 = new ArrayList();
                            }
                            ArrayList arrayList20 = arrayList12;
                            arrayList20.add(dVar10);
                            arrayList12 = arrayList20;
                        }
                        i35 = i36 + 1;
                        arrayList9 = arrayList2;
                    }
                    ArrayList<i> arrayList21 = arrayList8;
                    ArrayList arrayList22 = arrayList9;
                    ArrayList<i> arrayList23 = arrayList10;
                    ArrayList arrayList24 = arrayList11;
                    ArrayList<l> arrayList25 = new ArrayList();
                    if (arrayList13 != null) {
                        Iterator it = arrayList13.iterator();
                        while (it.hasNext()) {
                            AbstractC3095h.b((h) it.next(), 0, arrayList25, null);
                        }
                    }
                    l lVar4 = null;
                    int i39 = 0;
                    if (arrayList21 != null) {
                        for (i iVar2 : arrayList21) {
                            l lVarB = AbstractC3095h.b(iVar2, i39, arrayList25, lVar4);
                            iVar2.O(i39, arrayList25, lVarB);
                            lVarB.a(arrayList25);
                            lVar4 = null;
                            i39 = 0;
                        }
                    }
                    HashSet hashSet = j(2).f24422a;
                    if (hashSet != null) {
                        Iterator it2 = hashSet.iterator();
                        while (it2.hasNext()) {
                            AbstractC3095h.b(((C2962c) it2.next()).f24425d, 0, arrayList25, null);
                        }
                    }
                    HashSet hashSet2 = j(4).f24422a;
                    if (hashSet2 != null) {
                        Iterator it3 = hashSet2.iterator();
                        while (it3.hasNext()) {
                            AbstractC3095h.b(((C2962c) it3.next()).f24425d, 0, arrayList25, null);
                        }
                    }
                    HashSet hashSet3 = j(7).f24422a;
                    if (hashSet3 != null) {
                        Iterator it4 = hashSet3.iterator();
                        while (it4.hasNext()) {
                            AbstractC3095h.b(((C2962c) it4.next()).f24425d, 0, arrayList25, null);
                        }
                    }
                    l lVar5 = null;
                    if (arrayList24 != null) {
                        Iterator it5 = arrayList24.iterator();
                        while (it5.hasNext()) {
                            AbstractC3095h.b((d) it5.next(), 0, arrayList25, null);
                        }
                    }
                    if (arrayList22 != null) {
                        Iterator it6 = arrayList22.iterator();
                        while (it6.hasNext()) {
                            AbstractC3095h.b((h) it6.next(), 1, arrayList25, null);
                        }
                    }
                    int i40 = 1;
                    if (arrayList23 != null) {
                        for (i iVar3 : arrayList23) {
                            l lVarB2 = AbstractC3095h.b(iVar3, i40, arrayList25, lVar5);
                            iVar3.O(i40, arrayList25, lVarB2);
                            lVarB2.a(arrayList25);
                            i40 = 1;
                            lVar5 = null;
                        }
                    }
                    HashSet hashSet4 = j(3).f24422a;
                    if (hashSet4 != null) {
                        Iterator it7 = hashSet4.iterator();
                        while (it7.hasNext()) {
                            AbstractC3095h.b(((C2962c) it7.next()).f24425d, 1, arrayList25, null);
                        }
                    }
                    HashSet hashSet5 = j(6).f24422a;
                    if (hashSet5 != null) {
                        Iterator it8 = hashSet5.iterator();
                        while (it8.hasNext()) {
                            AbstractC3095h.b(((C2962c) it8.next()).f24425d, 1, arrayList25, null);
                        }
                    }
                    HashSet hashSet6 = j(5).f24422a;
                    if (hashSet6 != null) {
                        Iterator it9 = hashSet6.iterator();
                        while (it9.hasNext()) {
                            AbstractC3095h.b(((C2962c) it9.next()).f24425d, 1, arrayList25, null);
                        }
                    }
                    HashSet hashSet7 = j(7).f24422a;
                    if (hashSet7 != null) {
                        Iterator it10 = hashSet7.iterator();
                        while (it10.hasNext()) {
                            AbstractC3095h.b(((C2962c) it10.next()).f24425d, 1, arrayList25, null);
                        }
                    }
                    if (arrayList12 != null) {
                        Iterator it11 = arrayList12.iterator();
                        while (it11.hasNext()) {
                            AbstractC3095h.b((d) it11.next(), 1, arrayList25, null);
                        }
                    }
                    int i41 = 0;
                    while (i41 < size3) {
                        d dVar11 = (d) arrayList7.get(i41);
                        int[] iArr5 = dVar11.f24475m0;
                        if (iArr5[0] == 3 && iArr5[1] == 3) {
                            int i42 = dVar11.f24472k0;
                            int size4 = arrayList25.size();
                            int i43 = 0;
                            while (true) {
                                if (i43 >= size4) {
                                    i14 = i41;
                                    lVar2 = null;
                                    break;
                                }
                                i14 = i41;
                                lVar2 = (l) arrayList25.get(i43);
                                int i44 = size4;
                                if (i42 == lVar2.f25278b) {
                                    break;
                                }
                                i43++;
                                size4 = i44;
                                i41 = i14;
                            }
                            int i45 = dVar11.f24473l0;
                            int size5 = arrayList25.size();
                            int i46 = 0;
                            while (true) {
                                if (i46 >= size5) {
                                    lVar3 = null;
                                    break;
                                }
                                lVar3 = (l) arrayList25.get(i46);
                                int i47 = size5;
                                if (i45 == lVar3.f25278b) {
                                    break;
                                }
                                i46++;
                                size5 = i47;
                            }
                            if (lVar2 != null && lVar3 != null) {
                                lVar2.c(0, lVar3);
                                lVar3.f25279c = 2;
                                arrayList25.remove(lVar2);
                            }
                        } else {
                            i14 = i41;
                        }
                        i41 = i14 + 1;
                    }
                    if (arrayList25.size() > 1) {
                        if (iArr[0] == 2) {
                            lVar = null;
                            int i48 = 0;
                            for (l lVar6 : arrayList25) {
                                if (lVar6.f25279c != 1 && (iB2 = lVar6.b(c2609c2, 0)) > i48) {
                                    lVar = lVar6;
                                    i48 = iB2;
                                }
                            }
                            c8 = 1;
                            if (lVar != null) {
                                I(1);
                                K(i48);
                            }
                            if (iArr[c8] != 2) {
                                l lVar7 = null;
                                int i49 = 0;
                                for (l lVar8 : arrayList25) {
                                    if (lVar8.f25279c != 0 && (iB = lVar8.b(c2609c2, 1)) > i49) {
                                        lVar7 = lVar8;
                                        i49 = iB;
                                    }
                                }
                                if (lVar7 != null) {
                                    J(1);
                                    H(i49);
                                } else {
                                    lVar7 = null;
                                }
                                if (lVar != null || lVar7 != null) {
                                    if (i17 == 2) {
                                        if (iMax5 >= o() || iMax5 <= 0) {
                                            iMax5 = o();
                                        } else {
                                            K(iMax5);
                                        }
                                    }
                                    if (i16 == 2) {
                                        if (iMax6 >= l() || iMax6 <= 0) {
                                            iMax6 = l();
                                        } else {
                                            H(iMax6);
                                        }
                                    }
                                    i6 = iMax6;
                                    i7 = iMax5;
                                    i8 = 1;
                                }
                            }
                        } else {
                            c8 = 1;
                        }
                        lVar = null;
                        if (iArr[c8] != 2) {
                        }
                    }
                }
            }
        }
        i6 = iMax6;
        i7 = iMax5;
        i8 = 0;
        boolean z12 = R(64) || R(128);
        c2609c2.getClass();
        c2609c2.f21584h = false;
        if (this.f24503x0 == 0 || !z12) {
            c6 = 1;
        } else {
            c6 = 1;
            c2609c2.f21584h = true;
        }
        ArrayList arrayList26 = this.f24493n0;
        boolean z13 = iArr[0] == 2 || iArr[c6] == 2;
        this.f24499t0 = 0;
        this.f24500u0 = 0;
        for (int i50 = 0; i50 < size; i50++) {
            d dVar12 = (d) this.f24493n0.get(i50);
            if (dVar12 instanceof e) {
                ((e) dVar12).P();
            }
        }
        boolean zR = R(64);
        int i51 = i8;
        int i52 = 0;
        int i53 = 1;
        while (i53 != 0) {
            int i54 = i52 + 1;
            try {
                c2609c2.t();
                this.f24499t0 = 0;
                this.f24500u0 = 0;
                h(c2609c2);
                for (int i55 = 0; i55 < size; i55++) {
                    ((d) this.f24493n0.get(i55)).h(c2609c2);
                }
                O(c2609c2);
                try {
                    WeakReference weakReference = this.f24504y0;
                    if (weakReference != null) {
                        try {
                            if (weakReference.get() != null) {
                                C2962c c2962c5 = (C2962c) this.f24504y0.get();
                                n1.e eVarK = c2609c2.k(c2962c3);
                                C2609c c2609c3 = this.f24498s0;
                                c2962c2 = c2962c3;
                                i9 = i51;
                                try {
                                    c2609c3.f(c2609c3.k(c2962c5), eVarK, 0, 5);
                                    this.f24504y0 = null;
                                } catch (Exception e6) {
                                    e = e6;
                                    i53 = 1;
                                    e.printStackTrace();
                                    System.out.println("EXCEPTION : " + e);
                                    boolean[] zArr2 = j.f24553a;
                                    if (i53 != 0) {
                                    }
                                    if (z13) {
                                    }
                                    iMax = Math.max(this.Y, o());
                                    if (iMax > o()) {
                                    }
                                    iMax2 = Math.max(this.f24454Z, l());
                                    if (iMax2 > l()) {
                                    }
                                    if (i9 == 0) {
                                    }
                                    i51 = i9;
                                    i12 = 8;
                                    if (i54 <= i12) {
                                    }
                                    i52 = i54;
                                    i53 = i10;
                                    c2962c3 = c2962c2;
                                }
                            } else {
                                c2962c2 = c2962c3;
                                i9 = i51;
                            }
                            try {
                                WeakReference weakReference2 = this.f24489A0;
                                if (weakReference2 != null && weakReference2.get() != null) {
                                    C2962c c2962c6 = (C2962c) this.f24489A0.get();
                                    n1.e eVarK2 = c2609c2.k(this.f24439I);
                                    C2609c c2609c4 = this.f24498s0;
                                    c2609c4.f(eVarK2, c2609c4.k(c2962c6), 0, 5);
                                    this.f24489A0 = null;
                                }
                                WeakReference weakReference3 = this.f24505z0;
                                if (weakReference3 != null && weakReference3.get() != null) {
                                    C2962c c2962c7 = (C2962c) this.f24505z0.get();
                                    C2962c c2962c8 = c2962c;
                                    try {
                                        n1.e eVarK3 = c2609c2.k(c2962c8);
                                        C2609c c2609c5 = this.f24498s0;
                                        c2962c = c2962c8;
                                        c2609c5.f(c2609c5.k(c2962c7), eVarK3, 0, 5);
                                        this.f24505z0 = null;
                                    } catch (Exception e7) {
                                        e = e7;
                                        c2962c = c2962c8;
                                        i53 = 1;
                                        e.printStackTrace();
                                        System.out.println("EXCEPTION : " + e);
                                    }
                                }
                                WeakReference weakReference4 = this.f24490B0;
                                if (weakReference4 == null || weakReference4.get() == null) {
                                    c7 = 5;
                                } else {
                                    C2962c c2962c9 = (C2962c) this.f24490B0.get();
                                    n1.e eVarK4 = c2609c2.k(this.f24438H);
                                    try {
                                        c2609c = this.f24498s0;
                                        c7 = 5;
                                    } catch (Exception e8) {
                                        e = e8;
                                        c7 = 5;
                                        i53 = 1;
                                        e.printStackTrace();
                                        System.out.println("EXCEPTION : " + e);
                                        boolean[] zArr22 = j.f24553a;
                                        if (i53 != 0) {
                                        }
                                        if (z13) {
                                            int iMax7 = 0;
                                            int iMax8 = 0;
                                            while (i13 < size) {
                                            }
                                            iMax3 = Math.max(this.Y, iMax7);
                                            iMax4 = Math.max(this.f24454Z, iMax8);
                                            if (i17 == 2) {
                                                K(iMax3);
                                                iArr[0] = 2;
                                                i10 = 1;
                                                i9 = 1;
                                            }
                                            if (i16 == 2) {
                                                H(iMax4);
                                                iArr[1] = 2;
                                                i10 = 1;
                                                i9 = 1;
                                            }
                                        }
                                        iMax = Math.max(this.Y, o());
                                        if (iMax > o()) {
                                        }
                                        iMax2 = Math.max(this.f24454Z, l());
                                        if (iMax2 > l()) {
                                        }
                                        if (i9 == 0) {
                                        }
                                        i51 = i9;
                                        i12 = 8;
                                        if (i54 <= i12) {
                                        }
                                        i52 = i54;
                                        i53 = i10;
                                        c2962c3 = c2962c2;
                                    }
                                    try {
                                        c2609c.f(eVarK4, c2609c.k(c2962c9), 0, 5);
                                    } catch (Exception e9) {
                                        e = e9;
                                        i53 = 1;
                                        e.printStackTrace();
                                        System.out.println("EXCEPTION : " + e);
                                    }
                                    try {
                                        this.f24490B0 = null;
                                    } catch (Exception e10) {
                                        e = e10;
                                        i53 = 1;
                                        e.printStackTrace();
                                        System.out.println("EXCEPTION : " + e);
                                    }
                                }
                                c2609c2.p();
                                i53 = 1;
                            } catch (Exception e11) {
                                e = e11;
                            }
                        } catch (Exception e12) {
                            e = e12;
                            c2962c2 = c2962c3;
                            i9 = i51;
                        }
                    }
                } catch (Exception e13) {
                    e = e13;
                    c2962c2 = c2962c3;
                    i9 = i51;
                }
            } catch (Exception e14) {
                e = e14;
                c2962c2 = c2962c3;
                i9 = i51;
            }
            boolean[] zArr222 = j.f24553a;
            if (i53 != 0) {
                zArr222[2] = false;
                boolean zR2 = R(64);
                M(c2609c2, zR2);
                int size6 = this.f24493n0.size();
                int i56 = 0;
                i10 = 0;
                while (i56 < size6) {
                    d dVar13 = (d) this.f24493n0.get(i56);
                    dVar13.M(c2609c2, zR2);
                    boolean[] zArr3 = zArr222;
                    boolean z14 = zR2;
                    if (dVar13.f24466h != -1 || dVar13.f24467i != -1) {
                        i10 = 1;
                    }
                    i56++;
                    zArr222 = zArr3;
                    zR2 = z14;
                }
                zArr = zArr222;
            } else {
                zArr = zArr222;
                M(c2609c2, zR);
                for (int i57 = 0; i57 < size; i57++) {
                    ((d) this.f24493n0.get(i57)).M(c2609c2, zR);
                }
                i10 = 0;
            }
            if (z13 && i54 < 8 && zArr[2]) {
                int iMax72 = 0;
                int iMax82 = 0;
                for (i13 = 0; i13 < size; i13++) {
                    d dVar14 = (d) this.f24493n0.get(i13);
                    iMax72 = Math.max(iMax72, dVar14.o() + dVar14.f24452V);
                    iMax82 = Math.max(iMax82, dVar14.l() + dVar14.f24453W);
                }
                iMax3 = Math.max(this.Y, iMax72);
                iMax4 = Math.max(this.f24454Z, iMax82);
                if (i17 == 2 && o() < iMax3) {
                    K(iMax3);
                    iArr[0] = 2;
                    i10 = 1;
                    i9 = 1;
                }
                if (i16 == 2 && l() < iMax4) {
                    H(iMax4);
                    iArr[1] = 2;
                    i10 = 1;
                    i9 = 1;
                }
            }
            iMax = Math.max(this.Y, o());
            if (iMax > o()) {
                K(iMax);
                i11 = 1;
                iArr[0] = 1;
                i10 = 1;
                i9 = 1;
            } else {
                i11 = 1;
            }
            iMax2 = Math.max(this.f24454Z, l());
            if (iMax2 > l()) {
                H(iMax2);
                iArr[i11] = i11;
                i10 = i11;
                i9 = i10;
            }
            if (i9 == 0) {
                if (iArr[0] == 2 && i7 > 0 && o() > i7) {
                    iArr[0] = i11;
                    K(i7);
                    i10 = i11;
                    i9 = i10;
                }
                if (iArr[i11] == 2 && i6 > 0 && l() > i6) {
                    iArr[i11] = i11;
                    H(i6);
                    i12 = 8;
                    i51 = 1;
                    i10 = 1;
                }
                if (i54 <= i12) {
                    i10 = 0;
                }
                i52 = i54;
                i53 = i10;
                c2962c3 = c2962c2;
            }
            i51 = i9;
            i12 = 8;
            if (i54 <= i12) {
            }
            i52 = i54;
            i53 = i10;
            c2962c3 = c2962c2;
        }
        int i58 = i51;
        this.f24493n0 = arrayList26;
        if (i58 != 0) {
            iArr[0] = i17;
            iArr[1] = i16;
        }
        D(c2609c2.f21588m);
    }

    public final boolean R(int i6) {
        return (this.f24503x0 & i6) == i6;
    }
}
