package androidx.fragment.app;

import androidx.lifecycle.k;
import defpackage.n41;
import defpackage.rn3;
import java.lang.reflect.Modifier;
import java.util.ArrayList;

/* JADX INFO: loaded from: classes.dex */
public abstract class am {
    public int b;
    public int c;
    public int d;
    public int e;
    public int f;
    public boolean g;
    public String i;
    public int j;
    public CharSequence k;
    public int l;
    public CharSequence m;
    public ArrayList n;
    public ArrayList o;
    public ArrayList q;
    public final ArrayList a = new ArrayList();
    public boolean h = true;
    public boolean p = false;

    public final void b(a aVar) {
        this.a.add(aVar);
        aVar.d = this.b;
        aVar.e = this.c;
        aVar.f = this.d;
        aVar.g = this.e;
    }

    public final void c(String str) {
        if (!this.h) {
            throw new IllegalStateException("This FragmentTransaction is not allowed to be added to the back stack.");
        }
        this.g = true;
        this.i = str;
    }

    public abstract int d();

    public abstract int e();

    public abstract void f();

    public void g(int i, o oVar, String str, int i2) {
        String str2 = oVar.mPreviousWho;
        if (str2 != null) {
            rn3.c(oVar, str2);
        }
        Class<?> cls = oVar.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 = oVar.mTag;
            if (str3 != null && !str.equals(str3)) {
                StringBuilder sb = new StringBuilder("Can't change tag of fragment ");
                sb.append(oVar);
                sb.append(": was ");
                throw new IllegalStateException(n41.t(sb, oVar.mTag, " now ", str));
            }
            oVar.mTag = str;
        }
        if (i != 0) {
            if (i == -1) {
                throw new IllegalArgumentException("Can't add fragment " + oVar + " with tag " + str + " to container view with no id");
            }
            int i3 = oVar.mFragmentId;
            if (i3 != 0 && i3 != i) {
                throw new IllegalStateException("Can't change container ID of fragment " + oVar + ": was " + oVar.mFragmentId + " now " + i);
            }
            oVar.mFragmentId = i;
            oVar.mContainerId = i;
        }
        b(new a(oVar, i2));
    }

    public void h(o oVar) {
        b(new a(oVar, 3));
    }

    public final void i(int i, o oVar, String str) {
        if (i == 0) {
            throw new IllegalArgumentException("Must use non-zero containerViewId");
        }
        g(i, oVar, str, 2);
    }

    public void j(o oVar) {
        b(new a(oVar, 8));
    }

    public static final class a {
        public int a;
        public o b;
        public boolean c = false;
        public int d;
        public int e;
        public int f;
        public int g;
        public k.b h;
        public k.b i;

        public a(o oVar, int i) {
            this.a = i;
            this.b = oVar;
            k.b bVar = k.b.e;
            this.h = bVar;
            this.i = bVar;
        }

        public a(o oVar, int i, int i2) {
            this.a = i;
            this.b = oVar;
            k.b bVar = k.b.e;
            this.h = bVar;
            this.i = bVar;
        }
    }
}
