package androidx.fragment.app;

import android.util.Log;
import io.flutter.embedding.android.AndroidTouchProcessor;
import io.flutter.plugin.editing.FlutterTextUtils;
import java.io.PrintWriter;
import java.lang.reflect.Modifier;
import java.util.ArrayList;

/* JADX INFO: renamed from: androidx.fragment.app.a, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes.dex */
public final class C0262a implements InterfaceC0271e0 {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final ArrayList f4208a;

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

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

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

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

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

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public boolean f4214g;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public String f4215h;
    public int i;

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    public CharSequence f4216j;

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

    /* JADX INFO: renamed from: l, reason: collision with root package name */
    public CharSequence f4218l;

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

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

    /* JADX INFO: renamed from: o, reason: collision with root package name */
    public boolean f4221o;
    public final h0 p;
    public boolean q;

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

    public C0262a(h0 h0Var) {
        h0Var.G();
        T t4 = h0Var.f4293v;
        if (t4 != null) {
            t4.f4196l.getClassLoader();
        }
        this.f4208a = new ArrayList();
        this.f4221o = false;
        this.f4222r = -1;
        this.p = h0Var;
    }

    @Override // androidx.fragment.app.InterfaceC0271e0
    public final boolean a(ArrayList arrayList, ArrayList arrayList2) {
        if (h0.J(2)) {
            Log.v("FragmentManager", "Run: " + this);
        }
        arrayList.add(this);
        arrayList2.add(Boolean.FALSE);
        if (!this.f4214g) {
            return true;
        }
        this.p.f4278d.add(this);
        return true;
    }

    public final void b(r0 r0Var) {
        this.f4208a.add(r0Var);
        r0Var.f4368d = this.f4209b;
        r0Var.f4369e = this.f4210c;
        r0Var.f4370f = this.f4211d;
        r0Var.f4371g = this.f4212e;
    }

    public final void c(int i) {
        if (this.f4214g) {
            if (h0.J(2)) {
                Log.v("FragmentManager", "Bump nesting in " + this + " by " + i);
            }
            ArrayList arrayList = this.f4208a;
            int size = arrayList.size();
            for (int i5 = 0; i5 < size; i5++) {
                r0 r0Var = (r0) arrayList.get(i5);
                I i6 = r0Var.f4366b;
                if (i6 != null) {
                    i6.mBackStackNesting += i;
                    if (h0.J(2)) {
                        Log.v("FragmentManager", "Bump nesting of " + r0Var.f4366b + " to " + r0Var.f4366b.mBackStackNesting);
                    }
                }
            }
        }
    }

    public final int d(boolean z5) {
        if (this.q) {
            throw new IllegalStateException("commit already called");
        }
        if (h0.J(2)) {
            Log.v("FragmentManager", "Commit: " + this);
            PrintWriter printWriter = new PrintWriter(new B0());
            f("  ", printWriter, true);
            printWriter.close();
        }
        this.q = true;
        boolean z6 = this.f4214g;
        h0 h0Var = this.p;
        if (z6) {
            this.f4222r = h0Var.f4283j.getAndIncrement();
        } else {
            this.f4222r = -1;
        }
        h0Var.x(this, z5);
        return this.f4222r;
    }

    public final void e(int i, I i5, String str, int i6) {
        String str2 = i5.mPreviousWho;
        if (str2 != null) {
            g0.d.c(i5, str2);
        }
        Class<?> cls = i5.getClass();
        int modifiers = cls.getModifiers();
        if (cls.isAnonymousClass() || !Modifier.isPublic(modifiers) || (cls.isMemberClass() && !Modifier.isStatic(modifiers))) {
            throw new IllegalStateException("Fragment " + cls.getCanonicalName() + " must be a public static class to be  properly recreated from instance state.");
        }
        if (str != null) {
            String str3 = i5.mTag;
            if (str3 != null && !str.equals(str3)) {
                throw new IllegalStateException("Can't change tag of fragment " + i5 + ": was " + i5.mTag + " now " + str);
            }
            i5.mTag = str;
        }
        if (i != 0) {
            if (i == -1) {
                throw new IllegalArgumentException("Can't add fragment " + i5 + " with tag " + str + " to container view with no id");
            }
            int i7 = i5.mFragmentId;
            if (i7 != 0 && i7 != i) {
                throw new IllegalStateException("Can't change container ID of fragment " + i5 + ": was " + i5.mFragmentId + " now " + i);
            }
            i5.mFragmentId = i;
            i5.mContainerId = i;
        }
        b(new r0(i5, i6));
        i5.mFragmentManager = this.p;
    }

