package defpackage;

import androidx.media3.extractor.ts.TsExtractor;
import defpackage.cd1;
import defpackage.sc1;
import defpackage.t80;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;

/* JADX INFO: loaded from: classes.dex */
public class dd1 extends vpa {
    public final t80 bs;
    public final c52 bt;
    public int bu;
    public t80.b bv;
    public boolean bw;
    public final e95 bx;
    public int bz;
    public int ca;
    public int cb;
    public int cc;
    public bu0[] cd;
    public bu0[] ce;
    public int cf;
    public boolean cg;
    public boolean ch;
    public WeakReference ci;
    public WeakReference cj;
    public WeakReference ck;
    public WeakReference cl;
    public final HashSet cm;
    public final t80.a cn;

    public dd1() {
        this.br = new ArrayList();
        this.bs = new t80(this);
        c52 c52Var = new c52();
        c52Var.b = true;
        c52Var.c = true;
        c52Var.e = new ArrayList();
        new ArrayList();
        c52Var.f = null;
        c52Var.g = new t80.a();
        c52Var.h = new ArrayList();
        c52Var.a = this;
        c52Var.d = this;
        this.bt = c52Var;
        this.bv = null;
        this.bw = false;
        this.bx = new e95();
        this.cb = 0;
        this.cc = 0;
        this.cd = new bu0[4];
        this.ce = new bu0[4];
        this.cf = TsExtractor.TS_STREAM_TYPE_AIT;
        this.cg = false;
        this.ch = false;
        this.ci = null;
        this.cj = null;
        this.ck = null;
        this.cl = null;
        this.cm = new HashSet();
        this.cn = new t80.a();
    }

    public static void av(cd1 cd1Var, t80.b bVar, t80.a aVar) {
        int i;
        int i2;
        if (bVar == null) {
            return;
        }
        int i3 = cd1Var.bi;
        int[] iArr = cd1Var.t;
        if (i3 == 8 || (cd1Var instanceof xy3) || (cd1Var instanceof o60)) {
            aVar.e = 0;
            aVar.f = 0;
            return;
        }
        cd1.b[] bVarArr = cd1Var.au;
        aVar.a = bVarArr[0];
        aVar.b = bVarArr[1];
        aVar.c = cd1Var.r();
        aVar.d = cd1Var.l();
        aVar.i = false;
        aVar.j = 0;
        cd1.b bVar2 = aVar.a;
        cd1.b bVar3 = cd1.b.c;
        boolean z = bVar2 == bVar3;
        boolean z2 = aVar.b == bVar3;
        boolean z3 = z && cd1Var.ay > 0.0f;
        boolean z4 = z2 && cd1Var.ay > 0.0f;
        cd1.b bVar4 = cd1.b.b;
        cd1.b bVar5 = cd1.b.a;
        if (z && cd1Var.u(0) && cd1Var.r == 0 && !z3) {
            aVar.a = bVar4;
            if (z2 && cd1Var.s == 0) {
                aVar.a = bVar5;
            }
            z = false;
        }
        if (z2 && cd1Var.u(1) && cd1Var.s == 0 && !z4) {
            aVar.b = bVar4;
            if (z && cd1Var.r == 0) {
                aVar.b = bVar5;
            }
            z2 = false;
        }
        if (cd1Var.ab()) {
            aVar.a = bVar5;
            z = false;
        }
        if (cd1Var.ac()) {
            aVar.b = bVar5;
            z2 = false;
        }
        if (z3) {
            if (iArr[0] == 4) {
                aVar.a = bVar5;
            } else if (!z2) {
                if (aVar.b == bVar5) {
                    i2 = aVar.d;
                } else {
                    aVar.a = bVar4;
                    bVar.b(cd1Var, aVar);
                    i2 = aVar.f;
                }
                aVar.a = bVar5;
                aVar.c = (int) (cd1Var.ay * i2);
            }
        }
        if (z4) {
            if (iArr[1] == 4) {
                aVar.b = bVar5;
            } else if (!z) {
                if (aVar.a == bVar5) {
                    i = aVar.c;
                } else {
                    aVar.b = bVar4;
                    bVar.b(cd1Var, aVar);
                    i = aVar.e;
                }
                aVar.b = bVar5;
                if (cd1Var.az == -1) {
                    aVar.d = (int) (i / cd1Var.ay);
                } else {
                    aVar.d = (int) (cd1Var.ay * i);
                }
            }
        }
        bVar.b(cd1Var, aVar);
        cd1Var.ap(aVar.e);
        cd1Var.am(aVar.f);
        cd1Var.ae = aVar.h;
        cd1Var.aj(aVar.g);
        aVar.j = 0;
    }

    @Override // defpackage.vpa, defpackage.cd1
    public final void ad() {
        this.bx.t();
        this.bz = 0;
        this.ca = 0;
        super.ad();
    }

