package g.h.a;

import android.util.Log;
import g.h.a.c;
import g.h.a.i;
import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.util.ArrayList;

/* JADX INFO: compiled from: BackStackRecord.java */
/* JADX INFO: loaded from: classes.dex */
final class a extends m implements i.l {
    final i a;
    int c;
    int d;
    int e;
    int f;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    int f513g;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    int f514h;

    /* JADX INFO: renamed from: i, reason: collision with root package name */
    boolean f515i;

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    String f516j;

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    boolean f517k;

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    int f519m;
    CharSequence n;
    int o;
    CharSequence p;
    ArrayList<String> q;
    ArrayList<String> r;
    ArrayList<Runnable> t;
    ArrayList<C0031a> b = new ArrayList<>();

    /* JADX INFO: renamed from: l, reason: collision with root package name */
    int f518l = -1;
    boolean s = false;

    /* JADX INFO: renamed from: g.h.a.a$a, reason: collision with other inner class name */
    /* JADX INFO: compiled from: BackStackRecord.java */
    static final class C0031a {
        int a;
        c b;
        int c;
        int d;
        int e;
        int f;

        C0031a() {
        }

        C0031a(int i2, c cVar) {
            this.a = i2;
            this.b = cVar;
        }
    }

    public a(i iVar) {
        this.a = iVar;
    }

    private static boolean l(C0031a c0031a) {
        c cVar = c0031a.b;
        return (cVar == null || !cVar.f533m || cVar.K == null || cVar.D || cVar.C || !cVar.n0()) ? false : true;
    }

    @Override // g.h.a.i.l
    public boolean a(ArrayList<a> arrayList, ArrayList<Boolean> arrayList2) {
        if (i.G) {
            Log.v("FragmentManager", "Run: " + this);
        }
        arrayList.add(this);
        arrayList2.add(Boolean.FALSE);
        if (!this.f515i) {
            return true;
        }
        this.a.f(this);
        return true;
    }

    void b(C0031a c0031a) {
        this.b.add(c0031a);
        c0031a.c = this.c;
        c0031a.d = this.d;
        c0031a.e = this.e;
        c0031a.f = this.f;
    }

    void c(int i2) {
        if (this.f515i) {
            if (i.G) {
                Log.v("FragmentManager", "Bump nesting in " + this + " by " + i2);
            }
            int size = this.b.size();
            for (int i3 = 0; i3 < size; i3++) {
                C0031a c0031a = this.b.get(i3);
                c cVar = c0031a.b;
                if (cVar != null) {
                    cVar.s += i2;
                    if (i.G) {
                        Log.v("FragmentManager", "Bump nesting of " + c0031a.b + " to " + c0031a.b.s);
                    }
                }
            }
        }
    }

    public void d(String str, FileDescriptor fileDescriptor, PrintWriter printWriter, String[] strArr) {
        e(str, printWriter, true);
    }