    public final void f(String str, PrintWriter printWriter, boolean z5) {
        String str2;
        if (z5) {
            printWriter.print(str);
            printWriter.print("mName=");
            printWriter.print(this.f4215h);
            printWriter.print(" mIndex=");
            printWriter.print(this.f4222r);
            printWriter.print(" mCommitted=");
            printWriter.println(this.q);
            if (this.f4213f != 0) {
                printWriter.print(str);
                printWriter.print("mTransition=#");
                printWriter.print(Integer.toHexString(this.f4213f));
            }
            if (this.f4209b != 0 || this.f4210c != 0) {
                printWriter.print(str);
                printWriter.print("mEnterAnim=#");
                printWriter.print(Integer.toHexString(this.f4209b));
                printWriter.print(" mExitAnim=#");
                printWriter.println(Integer.toHexString(this.f4210c));
            }
            if (this.f4211d != 0 || this.f4212e != 0) {
                printWriter.print(str);
                printWriter.print("mPopEnterAnim=#");
                printWriter.print(Integer.toHexString(this.f4211d));
                printWriter.print(" mPopExitAnim=#");
                printWriter.println(Integer.toHexString(this.f4212e));
            }
            if (this.i != 0 || this.f4216j != null) {
                printWriter.print(str);
                printWriter.print("mBreadCrumbTitleRes=#");
                printWriter.print(Integer.toHexString(this.i));
                printWriter.print(" mBreadCrumbTitleText=");
                printWriter.println(this.f4216j);
            }
            if (this.f4217k != 0 || this.f4218l != null) {
                printWriter.print(str);
                printWriter.print("mBreadCrumbShortTitleRes=#");
                printWriter.print(Integer.toHexString(this.f4217k));
                printWriter.print(" mBreadCrumbShortTitleText=");
                printWriter.println(this.f4218l);
            }
        }
        ArrayList arrayList = this.f4208a;
        if (arrayList.isEmpty()) {
            return;
        }
        printWriter.print(str);
        printWriter.println("Operations:");
        int size = arrayList.size();
        for (int i = 0; i < size; i++) {
            r0 r0Var = (r0) arrayList.get(i);
            switch (r0Var.f4365a) {
                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 AndroidTouchProcessor.PointerChange.PAN_ZOOM_END /* 9 */:
                    str2 = "UNSET_PRIMARY_NAV";
                    break;
                case FlutterTextUtils.LINE_FEED /* 10 */:
                    str2 = "OP_SET_MAX_LIFECYCLE";
                    break;
                default:
                    str2 = "cmd=" + r0Var.f4365a;
                    break;
            }
            printWriter.print(str);
            printWriter.print("  Op #");
            printWriter.print(i);
            printWriter.print(": ");
            printWriter.print(str2);
            printWriter.print(" ");
            printWriter.println(r0Var.f4366b);
            if (z5) {
                if (r0Var.f4368d != 0 || r0Var.f4369e != 0) {
                    printWriter.print(str);
                    printWriter.print("enterAnim=#");
                    printWriter.print(Integer.toHexString(r0Var.f4368d));
                    printWriter.print(" exitAnim=#");
                    printWriter.println(Integer.toHexString(r0Var.f4369e));
                }
                if (r0Var.f4370f != 0 || r0Var.f4371g != 0) {
                    printWriter.print(str);
                    printWriter.print("popEnterAnim=#");
                    printWriter.print(Integer.toHexString(r0Var.f4370f));
                    printWriter.print(" popExitAnim=#");
                    printWriter.println(Integer.toHexString(r0Var.f4371g));
                }
            }
        }
    }

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