package androidx.fragment.app;

import android.os.Parcel;
import android.os.Parcelable;
import android.text.TextUtils;
import android.util.Log;
import androidx.fragment.app.k0;
import androidx.lifecycle.n;
import java.util.ArrayList;
import java.util.Map;

/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes.dex */
public final class b implements Parcelable {
    public static final Parcelable.Creator<b> CREATOR = new a();
    final ArrayList A;
    final ArrayList B;
    final boolean C;

    /* renamed from: p, reason: collision with root package name */
    final int[] f4406p;

    /* renamed from: q, reason: collision with root package name */
    final ArrayList f4407q;

    /* renamed from: r, reason: collision with root package name */
    final int[] f4408r;

    /* renamed from: s, reason: collision with root package name */
    final int[] f4409s;

    /* renamed from: t, reason: collision with root package name */
    final int f4410t;

    /* renamed from: u, reason: collision with root package name */
    final String f4411u;

    /* renamed from: v, reason: collision with root package name */
    final int f4412v;

    /* renamed from: w, reason: collision with root package name */
    final int f4413w;

    /* renamed from: x, reason: collision with root package name */
    final CharSequence f4414x;

    /* renamed from: y, reason: collision with root package name */
    final int f4415y;

    /* renamed from: z, reason: collision with root package name */
    final CharSequence f4416z;

    /* loaded from: classes.dex */
    class a implements Parcelable.Creator {
        a() {
        }

        @Override // android.os.Parcelable.Creator
        /* renamed from: a, reason: merged with bridge method [inline-methods] */
        public b createFromParcel(Parcel parcel) {
            return new b(parcel);
        }

        @Override // android.os.Parcelable.Creator
        /* renamed from: b, reason: merged with bridge method [inline-methods] */
        public b[] newArray(int i10) {
            return new b[i10];
        }
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public b(androidx.fragment.app.a aVar) {
        int size = aVar.f4568c.size();
        this.f4406p = new int[size * 6];
        if (aVar.f4574i) {
            this.f4407q = new ArrayList(size);
            this.f4408r = new int[size];
            this.f4409s = new int[size];
            int i10 = 0;
            int i11 = 0;
            while (i10 < size) {
                k0.a aVar2 = (k0.a) aVar.f4568c.get(i10);
                int i12 = i11 + 1;
                this.f4406p[i11] = aVar2.f4585a;
                ArrayList arrayList = this.f4407q;
                f fVar = aVar2.f4586b;
                arrayList.add(fVar != null ? fVar.mWho : null);
                int[] iArr = this.f4406p;
                int i13 = i12 + 1;
                iArr[i12] = aVar2.f4587c ? 1 : 0;
                int i14 = i13 + 1;
                iArr[i13] = aVar2.f4588d;
                int i15 = i14 + 1;
                iArr[i14] = aVar2.f4589e;
                int i16 = i15 + 1;
                iArr[i15] = aVar2.f4590f;
                iArr[i16] = aVar2.f4591g;
                this.f4408r[i10] = aVar2.f4592h.ordinal();
                this.f4409s[i10] = aVar2.f4593i.ordinal();
                i10++;
                i11 = i16 + 1;
            }
            this.f4410t = aVar.f4573h;
            this.f4411u = aVar.f4576k;
            this.f4412v = aVar.f4404v;
            this.f4413w = aVar.f4577l;
            this.f4414x = aVar.f4578m;
            this.f4415y = aVar.f4579n;
            this.f4416z = aVar.f4580o;
            this.A = aVar.f4581p;
            this.B = aVar.f4582q;
            this.C = aVar.f4583r;
            return;
        }
        throw new IllegalStateException("Not on back stack");
    }