    public void e(String str, PrintWriter printWriter, boolean z) {
        String str2;
        if (z) {
            printWriter.print(str);
            printWriter.print("mName=");
            printWriter.print(this.f516j);
            printWriter.print(" mIndex=");
            printWriter.print(this.f518l);
            printWriter.print(" mCommitted=");
            printWriter.println(this.f517k);
            if (this.f513g != 0) {
                printWriter.print(str);
                printWriter.print("mTransition=#");
                printWriter.print(Integer.toHexString(this.f513g));
                printWriter.print(" mTransitionStyle=#");
                printWriter.println(Integer.toHexString(this.f514h));
            }
            if (this.c != 0 || this.d != 0) {
                printWriter.print(str);
                printWriter.print("mEnterAnim=#");
                printWriter.print(Integer.toHexString(this.c));
                printWriter.print(" mExitAnim=#");
                printWriter.println(Integer.toHexString(this.d));
            }
            if (this.e != 0 || this.f != 0) {
                printWriter.print(str);
                printWriter.print("mPopEnterAnim=#");
                printWriter.print(Integer.toHexString(this.e));
                printWriter.print(" mPopExitAnim=#");
                printWriter.println(Integer.toHexString(this.f));
            }
            if (this.f519m != 0 || this.n != null) {
                printWriter.print(str);
                printWriter.print("mBreadCrumbTitleRes=#");
                printWriter.print(Integer.toHexString(this.f519m));
                printWriter.print(" mBreadCrumbTitleText=");
                printWriter.println(this.n);
            }
            if (this.o != 0 || this.p != null) {
                printWriter.print(str);
                printWriter.print("mBreadCrumbShortTitleRes=#");
                printWriter.print(Integer.toHexString(this.o));
                printWriter.print(" mBreadCrumbShortTitleText=");
                printWriter.println(this.p);
            }
        }
        if (this.b.isEmpty()) {
            return;
        }
        printWriter.print(str);
        printWriter.println("Operations:");
        String str3 = str + "    ";
        int size = this.b.size();
        for (int i2 = 0; i2 < size; i2++) {
            C0031a c0031a = this.b.get(i2);
            switch (c0031a.a) {
                case 0:
                    str2 = "NULL";
                    break;
                case 1:
                    str2 = "ADD";
                    break;
                case 2:
                    str2 = "REPLACE";
                    break;
                case 3:
                    str2 = "REMOVE";
                    break;
                case 4:
                    str2 = "HIDE";
                    break;
                case 5:
                    str2 = "SHOW";
                    break;
                case 6:
                    str2 = "DETACH";
                    break;
                case 7:
                    str2 = "ATTACH";
                    break;
                case 8:
                    str2 = "SET_PRIMARY_NAV";
                    break;
                case 9:
                    str2 = "UNSET_PRIMARY_NAV";
                    break;
                default:
                    str2 = "cmd=" + c0031a.a;
                    break;
            }
            printWriter.print(str);
            printWriter.print("  Op #");
            printWriter.print(i2);
            printWriter.print(": ");
            printWriter.print(str2);
            printWriter.print(" ");
            printWriter.println(c0031a.b);
            if (z) {
                if (c0031a.c != 0 || c0031a.d != 0) {
                    printWriter.print(str);
                    printWriter.print("enterAnim=#");
                    printWriter.print(Integer.toHexString(c0031a.c));
                    printWriter.print(" exitAnim=#");
                    printWriter.println(Integer.toHexString(c0031a.d));
                }
                if (c0031a.e != 0 || c0031a.f != 0) {
                    printWriter.print(str);
                    printWriter.print("popEnterAnim=#");
                    printWriter.print(Integer.toHexString(c0031a.e));
                    printWriter.print(" popExitAnim=#");
                    printWriter.println(Integer.toHexString(c0031a.f));
                }
            }
        }
    }

    void f() {
        int size = this.b.size();
        for (int i2 = 0; i2 < size; i2++) {
            C0031a c0031a = this.b.get(i2);
            c cVar = c0031a.b;
            if (cVar != null) {
                cVar.C1(this.f513g, this.f514h);
            }
            switch (c0031a.a) {
                case 1:
                    cVar.B1(c0031a.c);
                    this.a.g(cVar, false);
                    break;
                case 2:
                default:
                    throw new IllegalArgumentException("Unknown cmd: " + c0031a.a);
                case 3:
                    cVar.B1(c0031a.d);
                    this.a.J0(cVar);
                    break;
                case 4:
                    cVar.B1(c0031a.d);
                    this.a.p0(cVar);
                    break;
                case 5:
                    cVar.B1(c0031a.c);
                    this.a.Z0(cVar);
                    break;
                case 6:
                    cVar.B1(c0031a.d);
                    this.a.p(cVar);
                    break;
                case 7:
                    cVar.B1(c0031a.c);
                    this.a.j(cVar);
                    break;
                case 8:
                    this.a.W0(cVar);
                    break;
                case 9:
                    this.a.W0(null);
                    break;
            }
            if (!this.s && c0031a.a != 1 && cVar != null) {
                this.a.z0(cVar);
            }
        }
        if (this.s) {
            return;
        }
        i iVar = this.a;
        iVar.A0(iVar.n, true);
    }