    @Override // defpackage.cd1
    public final void aq(boolean z, boolean z2) {
        super.aq(z, z2);
        int size = this.br.size();
        for (int i = 0; i < size; i++) {
            ((cd1) this.br.get(i)).aq(z, z2);
        }
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Removed duplicated region for block: B:226:0x03bb  */
    /* JADX WARN: Removed duplicated region for block: B:360:0x0639  */
    /* JADX WARN: Removed duplicated region for block: B:375:0x066b  */
    /* JADX WARN: Removed duplicated region for block: B:400:0x06b9  */
    /* JADX WARN: Removed duplicated region for block: B:405:0x06ca  */
    /* JADX WARN: Removed duplicated region for block: B:412:0x06da  */
    /* JADX WARN: Removed duplicated region for block: B:415:0x06e4  */
    /* JADX WARN: Removed duplicated region for block: B:421:0x0701  */
    /* JADX WARN: Removed duplicated region for block: B:485:0x0815  */
    /* JADX WARN: Removed duplicated region for block: B:494:0x0854  */
    /* JADX WARN: Removed duplicated region for block: B:500:0x0870 A[ADDED_TO_REGION] */
    /* JADX WARN: Removed duplicated region for block: B:515:0x08d8  */
    /* JADX WARN: Removed duplicated region for block: B:518:0x08ea  */
    /* JADX WARN: Removed duplicated region for block: B:521:0x0906  */
    /* JADX WARN: Removed duplicated region for block: B:522:0x0912  */
    /* JADX WARN: Removed duplicated region for block: B:524:0x0915  */
    /* JADX WARN: Removed duplicated region for block: B:536:0x094d A[PHI: r15 r25
      0x094d: PHI (r15v10 ??) = (r15v9 ??), (r15v14 ??), (r15v14 ??), (r15v14 ??) binds: [B:523:0x0913, B:531:0x0935, B:532:0x0937, B:534:0x093d] A[DONT_GENERATE, DONT_INLINE]
      0x094d: PHI (r25v8 boolean) = (r25v7 boolean), (r25v9 boolean), (r25v9 boolean), (r25v9 boolean) binds: [B:523:0x0913, B:531:0x0935, B:532:0x0937, B:534:0x093d] A[DONT_GENERATE, DONT_INLINE]] */
    /* JADX WARN: Removed duplicated region for block: B:538:0x0953  */
    /* JADX WARN: Removed duplicated region for block: B:542:0x0963  */
    /* JADX WARN: Removed duplicated region for block: B:610:0x0954 A[SYNTHETIC] */
    /* JADX WARN: Type inference failed for: r10v14 */
    /* JADX WARN: Type inference failed for: r10v15, types: [boolean] */
    /* JADX WARN: Type inference failed for: r10v17 */
    /* JADX WARN: Type inference failed for: r15v10 */
    /* JADX WARN: Type inference failed for: r15v109 */
    /* JADX WARN: Type inference failed for: r15v11 */
    /* JADX WARN: Type inference failed for: r15v110 */
    /* JADX WARN: Type inference failed for: r15v111 */
    /* JADX WARN: Type inference failed for: r15v117 */
    /* JADX WARN: Type inference failed for: r15v118 */
    /* JADX WARN: Type inference failed for: r15v119 */
    /* JADX WARN: Type inference failed for: r15v12 */
    /* JADX WARN: Type inference failed for: r15v120 */
    /* JADX WARN: Type inference failed for: r15v121 */
    /* JADX WARN: Type inference failed for: r15v122 */
    /* JADX WARN: Type inference failed for: r15v13 */
    /* JADX WARN: Type inference failed for: r15v14 */
    /* JADX WARN: Type inference failed for: r15v15 */
    /* JADX WARN: Type inference failed for: r15v16 */
    /* JADX WARN: Type inference failed for: r15v17 */
    /* JADX WARN: Type inference failed for: r15v2 */
    /* JADX WARN: Type inference failed for: r15v26 */
    /* JADX WARN: Type inference failed for: r15v28 */
    /* JADX WARN: Type inference failed for: r15v3 */
    /* JADX WARN: Type inference failed for: r15v32 */
    /* JADX WARN: Type inference failed for: r15v4 */
    /* JADX WARN: Type inference failed for: r15v9 */
    /* JADX WARN: Type inference failed for: r32v0, types: [cd1, dd1, vpa] */
    @Override // defpackage.vpa
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void as() {
        int i;
        sc1 sc1Var;
        int i2;
        sc1 sc1Var2;
        int iL;
        int i3;
        boolean z;
        char c;
        int i4;
        int i5;
        ?? r15;
        boolean z2;
        boolean z3;
        cd1.b bVar;
        boolean z4;
        ?? r152;
        boolean[] zArr;
        boolean z5;
        int iMax;
        int iMax2;
        ?? r10;
        ?? r153;
        int i6;
        ?? r154;
        ?? r155;
        sc1 sc1Var3;
        int i7;
        int i8;
        cd1.b bVar2;
        xpa xpaVar;
        xpa xpaVar2;
        boolean z6;
        ArrayList arrayList;
        ArrayList arrayList2;
        ArrayList arrayList3;
        ArrayList arrayList4;
        ArrayList arrayList5;
        int i9;
        sc1 sc1Var4;
        this.ba = 0;
        this.bb = 0;
        this.cg = false;
        this.ch = false;
        int size = this.br.size();
        int iMax3 = Math.max(0, r());
        int iMax4 = Math.max(0, l());
        cd1.b[] bVarArr = this.au;
        cd1.b bVar3 = bVarArr[1];
        cd1.b bVar4 = bVarArr[0];
        int i10 = this.bu;
        cd1.b bVar5 = cd1.b.c;
        sc1 sc1Var5 = this.ak;
        sc1 sc1Var6 = this.aj;
        cd1.b bVar6 = cd1.b.a;
        if (i10 == 0 && rx6.b(this.cf, 1)) {
            t80.b bVar7 = this.bv;
            cd1.b[] bVarArr2 = this.au;
            cd1.b bVar8 = bVarArr2[0];
            cd1.b bVar9 = bVarArr2[1];
            af();
            ArrayList arrayList6 = this.br;
            int size2 = arrayList6.size();
            for (int i11 = 0; i11 < size2; i11++) {
                ((cd1) arrayList6.get(i11)).af();
            }
            boolean z7 = this.bw;
            if (bVar8 == bVar6) {
                i = iMax4;
                ak(0, r());
            } else {
                i = iMax4;
                sc1Var6.l(0);
                this.ba = 0;
            }
            boolean z8 = false;
            int i12 = 0;
            boolean z9 = false;
            while (i12 < size2) {
                boolean z10 = z8;
                cd1 cd1Var = (cd1) arrayList6.get(i12);
                int i13 = i12;
                if (cd1Var instanceof xy3) {
                    xy3 xy3Var = (xy3) cd1Var;
                    sc1Var4 = sc1Var6;
                    if (xy3Var.bv == 1) {
                        int i14 = xy3Var.bs;
                        if (i14 != -1) {
                            xy3Var.as(i14);
                        } else if (xy3Var.bt != -1 && ab()) {
                            xy3Var.as(r() - xy3Var.bt);
                        } else if (ab()) {
                            xy3Var.as((int) ((xy3Var.br * r()) + 0.5f));
                        }
                        z10 = true;
                    }
                } else {
                    sc1Var4 = sc1Var6;
                    if ((cd1Var instanceof o60) && ((o60) cd1Var).au() == 0) {
                        z8 = z10;
                        z9 = true;
                    }
                    i12 = i13 + 1;
                    sc1Var6 = sc1Var4;
                }
                z8 = z10;
                i12 = i13 + 1;
                sc1Var6 = sc1Var4;
            }
            sc1Var = sc1Var6;
            if (z8) {
                for (int i15 = 0; i15 < size2; i15 = i9 + 1) {
                    cd1 cd1Var2 = (cd1) arrayList6.get(i15);
                    if (cd1Var2 instanceof xy3) {
                        xy3 xy3Var2 = (xy3) cd1Var2;
                        i9 = i15;
                        if (xy3Var2.bv == 1) {
                            va2.b(0, bVar7, xy3Var2, z7);
                        }
                    } else {
                        i9 = i15;
                    }
                }
            }
            va2.b(0, bVar7, this, z7);
            if (z9) {
                for (int i16 = 0; i16 < size2; i16++) {
                    cd1 cd1Var3 = (cd1) arrayList6.get(i16);
                    if (cd1Var3 instanceof o60) {
                        o60 o60Var = (o60) cd1Var3;
                        if (o60Var.au() == 0 && o60Var.at()) {
                            va2.b(1, bVar7, o60Var, z7);
                        }
                    }
                }
            }
            if (bVar9 == bVar6) {
                al(0, l());
            } else {
                sc1Var5.l(0);
                this.bb = 0;
            }
            int i17 = 0;
            boolean z11 = false;
            boolean z12 = false;
            while (i17 < size2) {
                cd1 cd1Var4 = (cd1) arrayList6.get(i17);
                int i18 = i17;
                if (cd1Var4 instanceof xy3) {
                    xy3 xy3Var3 = (xy3) cd1Var4;
                    if (xy3Var3.bv == 0) {
                        int i19 = xy3Var3.bs;
                        if (i19 != -1) {
                            xy3Var3.as(i19);
                        } else if (xy3Var3.bt != -1 && ac()) {
                            xy3Var3.as(l() - xy3Var3.bt);
                        } else if (ac()) {
                            xy3Var3.as((int) ((xy3Var3.br * l()) + 0.5f));
                        }
                        z11 = true;
                    }
                } else if ((cd1Var4 instanceof o60) && ((o60) cd1Var4).au() == 1) {
                    z12 = true;
                }
                i17 = i18 + 1;
            }
            if (z11) {
                for (int i20 = 0; i20 < size2; i20++) {
                    cd1 cd1Var5 = (cd1) arrayList6.get(i20);
                    if (cd1Var5 instanceof xy3) {
                        xy3 xy3Var4 = (xy3) cd1Var5;
                        if (xy3Var4.bv == 0) {
                            va2.g(1, bVar7, xy3Var4);
                        }
                    }
                }
            }
            va2.g(0, bVar7, this);
            if (z12) {
                for (int i21 = 0; i21 < size2; i21++) {
                    cd1 cd1Var6 = (cd1) arrayList6.get(i21);
                    if (cd1Var6 instanceof o60) {
                        o60 o60Var2 = (o60) cd1Var6;
                        if (o60Var2.au() == 1 && o60Var2.at()) {
                            va2.g(1, bVar7, o60Var2);
                        }
                    }
                }
            }
            for (int i22 = 0; i22 < size2; i22++) {
                cd1 cd1Var7 = (cd1) arrayList6.get(i22);
                if (cd1Var7.aa() && va2.a(cd1Var7)) {
                    av(cd1Var7, bVar7, va2.a);
                    if (!(cd1Var7 instanceof xy3)) {
                        va2.b(0, bVar7, cd1Var7, z7);
                        va2.g(0, bVar7, cd1Var7);
                    } else if (((xy3) cd1Var7).bv == 0) {
                        va2.g(0, bVar7, cd1Var7);
                    } else {
                        va2.b(0, bVar7, cd1Var7, z7);
                    }
                }
            }
            for (int i23 = 0; i23 < size; i23++) {
                cd1 cd1Var8 = (cd1) this.br.get(i23);
                if (cd1Var8.aa() && !(cd1Var8 instanceof xy3) && !(cd1Var8 instanceof o60) && !(cd1Var8 instanceof oma) && !cd1Var8.ag) {
                    cd1.b bVarK = cd1Var8.k(0);
                    cd1.b bVarK2 = cd1Var8.k(1);
                    if (bVarK != bVar5 || cd1Var8.r == 1 || bVarK2 != bVar5 || cd1Var8.s == 1) {
                        av(cd1Var8, this.bv, new t80.a());
                    }
                }
            }
        } else {
            i = iMax4;
            sc1Var = sc1Var6;
        }
        cd1.b bVar10 = cd1.b.b;
        e95 e95Var = this.bx;
        if (size > 2 && ((bVar4 == bVar10 || bVar3 == bVar10) && rx6.b(this.cf, 1024))) {
            t80.b bVar11 = this.bv;
            ArrayList arrayList7 = this.br;
            int size3 = arrayList7.size();
            int i24 = 0;
            while (true) {
                if (i24 < size3) {
                    cd1 cd1Var9 = (cd1) arrayList7.get(i24);
                    cd1.b[] bVarArr3 = this.au;
                    cd1.b bVar12 = bVarArr3[0];
                    int i25 = i24;
                    cd1.b bVar13 = bVarArr3[1];
                    sc1Var2 = sc1Var5;
                    cd1.b[] bVarArr4 = cd1Var9.au;
                    i2 = size;
                    if (!hy3.b(bVar12, bVar13, bVarArr4[0], bVarArr4[1]) || (cd1Var9 instanceof i43)) {
                        break;
                    }
                    i24 = i25 + 1;
                    sc1Var5 = sc1Var2;
                    size = i2;
                } else {
                    i2 = size;
                    sc1Var2 = sc1Var5;
                    int i26 = 0;
                    ArrayList arrayList8 = null;
                    ArrayList arrayList9 = null;
                    ArrayList arrayList10 = null;
                    ArrayList arrayList11 = null;
                    ArrayList arrayList12 = null;
                    ArrayList arrayList13 = null;
                    while (i26 < size3) {
                        int i27 = i26;
                        cd1 cd1Var10 = (cd1) arrayList7.get(i26);
                        ArrayList arrayList14 = arrayList8;
                        cd1.b[] bVarArr5 = this.au;
                        cd1.b bVar14 = bVarArr5[0];
                        ArrayList arrayList15 = arrayList9;
                        cd1.b bVar15 = bVarArr5[1];
                        ArrayList arrayList16 = arrayList10;
                        cd1.b[] bVarArr6 = cd1Var10.au;
                        ArrayList arrayList17 = arrayList11;
                        if (!hy3.b(bVar14, bVar15, bVarArr6[0], bVarArr6[1])) {
                            av(cd1Var10, bVar11, this.cn);
                        }
                        boolean z13 = cd1Var10 instanceof xy3;
                        if (z13) {
                            xy3 xy3Var5 = (xy3) cd1Var10;
                            if (xy3Var5.bv == 0) {
                                arrayList2 = arrayList16 == null ? new ArrayList() : arrayList16;
                                arrayList2.add(xy3Var5);
                            } else {
                                arrayList2 = arrayList16;
                            }
                            z6 = z13;
                            if (xy3Var5.bv == 1) {
                                arrayList = arrayList14 == null ? new ArrayList() : arrayList14;
                                arrayList.add(xy3Var5);
                            } else {
                                arrayList = arrayList14;
                            }
                        } else {
                            z6 = z13;
                            arrayList = arrayList14;
                            arrayList2 = arrayList16;
                        }
                        if (!(cd1Var10 instanceof d24)) {
                            arrayList3 = arrayList;
                            arrayList4 = arrayList2;
                            arrayList9 = arrayList15;
                        } else if (cd1Var10 instanceof o60) {
                            o60 o60Var3 = (o60) cd1Var10;
                            if (o60Var3.au() == 0) {
                                arrayList5 = arrayList15 == null ? new ArrayList() : arrayList15;
                                arrayList5.add(o60Var3);
                            } else {
                                arrayList5 = arrayList15;
                            }
                            arrayList3 = arrayList;
                            arrayList4 = arrayList2;
                            if (o60Var3.au() == 1) {
                                ArrayList arrayList18 = arrayList17 == null ? new ArrayList() : arrayList17;
                                arrayList18.add(o60Var3);
                                arrayList17 = arrayList18;
                            }
                            arrayList9 = arrayList5;
                        } else {
                            arrayList3 = arrayList;
                            arrayList4 = arrayList2;
                            d24 d24Var = (d24) cd1Var10;
                            arrayList9 = arrayList15 == null ? new ArrayList() : arrayList15;
                            arrayList9.add(d24Var);
                            arrayList11 = arrayList17 == null ? new ArrayList() : arrayList17;
                            arrayList11.add(d24Var);
                            if (cd1Var10.aj.f == null && cd1Var10.al.f == null && !z6 && !(cd1Var10 instanceof o60)) {
                                if (arrayList12 == null) {
                                    arrayList12 = new ArrayList();
                                }
                                ArrayList arrayList19 = arrayList12;
                                arrayList19.add(cd1Var10);
                                arrayList12 = arrayList19;
                            }
                            if (cd1Var10.ak.f != null && cd1Var10.am.f == null && cd1Var10.an.f == null && !z6 && !(cd1Var10 instanceof o60)) {
                                if (arrayList13 == null) {
                                    arrayList13 = new ArrayList();
                                }
                                ArrayList arrayList20 = arrayList13;
                                arrayList20.add(cd1Var10);
                                arrayList13 = arrayList20;
                            }
                            i26 = i27 + 1;
                            arrayList8 = arrayList3;
                            arrayList10 = arrayList4;
                        }
                        arrayList11 = arrayList17;
                        if (cd1Var10.aj.f == null) {
                            if (arrayList12 == null) {
                            }
                            ArrayList arrayList192 = arrayList12;
                            arrayList192.add(cd1Var10);
                            arrayList12 = arrayList192;
                        }
                        if (cd1Var10.ak.f != null) {
                        }
                        i26 = i27 + 1;
                        arrayList8 = arrayList3;
                        arrayList10 = arrayList4;
                    }
                    ArrayList arrayList21 = arrayList8;
                    ArrayList<d24> arrayList22 = arrayList9;
                    ArrayList arrayList23 = arrayList10;
                    ArrayList arrayList24 = arrayList11;
                    ArrayList<xpa> arrayList25 = new ArrayList();
                    if (arrayList21 != null) {
                        Iterator it = arrayList21.iterator();
                        while (it.hasNext()) {
                            hy3.a((xy3) it.next(), 0, arrayList25, null);
                        }
                    }
                    xpa xpaVar3 = null;
                    int i28 = 0;
                    if (arrayList22 != null) {
                        for (d24 d24Var2 : arrayList22) {
                            xpa xpaVarA = hy3.a(d24Var2, i28, arrayList25, xpaVar3);
                            d24Var2.as(i28, xpaVarA, arrayList25);
                            xpaVarA.a(arrayList25);
                            xpaVar3 = null;
                            i28 = 0;
                        }
                    }
                    HashSet hashSet = j(sc1.b.a).a;
                    if (hashSet != null) {
                        Iterator it2 = hashSet.iterator();
                        while (it2.hasNext()) {
                            hy3.a(((sc1) it2.next()).d, 0, arrayList25, null);
                        }
                    }
                    HashSet hashSet2 = j(sc1.b.c).a;
                    if (hashSet2 != null) {
                        Iterator it3 = hashSet2.iterator();
                        while (it3.hasNext()) {
                            hy3.a(((sc1) it3.next()).d, 0, arrayList25, null);
                        }
                    }
                    sc1.b bVar16 = sc1.b.f;
                    HashSet hashSet3 = j(bVar16).a;
                    if (hashSet3 != null) {
                        Iterator it4 = hashSet3.iterator();
                        while (it4.hasNext()) {
                            hy3.a(((sc1) it4.next()).d, 0, arrayList25, null);
                        }
                    }
                    xpa xpaVar4 = null;
                    if (arrayList12 != null) {
                        Iterator it5 = arrayList12.iterator();
                        while (it5.hasNext()) {
                            hy3.a((cd1) it5.next(), 0, arrayList25, null);
                        }
                    }
                    if (arrayList23 != null) {
                        Iterator it6 = arrayList23.iterator();
                        while (it6.hasNext()) {
                            hy3.a((xy3) it6.next(), 1, arrayList25, null);
                        }
                    }
                    int i29 = 1;
                    if (arrayList24 != null) {
                        Iterator it7 = arrayList24.iterator();
                        while (it7.hasNext()) {
                            d24 d24Var3 = (d24) it7.next();
                            Iterator it8 = it7;
                            xpa xpaVarA2 = hy3.a(d24Var3, i29, arrayList25, xpaVar4);
                            d24Var3.as(i29, xpaVarA2, arrayList25);
                            xpaVarA2.a(arrayList25);
                            it7 = it8;
                            xpaVar4 = null;
                            i29 = 1;
                        }
                    }
                    HashSet hashSet4 = j(sc1.b.b).a;
                    if (hashSet4 != null) {
                        Iterator it9 = hashSet4.iterator();
                        while (it9.hasNext()) {
                            hy3.a(((sc1) it9.next()).d, 1, arrayList25, null);
                        }
                    }
                    HashSet hashSet5 = j(sc1.b.e).a;
                    if (hashSet5 != null) {
                        Iterator it10 = hashSet5.iterator();
                        while (it10.hasNext()) {
                            hy3.a(((sc1) it10.next()).d, 1, arrayList25, null);
                        }
                    }
                    HashSet hashSet6 = j(sc1.b.d).a;
                    if (hashSet6 != null) {
                        Iterator it11 = hashSet6.iterator();
                        while (it11.hasNext()) {
                            hy3.a(((sc1) it11.next()).d, 1, arrayList25, null);
                        }
                    }
                    HashSet hashSet7 = j(bVar16).a;
                    if (hashSet7 != null) {
                        Iterator it12 = hashSet7.iterator();
                        while (it12.hasNext()) {
                            hy3.a(((sc1) it12.next()).d, 1, arrayList25, null);
                        }
                    }
                    char c2 = 1;
                    if (arrayList13 != null) {
                        Iterator it13 = arrayList13.iterator();
                        while (it13.hasNext()) {
                            hy3.a((cd1) it13.next(), 1, arrayList25, null);
                        }
                    }
                    int i30 = 0;
                    while (i30 < size3) {
                        cd1 cd1Var11 = (cd1) arrayList7.get(i30);
                        cd1.b[] bVarArr7 = cd1Var11.au;
                        if (bVarArr7[0] == bVar5 && bVarArr7[c2] == bVar5) {
                            int i31 = cd1Var11.bp;
                            int size4 = arrayList25.size();
                            int i32 = 0;
                            while (true) {
                                if (i32 >= size4) {
                                    i8 = i30;
                                    bVar2 = bVar5;
                                    xpaVar = null;
                                    break;
                                }
                                i8 = i30;
                                xpaVar = (xpa) arrayList25.get(i32);
                                bVar2 = bVar5;
                                if (i31 == xpaVar.b) {
                                    break;
                                }
                                i32++;
                                bVar5 = bVar2;
                                i30 = i8;
                            }
                            int i33 = cd1Var11.bq;
                            int size5 = arrayList25.size();
                            int i34 = 0;
                            while (true) {
                                if (i34 >= size5) {
                                    xpaVar2 = null;
                                    break;
                                }
                                xpaVar2 = (xpa) arrayList25.get(i34);
                                if (i33 == xpaVar2.b) {
                                    break;
                                } else {
                                    i34++;
                                }
                            }
                            if (xpaVar != null && xpaVar2 != null) {
                                xpaVar.c(0, xpaVar2);
                                xpaVar2.c = 2;
                                arrayList25.remove(xpaVar);
                            }
                        } else {
                            i8 = i30;
                            bVar2 = bVar5;
                        }
                        i30 = i8 + 1;
                        bVar5 = bVar2;
                        c2 = 1;
                    }
                    if (arrayList25.size() <= 1) {
                        break;
                    }
                    int i35 = 0;
                    if (this.au[0] == bVar10) {
                        int i36 = 0;
                        xpa xpaVar5 = null;
                        for (xpa xpaVar6 : arrayList25) {
                            if (xpaVar6.c != 1) {
                                int iB = xpaVar6.b(e95Var, i35);
                                if (iB > i36) {
                                    xpaVar5 = xpaVar6;
                                    i36 = iB;
                                }
                                i35 = 0;
                            }
                        }
                        if (xpaVar5 != null) {
                            an(bVar6);
                            ap(i36);
                        } else {
                            xpaVar5 = null;
                        }
                        int i37 = 1;
                        if (this.au[1] == bVar10) {
                            int i38 = 0;
                            xpa xpaVar7 = null;
                            for (xpa xpaVar8 : arrayList25) {
                                if (xpaVar8.c != 0) {
                                    int iB2 = xpaVar8.b(e95Var, i37);
                                    if (iB2 > i38) {
                                        xpaVar7 = xpaVar8;
                                        i38 = iB2;
                                    }
                                    i37 = 1;
                                }
                            }
                            if (xpaVar7 != null) {
                                ao(bVar6);
                                am(i38);
                            } else {
                                xpaVar7 = null;
                            }
                            if (xpaVar5 != null || xpaVar7 != null) {
                                if (bVar4 == bVar10) {
                                    if (iMax3 >= r() || iMax3 <= 0) {
                                        iMax3 = r();
                                    } else {
                                        ap(iMax3);
                                        this.cg = true;
                                    }
                                }
                                if (bVar3 == bVar10) {
                                    i7 = i;
                                    if (i7 >= l() || i7 <= 0) {
                                        iL = l();
                                        i3 = iMax3;
                                        z = true;
                                    } else {
                                        am(i7);
                                        this.ch = true;
                                    }
                                } else {
                                    i7 = i;
                                }
                                iL = i7;
                                i3 = iMax3;
                                z = true;
                            }
                        }
                    }
                }
            }
            boolean z14 = !aw(64) || aw(128);
            e95Var.getClass();
            e95Var.g = false;
            if (this.cf == 0 && z14) {
                c = 1;
                e95Var.g = true;
            } else {
                c = 1;
            }
            ArrayList arrayList26 = this.br;
            cd1.b[] bVarArr8 = this.au;
            boolean z15 = bVarArr8[0] != bVar10 || bVarArr8[c] == bVar10;
            this.cb = 0;
            this.cc = 0;
            i4 = i2;
            for (i5 = 0; i5 < i4; i5++) {
                cd1 cd1Var12 = (cd1) this.br.get(i5);
                if (cd1Var12 instanceof vpa) {
                    ((vpa) cd1Var12).as();
                }
            }
            boolean zAw = aw(64);
            boolean z16 = z;
            int i39 = 0;
            r15 = 1;
            while (r15 != 0) {
                int i40 = i39 + 1;
                try {
                    e95Var.t();
                    z3 = z15;
                } catch (Exception e) {
                    e = e;
                    z3 = z15;
                }
                try {
                    this.cb = 0;
                    this.cc = 0;
                    h(e95Var);
                    for (int i41 = 0; i41 < i4; i41++) {
                        ((cd1) this.br.get(i41)).h(e95Var);
                    }
                    au(e95Var);
                    try {
                        WeakReference weakReference = this.ci;
                        if (weakReference == null || weakReference.get() == null) {
                            bVar = bVar6;
                            z4 = z16;
                            sc1Var3 = sc1Var2;
                        } else {
                            sc1Var3 = sc1Var2;
                            try {
                                bVar = bVar6;
                                z4 = z16;
                            } catch (Exception e2) {
                                e = e2;
                                bVar = bVar6;
                                z4 = z16;
                            }
                            try {
                                e95Var.f(e95Var.k((sc1) this.ci.get()), e95Var.k(sc1Var3), 0, 5);
                                this.ci = null;
                            } catch (Exception e3) {
                                e = e3;
                                sc1Var2 = sc1Var3;
                                r155 = 1;
                                e.printStackTrace();
                                System.out.println("EXCEPTION : " + e);
                                r152 = r155;
                                boolean[] zArr2 = rx6.a;
                                if (r152 != 0) {
                                }
                                if (z3) {
                                }
                                iMax = Math.max(this.bd, r());
                                boolean z17 = z5;
                                if (iMax > r()) {
                                }
                                iMax2 = Math.max(this.be, l());
                                if (iMax2 > l()) {
                                }
                                if (!z4) {
                                }
                                if (i40 > i6) {
                                }
                                i39 = i40;
                                z15 = z3;
                                bVar6 = bVar;
                                r15 = r154;
                            }
                        }
                        try {
                            WeakReference weakReference2 = this.ck;
                            if (weakReference2 != null && weakReference2.get() != null) {
                                e95Var.f(e95Var.k(this.am), e95Var.k((sc1) this.ck.get()), 0, 5);
                                this.ck = null;
                            }
                            WeakReference weakReference3 = this.cj;
                            if (weakReference3 != null && weakReference3.get() != null) {
                                sc1 sc1Var7 = sc1Var;
                                try {
                                    sc1Var = sc1Var7;
                                    e95Var.f(e95Var.k((sc1) this.cj.get()), e95Var.k(sc1Var7), 0, 5);
                                    this.cj = null;
                                } catch (Exception e4) {
                                    e = e4;
                                    sc1Var = sc1Var7;
                                    sc1Var2 = sc1Var3;
                                    r155 = 1;
                                    e.printStackTrace();
                                    System.out.println("EXCEPTION : " + e);
                                    r152 = r155;
                                }
                            }
                            WeakReference weakReference4 = this.cl;
                            if (weakReference4 != null && weakReference4.get() != null) {
                                e95Var.f(e95Var.k(this.al), e95Var.k((sc1) this.cl.get()), 0, 5);
                                try {
                                    this.cl = null;
                                } catch (Exception e5) {
                                    e = e5;
                                    sc1Var2 = sc1Var3;
                                    r155 = 1;
                                    e.printStackTrace();
                                    System.out.println("EXCEPTION : " + e);
                                    r152 = r155;
                                }
                            }
                            e95Var.p();
                            sc1Var2 = sc1Var3;
                            r152 = 1;
                        } catch (Exception e6) {
                            e = e6;
                        }
                    } catch (Exception e7) {
                        e = e7;
                        bVar = bVar6;
                        z4 = z16;
                    }
                } catch (Exception e8) {
                    e = e8;
                    bVar = bVar6;
                    z4 = z16;
                    r155 = r15;
                    e.printStackTrace();
                    System.out.println("EXCEPTION : " + e);
                    r152 = r155;
                    boolean[] zArr22 = rx6.a;
                    if (r152 != 0) {
                    }
                    if (z3) {
                    }
                    iMax = Math.max(this.bd, r());
                    boolean z172 = z5;
                    if (iMax > r()) {
                    }
                    iMax2 = Math.max(this.be, l());
                    if (iMax2 > l()) {
                    }
                    if (!z4) {
                    }
                    if (i40 > i6) {
                    }
                    i39 = i40;
                    z15 = z3;
                    bVar6 = bVar;
                    r15 = r154;
                }
                boolean[] zArr222 = rx6.a;
                if (r152 != 0) {
                    zArr222[2] = false;
                    boolean zAw2 = aw(64);
                    ar(e95Var, zAw2);
                    int size6 = this.br.size();
                    int i42 = 0;
                    boolean z18 = false;
                    while (i42 < size6) {
                        boolean[] zArr3 = zArr222;
                        cd1 cd1Var13 = (cd1) this.br.get(i42);
                        cd1Var13.ar(e95Var, zAw2);
                        int i43 = i42;
                        boolean z19 = zAw2;
                        if (cd1Var13.h != -1 || cd1Var13.i != -1) {
                            z18 = true;
                        }
                        i42 = i43 + 1;
                        zArr222 = zArr3;
                        zAw2 = z19;
                        z18 = z18;
                    }
                    zArr = zArr222;
                    z5 = z18;
                } else {
                    zArr = zArr222;
                    ar(e95Var, zAw);
                    for (int i44 = 0; i44 < i4; i44++) {
                        ((cd1) this.br.get(i44)).ar(e95Var, zAw);
                    }
                    z5 = false;
                }
                if (z3 && i40 < 8) {
                    if (zArr[2]) {
                        int iMax5 = 0;
                        int iMax6 = 0;
                        for (int i45 = 0; i45 < i4; i45++) {
                            cd1 cd1Var14 = (cd1) this.br.get(i45);
                            iMax6 = Math.max(iMax6, cd1Var14.r() + cd1Var14.ba);
                            iMax5 = Math.max(iMax5, cd1Var14.l() + cd1Var14.bb);
                        }
                        int iMax7 = Math.max(this.bd, iMax6);
                        int iMax8 = Math.max(this.be, iMax5);
                        z5 = z5;
                        if (bVar4 == bVar10) {
                            z5 = z5;
                            if (r() < iMax7) {
                                ap(iMax7);
                                this.au[0] = bVar10;
                                z5 = true;
                                z4 = true;
                            }
                        }
                        if (bVar3 == bVar10 && l() < iMax8) {
                            am(iMax8);
                            this.au[1] = bVar10;
                            z5 = true;
                            z4 = true;
                        }
                    }
                }
                iMax = Math.max(this.bd, r());
                boolean z1722 = z5;
                if (iMax > r()) {
                    ap(iMax);
                    this.au[0] = bVar;
                    z1722 = true;
                    z4 = true;
                }
                iMax2 = Math.max(this.be, l());
                if (iMax2 > l()) {
                    am(iMax2);
                    r10 = 1;
                    this.au[1] = bVar;
                    r153 = 1;
                    z4 = true;
                } else {
                    r10 = 1;
                    r153 = z1722;
                }
                if (!z4) {
                    r153 = r153;
                    r153 = r153;
                    if (this.au[0] == bVar10 && i3 > 0) {
                        r153 = r153;
                        if (r() > i3) {
                            this.cg = r10;
                            this.au[0] = bVar;
                            ap(i3);
                            ?? r156 = r10;
                            z4 = r156 == true ? 1 : 0;
                            r153 = r156;
                        }
                    }
                    if (this.au[r10] != bVar10 || iL <= 0 || l() <= iL) {
                        z16 = z4;
                        i6 = 8;
                        r154 = r153;
                    } else {
                        this.ch = r10;
                        this.au[r10] = bVar;
                        am(iL);
                        i6 = 8;
                        z16 = true;
                        r154 = 1;
                    }
                }
                if (i40 > i6) {
                    r154 = 0;
                }
                i39 = i40;
                z15 = z3;
                bVar6 = bVar;
                r15 = r154;
            }
            z2 = z16;
            this.br = arrayList26;
            if (z2) {
                cd1.b[] bVarArr9 = this.au;
                bVarArr9[0] = bVar4;
                bVarArr9[1] = bVar3;
            }
            ag(e95Var.l);
        }
        i2 = size;
        sc1Var2 = sc1Var5;
        i3 = iMax3;
        iL = i;
        z = false;
        if (aw(64)) {
        }
        e95Var.getClass();
        e95Var.g = false;
        if (this.cf == 0) {
            c = 1;
        }
        ArrayList arrayList262 = this.br;
        cd1.b[] bVarArr82 = this.au;
        if (bVarArr82[0] != bVar10) {
        }
        this.cb = 0;
        this.cc = 0;
        i4 = i2;
        while (i5 < i4) {
        }
        boolean zAw3 = aw(64);
        boolean z162 = z;
        int i392 = 0;
        r15 = 1;
        while (r15 != 0) {
        }
        z2 = z162;
        this.br = arrayList262;
        if (z2) {
        }
        ag(e95Var.l);
    }

    public final void at(cd1 cd1Var, int i) {
        if (i == 0) {
            int i2 = this.cb + 1;
            bu0[] bu0VarArr = this.ce;
            if (i2 >= bu0VarArr.length) {
                this.ce = (bu0[]) Arrays.copyOf(bu0VarArr, bu0VarArr.length * 2);
            }
            bu0[] bu0VarArr2 = this.ce;
            int i3 = this.cb;
            bu0VarArr2[i3] = new bu0(cd1Var, 0, this.bw);
            this.cb = i3 + 1;
            return;
        }
        if (i == 1) {
            int i4 = this.cc + 1;
            bu0[] bu0VarArr3 = this.cd;
            if (i4 >= bu0VarArr3.length) {
                this.cd = (bu0[]) Arrays.copyOf(bu0VarArr3, bu0VarArr3.length * 2);
            }
            bu0[] bu0VarArr4 = this.cd;
            int i5 = this.cc;
            bu0VarArr4[i5] = new bu0(cd1Var, 1, this.bw);
            this.cc = i5 + 1;
        }
    }

    public final void au(e95 e95Var) {
        dd1 dd1Var;
        e95 e95Var2;
        boolean zAw = aw(64);
        c(e95Var, zAw);
        int size = this.br.size();
        boolean z = false;
        for (int i = 0; i < size; i++) {
            cd1 cd1Var = (cd1) this.br.get(i);
            boolean[] zArr = cd1Var.at;
            zArr[0] = false;
            zArr[1] = false;
            if (cd1Var instanceof o60) {
                z = true;
            }
        }
        if (z) {
            for (int i2 = 0; i2 < size; i2++) {
                cd1 cd1Var2 = (cd1) this.br.get(i2);
                if (cd1Var2 instanceof o60) {
                    o60 o60Var = (o60) cd1Var2;
                    for (int i3 = 0; i3 < o60Var.bs; i3++) {
                        cd1 cd1Var3 = o60Var.br[i3];
                        if (o60Var.bu || cd1Var3.d()) {
                            int i4 = o60Var.bt;
                            if (i4 == 0 || i4 == 1) {
                                cd1Var3.at[0] = true;
                            } else if (i4 == 2 || i4 == 3) {
                                cd1Var3.at[1] = true;
                            }
                        }
                    }
                }
            }
        }
        HashSet hashSet = this.cm;
        hashSet.clear();
        for (int i5 = 0; i5 < size; i5++) {
            cd1 cd1Var4 = (cd1) this.br.get(i5);
            cd1Var4.getClass();
            boolean z2 = cd1Var4 instanceof oma;
            if (z2 || (cd1Var4 instanceof xy3)) {
                if (z2) {
                    hashSet.add(cd1Var4);
                } else {
                    cd1Var4.c(e95Var, zAw);
                }
            }
        }
        while (hashSet.size() > 0) {
            int size2 = hashSet.size();
            Iterator it = hashSet.iterator();
            while (true) {
                if (!it.hasNext()) {
                    break;
                }
                oma omaVar = (oma) ((cd1) it.next());
                for (int i6 = 0; i6 < omaVar.bs; i6++) {
                    if (hashSet.contains(omaVar.br[i6])) {
                        omaVar.c(e95Var, zAw);
                        hashSet.remove(omaVar);
                        break;
                    }
                }
            }
            if (size2 == hashSet.size()) {
                Iterator it2 = hashSet.iterator();
                while (it2.hasNext()) {
                    ((cd1) it2.next()).c(e95Var, zAw);
                }
                hashSet.clear();
            }
        }
        boolean z3 = e95.p;
        cd1.b bVar = cd1.b.b;
        if (z3) {
            HashSet<cd1> hashSet2 = new HashSet();
            for (int i7 = 0; i7 < size; i7++) {
                cd1 cd1Var5 = (cd1) this.br.get(i7);
                cd1Var5.getClass();
                if (!(cd1Var5 instanceof oma) && !(cd1Var5 instanceof xy3)) {
                    hashSet2.add(cd1Var5);
                }
            }
            dd1Var = this;
            e95Var2 = e95Var;
            dd1Var.b(this, e95Var2, hashSet2, this.au[0] == bVar ? 0 : 1, false);
            for (cd1 cd1Var6 : hashSet2) {
                rx6.a(this, e95Var2, cd1Var6);
                cd1Var6.c(e95Var2, zAw);
            }
        } else {
            dd1Var = this;
            e95Var2 = e95Var;
            for (int i8 = 0; i8 < size; i8++) {
                cd1 cd1Var7 = (cd1) dd1Var.br.get(i8);
                if (cd1Var7 instanceof dd1) {
                    cd1.b[] bVarArr = cd1Var7.au;
                    cd1.b bVar2 = bVarArr[0];
                    cd1.b bVar3 = bVarArr[1];
                    cd1.b bVar4 = cd1.b.a;
                    if (bVar2 == bVar) {
                        cd1Var7.an(bVar4);
                    }
                    if (bVar3 == bVar) {
                        cd1Var7.ao(bVar4);
                    }
                    cd1Var7.c(e95Var2, zAw);
                    if (bVar2 == bVar) {
                        cd1Var7.an(bVar2);
                    }
                    if (bVar3 == bVar) {
                        cd1Var7.ao(bVar3);
                    }
                } else {
                    rx6.a(this, e95Var2, cd1Var7);
                    if (!(cd1Var7 instanceof oma) && !(cd1Var7 instanceof xy3)) {
                        cd1Var7.c(e95Var2, zAw);
                    }
                }
            }
        }
        if (dd1Var.cb > 0) {
            au0.a(this, e95Var2, null, 0);
        }
        if (dd1Var.cc > 0) {
            au0.a(this, e95Var2, null, 1);
        }
    }

    public final boolean aw(int i) {
        return (this.cf & i) == i;
    }

    @Override // defpackage.cd1
    public final void o(StringBuilder sb) {
        sb.append(this.j + ":{\n");
        StringBuilder sb2 = new StringBuilder("  actualWidth:");
        sb2.append(this.aw);
        sb.append(sb2.toString());
        sb.append("\n");
        sb.append("  actualHeight:" + this.ax);
        sb.append("\n");
        Iterator it = this.br.iterator();
        while (it.hasNext()) {
            ((cd1) it.next()).o(sb);
            sb.append(",\n");
        }
        sb.append("}");
    }
}