    private void a(androidx.fragment.app.a aVar) {
        int i10 = 0;
        int i11 = 0;
        while (true) {
            boolean z10 = true;
            if (i10 >= this.f4406p.length) {
                aVar.f4573h = this.f4410t;
                aVar.f4576k = this.f4411u;
                aVar.f4574i = true;
                aVar.f4577l = this.f4413w;
                aVar.f4578m = this.f4414x;
                aVar.f4579n = this.f4415y;
                aVar.f4580o = this.f4416z;
                aVar.f4581p = this.A;
                aVar.f4582q = this.B;
                aVar.f4583r = this.C;
                return;
            }
            k0.a aVar2 = new k0.a();
            int i12 = i10 + 1;
            aVar2.f4585a = this.f4406p[i10];
            if (z.N0(2)) {
                Log.v("FragmentManager", "Instantiate " + aVar + " op #" + i11 + " base fragment #" + this.f4406p[i12]);
            }
            aVar2.f4592h = n.b.values()[this.f4408r[i11]];
            aVar2.f4593i = n.b.values()[this.f4409s[i11]];
            int[] iArr = this.f4406p;
            int i13 = i12 + 1;
            if (iArr[i12] == 0) {
                z10 = false;
            }
            aVar2.f4587c = z10;
            int i14 = i13 + 1;
            int i15 = iArr[i13];
            aVar2.f4588d = i15;
            int i16 = i14 + 1;
            int i17 = iArr[i14];
            aVar2.f4589e = i17;
            int i18 = i16 + 1;
            int i19 = iArr[i16];
            aVar2.f4590f = i19;
            int i20 = iArr[i18];
            aVar2.f4591g = i20;
            aVar.f4569d = i15;
            aVar.f4570e = i17;
            aVar.f4571f = i19;
            aVar.f4572g = i20;
            aVar.f(aVar2);
            i11++;
            i10 = i18 + 1;
        }
    }

    public androidx.fragment.app.a b(z zVar) {
        androidx.fragment.app.a aVar = new androidx.fragment.app.a(zVar);
        a(aVar);
        aVar.f4404v = this.f4412v;
        for (int i10 = 0; i10 < this.f4407q.size(); i10++) {
            String str = (String) this.f4407q.get(i10);
            if (str != null) {
                ((k0.a) aVar.f4568c.get(i10)).f4586b = zVar.i0(str);
            }
        }
        aVar.z(1);
        return aVar;
    }

    public androidx.fragment.app.a c(z zVar, Map map) {
        androidx.fragment.app.a aVar = new androidx.fragment.app.a(zVar);
        a(aVar);
        for (int i10 = 0; i10 < this.f4407q.size(); i10++) {
            String str = (String) this.f4407q.get(i10);
            if (str != null) {
                f fVar = (f) map.get(str);
                if (fVar == null) {
                    throw new IllegalStateException("Restoring FragmentTransaction " + this.f4411u + " failed due to missing saved state for Fragment (" + str + ")");
                }
                ((k0.a) aVar.f4568c.get(i10)).f4586b = fVar;
            }
        }
        return aVar;
    }

    @Override // android.os.Parcelable
    public int describeContents() {
        return 0;
    }

    @Override // android.os.Parcelable
    public void writeToParcel(Parcel parcel, int i10) {
        parcel.writeIntArray(this.f4406p);
        parcel.writeStringList(this.f4407q);
        parcel.writeIntArray(this.f4408r);
        parcel.writeIntArray(this.f4409s);
        parcel.writeInt(this.f4410t);
        parcel.writeString(this.f4411u);
        parcel.writeInt(this.f4412v);
        parcel.writeInt(this.f4413w);
        TextUtils.writeToParcel(this.f4414x, parcel, 0);
        parcel.writeInt(this.f4415y);
        TextUtils.writeToParcel(this.f4416z, parcel, 0);
        parcel.writeStringList(this.A);
        parcel.writeStringList(this.B);
        parcel.writeInt(this.C ? 1 : 0);
    }

    b(Parcel parcel) {
        this.f4406p = parcel.createIntArray();
        this.f4407q = parcel.createStringArrayList();
        this.f4408r = parcel.createIntArray();
        this.f4409s = parcel.createIntArray();
        this.f4410t = parcel.readInt();
        this.f4411u = parcel.readString();
        this.f4412v = parcel.readInt();
        this.f4413w = parcel.readInt();
        this.f4414x = (CharSequence) TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(parcel);
        this.f4415y = parcel.readInt();
        this.f4416z = (CharSequence) TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(parcel);
        this.A = parcel.createStringArrayList();
        this.B = parcel.createStringArrayList();
        this.C = parcel.readInt() != 0;
    }
}