    void g(boolean z) {
        for (int size = this.b.size() - 1; size >= 0; size--) {
            C0031a c0031a = this.b.get(size);
            c cVar = c0031a.b;
            if (cVar != null) {
                cVar.C1(i.O0(this.f513g), this.f514h);
            }
            switch (c0031a.a) {
                case 1:
                    cVar.B1(c0031a.f);
                    this.a.J0(cVar);
                    break;
                case 2:
                default:
                    throw new IllegalArgumentException("Unknown cmd: " + c0031a.a);
                case 3:
                    cVar.B1(c0031a.e);
                    this.a.g(cVar, false);
                    break;
                case 4:
                    cVar.B1(c0031a.e);
                    this.a.Z0(cVar);
                    break;
                case 5:
                    cVar.B1(c0031a.f);
                    this.a.p0(cVar);
                    break;
                case 6:
                    cVar.B1(c0031a.e);
                    this.a.j(cVar);
                    break;
                case 7:
                    cVar.B1(c0031a.f);
                    this.a.p(cVar);
                    break;
                case 8:
                    this.a.W0(null);
                    break;
                case 9:
                    this.a.W0(cVar);
                    break;
            }
            if (!this.s && c0031a.a != 3 && cVar != null) {
                this.a.z0(cVar);
            }
        }
        if (this.s || !z) {
            return;
        }
        i iVar = this.a;
        iVar.A0(iVar.n, true);
    }

    /* JADX WARN: Removed duplicated region for block: B:34:0x00b2  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    g.h.a.c h(java.util.ArrayList<g.h.a.c> r17, g.h.a.c r18) {
        /*
            r16 = this;
            r0 = r16
            r1 = r17
            r3 = r18
            r4 = 0
        L7:
            java.util.ArrayList<g.h.a.a$a> r5 = r0.b
            int r5 = r5.size()
            if (r4 >= r5) goto Lba
            java.util.ArrayList<g.h.a.a$a> r5 = r0.b
            java.lang.Object r5 = r5.get(r4)
            g.h.a.a$a r5 = (g.h.a.a.C0031a) r5
            int r6 = r5.a
            r7 = 0
            r8 = 1
            if (r6 == r8) goto Lb2
            r9 = 2
            r10 = 3
            r11 = 9
            if (r6 == r9) goto L58
            if (r6 == r10) goto L41
            r9 = 6
            if (r6 == r9) goto L41
            r7 = 7
            if (r6 == r7) goto Lb2
            r7 = 8
            if (r6 == r7) goto L31
            goto Lb7
        L31:
            java.util.ArrayList<g.h.a.a$a> r6 = r0.b
            g.h.a.a$a r7 = new g.h.a.a$a
            r7.<init>(r11, r3)
            r6.add(r4, r7)
            int r4 = r4 + 1
            g.h.a.c r3 = r5.b
            goto Lb7
        L41:
            g.h.a.c r6 = r5.b
            r1.remove(r6)
            g.h.a.c r5 = r5.b
            if (r5 != r3) goto Lb7
            java.util.ArrayList<g.h.a.a$a> r3 = r0.b
            g.h.a.a$a r6 = new g.h.a.a$a
            r6.<init>(r11, r5)
            r3.add(r4, r6)
            int r4 = r4 + 1
            r3 = r7
            goto Lb7
        L58:
            g.h.a.c r6 = r5.b
            int r9 = r6.A
            int r12 = r17.size()
            int r12 = r12 - r8
            r13 = 0
        L62:
            if (r12 < 0) goto La2
            java.lang.Object r14 = r1.get(r12)
            g.h.a.c r14 = (g.h.a.c) r14
            int r15 = r14.A
            if (r15 != r9) goto L9f
            if (r14 != r6) goto L72
            r13 = r8
            goto L9f
        L72:
            if (r14 != r3) goto L81
            java.util.ArrayList<g.h.a.a$a> r3 = r0.b
            g.h.a.a$a r15 = new g.h.a.a$a
            r15.<init>(r11, r14)
            r3.add(r4, r15)
            int r4 = r4 + 1
            r3 = r7
        L81:
            g.h.a.a$a r15 = new g.h.a.a$a
            r15.<init>(r10, r14)
            int r2 = r5.c
            r15.c = r2
            int r2 = r5.e
            r15.e = r2
            int r2 = r5.d
            r15.d = r2
            int r2 = r5.f
            r15.f = r2
            java.util.ArrayList<g.h.a.a$a> r2 = r0.b
            r2.add(r4, r15)
            r1.remove(r14)
            int r4 = r4 + r8
        L9f:
            int r12 = r12 + (-1)
            goto L62
        La2:
            if (r13 == 0) goto Lac
            java.util.ArrayList<g.h.a.a$a> r2 = r0.b
            r2.remove(r4)
            int r4 = r4 + (-1)
            goto Lb7
        Lac:
            r5.a = r8
            r1.add(r6)
            goto Lb7
        Lb2:
            g.h.a.c r2 = r5.b
            r1.add(r2)
        Lb7:
            int r4 = r4 + r8
            goto L7
        Lba:
            return r3
        */
        throw new UnsupportedOperationException("Method not decompiled: g.h.a.a.h(java.util.ArrayList, g.h.a.c):g.h.a.c");
    }

    public String i() {
        return this.f516j;
    }

    boolean j(int i2) {
        int size = this.b.size();
        for (int i3 = 0; i3 < size; i3++) {
            c cVar = this.b.get(i3).b;
            int i4 = cVar != null ? cVar.A : 0;
            if (i4 != 0 && i4 == i2) {
                return true;
            }
        }
        return false;
    }

    boolean k(ArrayList<a> arrayList, int i2, int i3) {
        if (i3 == i2) {
            return false;
        }
        int size = this.b.size();
        int i4 = -1;
        for (int i5 = 0; i5 < size; i5++) {
            c cVar = this.b.get(i5).b;
            int i6 = cVar != null ? cVar.A : 0;
            if (i6 != 0 && i6 != i4) {
                for (int i7 = i2; i7 < i3; i7++) {
                    a aVar = arrayList.get(i7);
                    int size2 = aVar.b.size();
                    for (int i8 = 0; i8 < size2; i8++) {
                        c cVar2 = aVar.b.get(i8).b;
                        if ((cVar2 != null ? cVar2.A : 0) == i6) {
                            return true;
                        }
                    }
                }
                i4 = i6;
            }
        }
        return false;
    }

    boolean m() {
        for (int i2 = 0; i2 < this.b.size(); i2++) {
            if (l(this.b.get(i2))) {
                return true;
            }
        }
        return false;
    }

    public void n() {
        ArrayList<Runnable> arrayList = this.t;
        if (arrayList != null) {
            int size = arrayList.size();
            for (int i2 = 0; i2 < size; i2++) {
                this.t.get(i2).run();
            }
            this.t = null;
        }
    }

    void o(c.f fVar) {
        for (int i2 = 0; i2 < this.b.size(); i2++) {
            C0031a c0031a = this.b.get(i2);
            if (l(c0031a)) {
                c0031a.b.D1(fVar);
            }
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:13:0x0022  */
    /* JADX WARN: Removed duplicated region for block: B:14:0x0028  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    g.h.a.c p(java.util.ArrayList<g.h.a.c> r5, g.h.a.c r6) {
        /*
            r4 = this;
            r0 = 0
        L1:
            java.util.ArrayList<g.h.a.a$a> r1 = r4.b
            int r1 = r1.size()
            if (r0 >= r1) goto L30
            java.util.ArrayList<g.h.a.a$a> r1 = r4.b
            java.lang.Object r1 = r1.get(r0)
            g.h.a.a$a r1 = (g.h.a.a.C0031a) r1
            int r2 = r1.a
            r3 = 1
            if (r2 == r3) goto L28
            r3 = 3
            if (r2 == r3) goto L22
            switch(r2) {
                case 6: goto L22;
                case 7: goto L28;
                case 8: goto L20;
                case 9: goto L1d;
                default: goto L1c;
            }
        L1c:
            goto L2d
        L1d:
            g.h.a.c r6 = r1.b
            goto L2d
        L20:
            r6 = 0
            goto L2d
        L22:
            g.h.a.c r1 = r1.b
            r5.add(r1)
            goto L2d
        L28:
            g.h.a.c r1 = r1.b
            r5.remove(r1)
        L2d:
            int r0 = r0 + 1
            goto L1
        L30:
            return r6
        */
        throw new UnsupportedOperationException("Method not decompiled: g.h.a.a.p(java.util.ArrayList, g.h.a.c):g.h.a.c");
    }

    public String toString() {
        StringBuilder sb = new StringBuilder(128);
        sb.append("BackStackEntry{");
        sb.append(Integer.toHexString(System.identityHashCode(this)));
        if (this.f518l >= 0) {
            sb.append(" #");
            sb.append(this.f518l);
        }
        if (this.f516j != null) {
            sb.append(" ");
            sb.append(this.f516j);
        }
        sb.append("}");
        return sb.toString();
    }
}
