package androidx.fragment.app;

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.content.res.Configuration;
import android.os.Bundle;
import android.os.Looper;
import android.os.Parcel;
import android.os.Parcelable;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;
import androidx.activity.OnBackPressedDispatcher;
import androidx.activity.result.f;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.e;
import androidx.fragment.app.v;
import androidx.fragment.app.w;
import androidx.lifecycle.f;
import com.cvte.vman.instance.InvokeCmd;
import com.seewo.adbcommons.model.base.ICmdMsg;
import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.atomic.AtomicInteger;

/* JADX INFO: compiled from: FragmentManager.java */
/* JADX INFO: loaded from: classes.dex */
public abstract class m {
    private static boolean O = false;
    static boolean P = true;
    private androidx.activity.result.c<androidx.activity.result.f> A;
    private androidx.activity.result.c<String[]> B;
    private boolean D;
    private boolean E;
    private boolean F;
    private boolean G;
    private boolean H;
    private ArrayList<androidx.fragment.app.a> I;
    private ArrayList<Boolean> J;
    private ArrayList<Fragment> K;
    private ArrayList<q> L;
    private androidx.fragment.app.p M;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    private boolean f774b;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    ArrayList<androidx.fragment.app.a> f776d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    private ArrayList<Fragment> f777e;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    private OnBackPressedDispatcher f779g;
    private ArrayList<n> l;
    private androidx.fragment.app.j<?> r;
    private androidx.fragment.app.f s;
    private Fragment t;
    Fragment u;
    private androidx.activity.result.c<Intent> z;
    private final ArrayList<o> a = new ArrayList<>();

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    private final u f775c = new u();

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    private final androidx.fragment.app.k f778f = new androidx.fragment.app.k(this);

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    private final androidx.activity.b f780h = new c(false);

    /* JADX INFO: renamed from: i, reason: collision with root package name */
    private final AtomicInteger f781i = new AtomicInteger();

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    private final Map<String, Bundle> f782j = Collections.synchronizedMap(new HashMap());

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    private final Map<String, Object> f783k = Collections.synchronizedMap(new HashMap());
    private Map<Fragment, HashSet<c.f.h.a>> m = Collections.synchronizedMap(new HashMap());
    private final w.g n = new d();
    private final androidx.fragment.app.l o = new androidx.fragment.app.l(this);
    private final CopyOnWriteArrayList<androidx.fragment.app.q> p = new CopyOnWriteArrayList<>();
    int q = -1;
    private androidx.fragment.app.i v = null;
    private androidx.fragment.app.i w = new e();
    private d0 x = null;
    private d0 y = new f(this);
    ArrayDeque<C0012m> C = new ArrayDeque<>();
    private Runnable N = new g();

    /* JADX INFO: compiled from: FragmentManager.java */
    class a implements androidx.activity.result.b<androidx.activity.result.a> {
        a() {
        }

        @Override // androidx.activity.result.b
        /* JADX INFO: renamed from: b, reason: merged with bridge method [inline-methods] */
        public void a(androidx.activity.result.a aVar) {
            C0012m c0012mPollFirst = m.this.C.pollFirst();
            if (c0012mPollFirst == null) {
                Log.w("FragmentManager", "No IntentSenders were started for " + this);
                return;
            }
            String str = c0012mPollFirst.f790b;
            int i2 = c0012mPollFirst.f791f;
            Fragment fragmentI = m.this.f775c.i(str);
            if (fragmentI != null) {
                fragmentI.e0(i2, aVar.b(), aVar.a());
                return;
            }
            Log.w("FragmentManager", "Intent Sender result delivered for unknown Fragment " + str);
        }
    }

    /* JADX INFO: compiled from: FragmentManager.java */
    class b implements androidx.activity.result.b<Map<String, Boolean>> {
        b() {
        }

        @Override // androidx.activity.result.b
        @SuppressLint({"SyntheticAccessor"})
        /* JADX INFO: renamed from: b, reason: merged with bridge method [inline-methods] */
        public void a(Map<String, Boolean> map) {
            String[] strArr = (String[]) map.keySet().toArray(new String[0]);
            ArrayList arrayList = new ArrayList(map.values());
            int[] iArr = new int[arrayList.size()];
            for (int i2 = 0; i2 < arrayList.size(); i2++) {
                iArr[i2] = ((Boolean) arrayList.get(i2)).booleanValue() ? 0 : -1;
            }
            C0012m c0012mPollFirst = m.this.C.pollFirst();
            if (c0012mPollFirst == null) {
                Log.w("FragmentManager", "No permissions were requested for " + this);
                return;
            }
            String str = c0012mPollFirst.f790b;
            int i3 = c0012mPollFirst.f791f;
            Fragment fragmentI = m.this.f775c.i(str);
            if (fragmentI != null) {
                fragmentI.D0(i3, strArr, iArr);
                return;
            }
            Log.w("FragmentManager", "Permission request result delivered for unknown Fragment " + str);
        }
    }

    /* JADX INFO: compiled from: FragmentManager.java */
    class c extends androidx.activity.b {
        c(boolean z) {
            super(z);
        }

        @Override // androidx.activity.b
        public void b() {
            m.this.A0();
        }
    }

    /* JADX INFO: compiled from: FragmentManager.java */
    class d implements w.g {
        d() {
        }

        @Override // androidx.fragment.app.w.g
        public void a(Fragment fragment, c.f.h.a aVar) {
            if (aVar.b()) {
                return;
            }
            m.this.W0(fragment, aVar);
        }

        @Override // androidx.fragment.app.w.g
        public void b(Fragment fragment, c.f.h.a aVar) {
            m.this.f(fragment, aVar);
        }
    }

    /* JADX INFO: compiled from: FragmentManager.java */
    class e extends androidx.fragment.app.i {
        e() {
        }

        @Override // androidx.fragment.app.i
        public Fragment a(ClassLoader classLoader, String str) {
            return m.this.s0().e(m.this.s0().k(), str, null);
        }
    }

    /* JADX INFO: compiled from: FragmentManager.java */
    class f implements d0 {
        f(m mVar) {
        }

        @Override // androidx.fragment.app.d0
        public c0 a(ViewGroup viewGroup) {
            return new androidx.fragment.app.c(viewGroup);
        }
    }

    /* JADX INFO: compiled from: FragmentManager.java */
    class g implements Runnable {
        g() {
        }

        @Override // java.lang.Runnable
        public void run() {
            m.this.a0(true);
        }
    }

    /* JADX INFO: compiled from: FragmentManager.java */
    class h extends AnimatorListenerAdapter {
        final /* synthetic */ ViewGroup a;

        /* JADX INFO: renamed from: b, reason: collision with root package name */
        final /* synthetic */ View f787b;

        /* JADX INFO: renamed from: c, reason: collision with root package name */
        final /* synthetic */ Fragment f788c;

        h(m mVar, ViewGroup viewGroup, View view, Fragment fragment) {
            this.a = viewGroup;
            this.f787b = view;
            this.f788c = fragment;
        }

        @Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
        public void onAnimationEnd(Animator animator) {
            this.a.endViewTransition(this.f787b);
            animator.removeListener(this);
            Fragment fragment = this.f788c;
            View view = fragment.L;
            if (view == null || !fragment.D) {
                return;
            }
            view.setVisibility(8);
        }
    }

    /* JADX INFO: compiled from: FragmentManager.java */
    class i implements androidx.fragment.app.q {

        /* JADX INFO: renamed from: b, reason: collision with root package name */
        final /* synthetic */ Fragment f789b;

        i(m mVar, Fragment fragment) {
            this.f789b = fragment;
        }

        @Override // androidx.fragment.app.q
        public void b(m mVar, Fragment fragment) {
            this.f789b.h0(fragment);
        }
    }

    /* JADX INFO: compiled from: FragmentManager.java */
    class j implements androidx.activity.result.b<androidx.activity.result.a> {
        j() {
        }

        @Override // androidx.activity.result.b
        /* JADX INFO: renamed from: b, reason: merged with bridge method [inline-methods] */
        public void a(androidx.activity.result.a aVar) {
            C0012m c0012mPollFirst = m.this.C.pollFirst();
            if (c0012mPollFirst == null) {
                Log.w("FragmentManager", "No Activities were started for result for " + this);
                return;
            }
            String str = c0012mPollFirst.f790b;
            int i2 = c0012mPollFirst.f791f;
            Fragment fragmentI = m.this.f775c.i(str);
            if (fragmentI != null) {
                fragmentI.e0(i2, aVar.b(), aVar.a());
                return;
            }
            Log.w("FragmentManager", "Activity result delivered for unknown Fragment " + str);
        }
    }

    /* JADX INFO: compiled from: FragmentManager.java */
    static class k extends androidx.activity.result.g.a<androidx.activity.result.f, androidx.activity.result.a> {
        k() {
        }

        @Override // androidx.activity.result.g.a
        /* JADX INFO: renamed from: d, reason: merged with bridge method [inline-methods] */
        public Intent a(Context context, androidx.activity.result.f fVar) {
            Bundle bundleExtra;
            Intent intent = new Intent("androidx.activity.result.contract.action.INTENT_SENDER_REQUEST");
            Intent intentA = fVar.a();
            if (intentA != null && (bundleExtra = intentA.getBundleExtra("androidx.activity.result.contract.extra.ACTIVITY_OPTIONS_BUNDLE")) != null) {
                intent.putExtra("androidx.activity.result.contract.extra.ACTIVITY_OPTIONS_BUNDLE", bundleExtra);
                intentA.removeExtra("androidx.activity.result.contract.extra.ACTIVITY_OPTIONS_BUNDLE");
                if (intentA.getBooleanExtra("androidx.fragment.extra.ACTIVITY_OPTIONS_BUNDLE", false)) {
                    f.b bVar = new f.b(fVar.d());
                    bVar.b(null);
                    bVar.c(fVar.c(), fVar.b());
                    fVar = bVar.a();
                }
            }
            intent.putExtra("androidx.activity.result.contract.extra.INTENT_SENDER_REQUEST", fVar);
            if (m.D0(2)) {
                Log.v("FragmentManager", "CreateIntent created the following intent: " + intent);
            }
            return intent;
        }

        @Override // androidx.activity.result.g.a
        /* JADX INFO: renamed from: e, reason: merged with bridge method [inline-methods] */
        public androidx.activity.result.a c(int i2, Intent intent) {
            return new androidx.activity.result.a(i2, intent);
        }
    }

    /* JADX INFO: compiled from: FragmentManager.java */
    public static abstract class l {
        @Deprecated
        public abstract void a(m mVar, Fragment fragment, Bundle bundle);

        public abstract void b(m mVar, Fragment fragment, Context context);

        public abstract void c(m mVar, Fragment fragment, Bundle bundle);

        public abstract void d(m mVar, Fragment fragment);

        public abstract void e(m mVar, Fragment fragment);

        public abstract void f(m mVar, Fragment fragment);

        public abstract void g(m mVar, Fragment fragment, Context context);

        public abstract void h(m mVar, Fragment fragment, Bundle bundle);

        public abstract void i(m mVar, Fragment fragment);

        public abstract void j(m mVar, Fragment fragment, Bundle bundle);

        public abstract void k(m mVar, Fragment fragment);

        public abstract void l(m mVar, Fragment fragment);

        public abstract void m(m mVar, Fragment fragment, View view, Bundle bundle);

        public abstract void n(m mVar, Fragment fragment);
    }

    /* JADX INFO: compiled from: FragmentManager.java */
    public interface n {
        void a();
    }

    /* JADX INFO: compiled from: FragmentManager.java */
    interface o {
        boolean a(ArrayList<androidx.fragment.app.a> arrayList, ArrayList<Boolean> arrayList2);
    }

    /* JADX INFO: compiled from: FragmentManager.java */
    private class p implements o {
        final String a;

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

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

        p(String str, int i2, int i3) {
            this.a = str;
            this.f792b = i2;
            this.f793c = i3;
        }

        @Override // androidx.fragment.app.m.o
        public boolean a(ArrayList<androidx.fragment.app.a> arrayList, ArrayList<Boolean> arrayList2) {
            Fragment fragment = m.this.u;
            if (fragment == null || this.f792b >= 0 || this.a != null || !fragment.p().S0()) {
                return m.this.U0(arrayList, arrayList2, this.a, this.f792b, this.f793c);
            }
            return false;
        }
    }

    /* JADX INFO: compiled from: FragmentManager.java */
    static class q implements Fragment.g {
        final boolean a;

        /* JADX INFO: renamed from: b, reason: collision with root package name */
        final androidx.fragment.app.a f795b;

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

        q(androidx.fragment.app.a aVar, boolean z) {
            this.a = z;
            this.f795b = aVar;
        }

        @Override // androidx.fragment.app.Fragment.g
        public void a() {
            int i2 = this.f796c - 1;
            this.f796c = i2;
            if (i2 != 0) {
                return;
            }
            this.f795b.r.d1();
        }

        @Override // androidx.fragment.app.Fragment.g
        public void b() {
            this.f796c++;
        }

        void c() {
            androidx.fragment.app.a aVar = this.f795b;
            aVar.r.t(aVar, this.a, false, false);
        }

        void d() {
            boolean z = this.f796c > 0;
            for (Fragment fragment : this.f795b.r.r0()) {
                fragment.v1(null);
                if (z && fragment.X()) {
                    fragment.A1();
                }
            }
            androidx.fragment.app.a aVar = this.f795b;
            aVar.r.t(aVar, this.a, !z, true);
        }

        public boolean e() {
            return this.f796c == 0;
        }
    }

    static boolean D0(int i2) {
        return O || Log.isLoggable("FragmentManager", i2);
    }

    private boolean E0(Fragment fragment) {
        return (fragment.H && fragment.I) || fragment.y.n();
    }

    private void K0(c.d.b<Fragment> bVar) {
        int size = bVar.size();
        for (int i2 = 0; i2 < size; i2++) {
            Fragment fragmentH = bVar.h(i2);
            if (!fragmentH.p) {
                View viewK1 = fragmentH.k1();
                fragmentH.R = viewK1.getAlpha();
                viewK1.setAlpha(0.0f);
            }
        }
    }

    private void L(Fragment fragment) {
        if (fragment == null || !fragment.equals(f0(fragment.f677j))) {
            return;
        }
        fragment.c1();
    }

    private void S(int i2) {
        try {
            this.f774b = true;
            this.f775c.d(i2);
            M0(i2, false);
            if (P) {
                Iterator<c0> it = r().iterator();
                while (it.hasNext()) {
                    it.next().j();
                }
            }
            this.f774b = false;
            a0(true);
        } catch (Throwable th) {
            this.f774b = false;
            throw th;
        }
    }

    private boolean T0(String str, int i2, int i3) {
        a0(false);
        Z(true);
        Fragment fragment = this.u;
        if (fragment != null && i2 < 0 && str == null && fragment.p().S0()) {
            return true;
        }
        boolean zU0 = U0(this.I, this.J, str, i2, i3);
        if (zU0) {
            this.f774b = true;
            try {
                Y0(this.I, this.J);
            } finally {
                p();
            }
        }
        k1();
        V();
        this.f775c.b();
        return zU0;
    }

    private void V() {
        if (this.H) {
            this.H = false;
            j1();
        }
    }

    private int V0(ArrayList<androidx.fragment.app.a> arrayList, ArrayList<Boolean> arrayList2, int i2, int i3, c.d.b<Fragment> bVar) {
        int i4 = i3;
        for (int i5 = i3 - 1; i5 >= i2; i5--) {
            androidx.fragment.app.a aVar = arrayList.get(i5);
            boolean zBooleanValue = arrayList2.get(i5).booleanValue();
            if (aVar.y() && !aVar.w(arrayList, i5 + 1, i3)) {
                if (this.L == null) {
                    this.L = new ArrayList<>();
                }
                q qVar = new q(aVar, zBooleanValue);
                this.L.add(qVar);
                aVar.A(qVar);
                if (zBooleanValue) {
                    aVar.r();
                } else {
                    aVar.s(false);
                }
                i4--;
                if (i5 != i4) {
                    arrayList.remove(i5);
                    arrayList.add(i4, aVar);
                }
                d(bVar);
            }
        }
        return i4;
    }

    private void X() {
        if (P) {
            Iterator<c0> it = r().iterator();
            while (it.hasNext()) {
                it.next().j();
            }
        } else {
            if (this.m.isEmpty()) {
                return;
            }
            for (Fragment fragment : this.m.keySet()) {
                m(fragment);
                N0(fragment);
            }
        }
    }

    private void Y0(ArrayList<androidx.fragment.app.a> arrayList, ArrayList<Boolean> arrayList2) {
        if (arrayList.isEmpty()) {
            return;
        }
        if (arrayList.size() != arrayList2.size()) {
            throw new IllegalStateException("Internal error with the back stack records");
        }
        e0(arrayList, arrayList2);
        int size = arrayList.size();
        int i2 = 0;
        int i3 = 0;
        while (i2 < size) {
            if (!arrayList.get(i2).p) {
                if (i3 != i2) {
                    d0(arrayList, arrayList2, i3, i2);
                }
                i3 = i2 + 1;
                if (arrayList2.get(i2).booleanValue()) {
                    while (i3 < size && arrayList2.get(i3).booleanValue() && !arrayList.get(i3).p) {
                        i3++;
                    }
                }
                d0(arrayList, arrayList2, i2, i3);
                i2 = i3 - 1;
            }
            i2++;
        }
        if (i3 != size) {
            d0(arrayList, arrayList2, i3, size);
        }
    }

    private void Z(boolean z) {
        if (this.f774b) {
            throw new IllegalStateException("FragmentManager is already executing transactions");
        }
        if (this.r == null) {
            if (!this.G) {
                throw new IllegalStateException("FragmentManager has not been attached to a host.");
            }
            throw new IllegalStateException("FragmentManager has been destroyed");
        }
        if (Looper.myLooper() != this.r.l().getLooper()) {
            throw new IllegalStateException("Must be called from main thread of fragment host");
        }
        if (!z) {
            o();
        }
        if (this.I == null) {
            this.I = new ArrayList<>();
            this.J = new ArrayList<>();
        }
        this.f774b = true;
        try {
            e0(null, null);
        } finally {
            this.f774b = false;
        }
    }

    private void Z0() {
        if (this.l != null) {
            for (int i2 = 0; i2 < this.l.size(); i2++) {
                this.l.get(i2).a();
            }
        }
    }

    static int b1(int i2) {
        if (i2 == 4097) {
            return InvokeCmd.CMD_TOUCH_GET_MOUSE_FADE_STATE;
        }
        if (i2 != 4099) {
            return i2 != 8194 ? 0 : 4097;
        }
        return 4099;
    }

    private static void c0(ArrayList<androidx.fragment.app.a> arrayList, ArrayList<Boolean> arrayList2, int i2, int i3) {
        while (i2 < i3) {
            androidx.fragment.app.a aVar = arrayList.get(i2);
            if (arrayList2.get(i2).booleanValue()) {
                aVar.n(-1);
                aVar.s(i2 == i3 + (-1));
            } else {
                aVar.n(1);
                aVar.r();
            }
            i2++;
        }
    }

    private void d(c.d.b<Fragment> bVar) {
        int i2 = this.q;
        if (i2 < 1) {
            return;
        }
        int iMin = Math.min(i2, 5);
        for (Fragment fragment : this.f775c.n()) {
            if (fragment.f672b < iMin) {
                O0(fragment, iMin);
                if (fragment.L != null && !fragment.D && fragment.P) {
                    bVar.add(fragment);
                }
            }
        }
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Type inference failed for: r14v1 */
    /* JADX WARN: Type inference failed for: r14v2 */
    /* JADX WARN: Type inference failed for: r14v4 */
    /* JADX WARN: Type inference failed for: r17v0, types: [androidx.fragment.app.m] */
    /* JADX WARN: Type inference failed for: r1v10 */
    /* JADX WARN: Type inference failed for: r1v17 */
    /* JADX WARN: Type inference failed for: r1v3 */
    /* JADX WARN: Type inference failed for: r1v4, types: [boolean, int] */
    /* JADX WARN: Type inference failed for: r1v6 */
    /* JADX WARN: Type inference failed for: r1v7, types: [boolean] */
    private void d0(ArrayList<androidx.fragment.app.a> arrayList, ArrayList<Boolean> arrayList2, int i2, int i3) {
        ?? r1;
        ?? r14;
        boolean z;
        int i4;
        int i5;
        ArrayList<Boolean> arrayList3;
        int iV0;
        ArrayList<Boolean> arrayList4;
        int i6;
        ?? r12;
        boolean z2 = arrayList.get(i2).p;
        ArrayList<Fragment> arrayList5 = this.K;
        if (arrayList5 == null) {
            this.K = new ArrayList<>();
        } else {
            arrayList5.clear();
        }
        this.K.addAll(this.f775c.n());
        Fragment fragmentW0 = w0();
        boolean z3 = false;
        for (int i7 = i2; i7 < i3; i7++) {
            androidx.fragment.app.a aVar = arrayList.get(i7);
            fragmentW0 = !arrayList2.get(i7).booleanValue() ? aVar.t(this.K, fragmentW0) : aVar.B(this.K, fragmentW0);
            z3 = z3 || aVar.f831g;
        }
        this.K.clear();
        if (z2 || this.q < 1) {
            r1 = 1;
        } else if (P) {
            for (int i8 = i2; i8 < i3; i8++) {
                Iterator<v.a> it = arrayList.get(i8).a.iterator();
                while (it.hasNext()) {
                    Fragment fragment = it.next().f836b;
                    if (fragment != null && fragment.w != null) {
                        this.f775c.p(v(fragment));
                    }
                }
            }
            r1 = 1;
        } else {
            r1 = 1;
            w.C(this.r.k(), this.s, arrayList, arrayList2, i2, i3, false, this.n);
        }
        c0(arrayList, arrayList2, i2, i3);
        if (P) {
            boolean zBooleanValue = arrayList2.get(i3 - 1).booleanValue();
            for (int i9 = i2; i9 < i3; i9++) {
                androidx.fragment.app.a aVar2 = arrayList.get(i9);
                if (zBooleanValue) {
                    for (int size = aVar2.a.size() - r1; size >= 0; size--) {
                        Fragment fragment2 = aVar2.a.get(size).f836b;
                        if (fragment2 != null) {
                            v(fragment2).m();
                        }
                    }
                } else {
                    Iterator<v.a> it2 = aVar2.a.iterator();
                    while (it2.hasNext()) {
                        Fragment fragment3 = it2.next().f836b;
                        if (fragment3 != null) {
                            v(fragment3).m();
                        }
                    }
                }
            }
            M0(this.q, r1);
            for (c0 c0Var : s(arrayList, i2, i3)) {
                c0Var.r(zBooleanValue);
                c0Var.p();
                c0Var.g();
            }
            i6 = i3;
            arrayList4 = arrayList2;
        } else {
            if (z2) {
                c.d.b bVar = new c.d.b();
                d(bVar);
                r14 = r1;
                z = z2;
                i4 = i3;
                i5 = i2;
                arrayList3 = arrayList2;
                iV0 = V0(arrayList, arrayList2, i2, i3, bVar);
                K0(bVar);
            } else {
                r14 = r1;
                z = z2;
                i4 = i3;
                i5 = i2;
                arrayList3 = arrayList2;
                iV0 = i4;
            }
            if (iV0 == i5 || !z) {
                arrayList4 = arrayList3;
                i6 = i4;
            } else {
                if (this.q >= r14) {
                    arrayList4 = arrayList3;
                    int i10 = iV0;
                    i6 = i4;
                    r12 = r14;
                    w.C(this.r.k(), this.s, arrayList, arrayList2, i2, i10, true, this.n);
                } else {
                    arrayList4 = arrayList3;
                    i6 = i4;
                    r12 = r14;
                }
                M0(this.q, r12);
            }
        }
        for (int i11 = i2; i11 < i6; i11++) {
            androidx.fragment.app.a aVar3 = arrayList.get(i11);
            if (arrayList4.get(i11).booleanValue() && aVar3.t >= 0) {
                aVar3.t = -1;
            }
            aVar3.z();
        }
        if (z3) {
            Z0();
        }
    }

    private void e0(ArrayList<androidx.fragment.app.a> arrayList, ArrayList<Boolean> arrayList2) {
        int iIndexOf;
        int iIndexOf2;
        ArrayList<q> arrayList3 = this.L;
        int size = arrayList3 == null ? 0 : arrayList3.size();
        int i2 = 0;
        while (i2 < size) {
            q qVar = this.L.get(i2);
            if (arrayList != null && !qVar.a && (iIndexOf2 = arrayList.indexOf(qVar.f795b)) != -1 && arrayList2 != null && arrayList2.get(iIndexOf2).booleanValue()) {
                this.L.remove(i2);
                i2--;
                size--;
                qVar.c();
            } else if (qVar.e() || (arrayList != null && qVar.f795b.w(arrayList, 0, arrayList.size()))) {
                this.L.remove(i2);
                i2--;
                size--;
                if (arrayList == null || qVar.a || (iIndexOf = arrayList.indexOf(qVar.f795b)) == -1 || arrayList2 == null || !arrayList2.get(iIndexOf).booleanValue()) {
                    qVar.d();
                } else {
                    qVar.c();
                }
            }
            i2++;
        }
    }

    private void h1(Fragment fragment) {
        ViewGroup viewGroupO0 = o0(fragment);
        if (viewGroupO0 == null || fragment.A() <= 0) {
            return;
        }
        if (viewGroupO0.getTag(c.i.b.visible_removing_fragment_view_tag) == null) {
            viewGroupO0.setTag(c.i.b.visible_removing_fragment_view_tag, fragment);
        }
        ((Fragment) viewGroupO0.getTag(c.i.b.visible_removing_fragment_view_tag)).t1(fragment.A());
    }

    private void j0() {
        if (P) {
            Iterator<c0> it = r().iterator();
            while (it.hasNext()) {
                it.next().k();
            }
        } else if (this.L != null) {
            while (!this.L.isEmpty()) {
                this.L.remove(0).d();
            }
        }
    }

    private void j1() {
        Iterator<t> it = this.f775c.k().iterator();
        while (it.hasNext()) {
            Q0(it.next());
        }
    }

    private boolean k0(ArrayList<androidx.fragment.app.a> arrayList, ArrayList<Boolean> arrayList2) {
        synchronized (this.a) {
            if (this.a.isEmpty()) {
                return false;
            }
            int size = this.a.size();
            boolean zA = false;
            for (int i2 = 0; i2 < size; i2++) {
                zA |= this.a.get(i2).a(arrayList, arrayList2);
            }
            this.a.clear();
            this.r.l().removeCallbacks(this.N);
            return zA;
        }
    }

    private void k1() {
        synchronized (this.a) {
            if (this.a.isEmpty()) {
                this.f780h.f(l0() > 0 && G0(this.t));
            } else {
                this.f780h.f(true);
            }
        }
    }

    private void m(Fragment fragment) {
        HashSet<c.f.h.a> hashSet = this.m.get(fragment);
        if (hashSet != null) {
            Iterator<c.f.h.a> it = hashSet.iterator();
            while (it.hasNext()) {
                it.next().a();
            }
            hashSet.clear();
            w(fragment);
            this.m.remove(fragment);
        }
    }

    private androidx.fragment.app.p m0(Fragment fragment) {
        return this.M.i(fragment);
    }

    private void o() {
        if (I0()) {
            throw new IllegalStateException("Can not perform this action after onSaveInstanceState");
        }
    }

    private ViewGroup o0(Fragment fragment) {
        ViewGroup viewGroup = fragment.K;
        if (viewGroup != null) {
            return viewGroup;
        }
        if (fragment.B > 0 && this.s.g()) {
            View viewF = this.s.f(fragment.B);
            if (viewF instanceof ViewGroup) {
                return (ViewGroup) viewF;
            }
        }
        return null;
    }

    private void p() {
        this.f774b = false;
        this.J.clear();
        this.I.clear();
    }

    private Set<c0> r() {
        HashSet hashSet = new HashSet();
        Iterator<t> it = this.f775c.k().iterator();
        while (it.hasNext()) {
            ViewGroup viewGroup = it.next().k().K;
            if (viewGroup != null) {
                hashSet.add(c0.o(viewGroup, x0()));
            }
        }
        return hashSet;
    }

    private Set<c0> s(ArrayList<androidx.fragment.app.a> arrayList, int i2, int i3) {
        ViewGroup viewGroup;
        HashSet hashSet = new HashSet();
        while (i2 < i3) {
            Iterator<v.a> it = arrayList.get(i2).a.iterator();
            while (it.hasNext()) {
                Fragment fragment = it.next().f836b;
                if (fragment != null && (viewGroup = fragment.K) != null) {
                    hashSet.add(c0.n(viewGroup, this));
                }
            }
            i2++;
        }
        return hashSet;
    }

    private void u(Fragment fragment) {
        Animator animator;
        if (fragment.L != null) {
            e.d dVarB = androidx.fragment.app.e.b(this.r.k(), fragment, !fragment.D);
            if (dVarB == null || (animator = dVarB.f758b) == null) {
                if (dVarB != null) {
                    fragment.L.startAnimation(dVarB.a);
                    dVarB.a.start();
                }
                fragment.L.setVisibility((!fragment.D || fragment.U()) ? 0 : 8);
                if (fragment.U()) {
                    fragment.s1(false);
                }
            } else {
                animator.setTarget(fragment.L);
                if (!fragment.D) {
                    fragment.L.setVisibility(0);
                } else if (fragment.U()) {
                    fragment.s1(false);
                } else {
                    ViewGroup viewGroup = fragment.K;
                    View view = fragment.L;
                    viewGroup.startViewTransition(view);
                    dVarB.f758b.addListener(new h(this, viewGroup, view, fragment));
                }
                dVarB.f758b.start();
            }
        }
        if (fragment.p && E0(fragment)) {
            this.D = true;
        }
        fragment.Q = false;
        fragment.t0(fragment.D);
    }

    private void w(Fragment fragment) {
        fragment.S0();
        this.o.n(fragment, false);
        fragment.K = null;
        fragment.L = null;
        fragment.W = null;
        fragment.X.m(null);
        fragment.s = false;
    }

    static Fragment y0(View view) {
        Object tag = view.getTag(c.i.b.fragment_container_view_tag);
        if (tag instanceof Fragment) {
            return (Fragment) tag;
        }
        return null;
    }

    void A(Configuration configuration) {
        for (Fragment fragment : this.f775c.n()) {
            if (fragment != null) {
                fragment.M0(configuration);
            }
        }
    }

    void A0() {
        a0(true);
        if (this.f780h.c()) {
            S0();
        } else {
            this.f779g.c();
        }
    }

    boolean B(MenuItem menuItem) {
        if (this.q < 1) {
            return false;
        }
        for (Fragment fragment : this.f775c.n()) {
            if (fragment != null && fragment.N0(menuItem)) {
                return true;
            }
        }
        return false;
    }

    void B0(Fragment fragment) {
        if (D0(2)) {
            Log.v("FragmentManager", "hide: " + fragment);
        }
        if (fragment.D) {
            return;
        }
        fragment.D = true;
        fragment.Q = true ^ fragment.Q;
        h1(fragment);
    }

    void C() {
        this.E = false;
        this.F = false;
        this.M.o(false);
        S(1);
    }

    public boolean C0() {
        return this.G;
    }

    boolean D(Menu menu, MenuInflater menuInflater) {
        if (this.q < 1) {
            return false;
        }
        ArrayList<Fragment> arrayList = null;
        boolean z = false;
        for (Fragment fragment : this.f775c.n()) {
            if (fragment != null && F0(fragment) && fragment.P0(menu, menuInflater)) {
                if (arrayList == null) {
                    arrayList = new ArrayList<>();
                }
                arrayList.add(fragment);
                z = true;
            }
        }
        if (this.f777e != null) {
            for (int i2 = 0; i2 < this.f777e.size(); i2++) {
                Fragment fragment2 = this.f777e.get(i2);
                if (arrayList == null || !arrayList.contains(fragment2)) {
                    fragment2.p0();
                }
            }
        }
        this.f777e = arrayList;
        return z;
    }

    void E() {
        this.G = true;
        a0(true);
        X();
        S(-1);
        this.r = null;
        this.s = null;
        this.t = null;
        if (this.f779g != null) {
            this.f780h.d();
            this.f779g = null;
        }
        androidx.activity.result.c<Intent> cVar = this.z;
        if (cVar != null) {
            cVar.c();
            this.A.c();
            this.B.c();
        }
    }

    void F() {
        S(1);
    }

    boolean F0(Fragment fragment) {
        if (fragment == null) {
            return true;
        }
        return fragment.W();
    }

    void G() {
        for (Fragment fragment : this.f775c.n()) {
            if (fragment != null) {
                fragment.V0();
            }
        }
    }

    boolean G0(Fragment fragment) {
        if (fragment == null) {
            return true;
        }
        m mVar = fragment.w;
        return fragment.equals(mVar.w0()) && G0(mVar.t);
    }

    void H(boolean z) {
        for (Fragment fragment : this.f775c.n()) {
            if (fragment != null) {
                fragment.W0(z);
            }
        }
    }

    boolean H0(int i2) {
        return this.q >= i2;
    }

    void I(Fragment fragment) {
        Iterator<androidx.fragment.app.q> it = this.p.iterator();
        while (it.hasNext()) {
            it.next().b(this, fragment);
        }
    }

    public boolean I0() {
        return this.E || this.F;
    }

    boolean J(MenuItem menuItem) {
        if (this.q < 1) {
            return false;
        }
        for (Fragment fragment : this.f775c.n()) {
            if (fragment != null && fragment.X0(menuItem)) {
                return true;
            }
        }
        return false;
    }

    void J0(Fragment fragment, @SuppressLint({"UnknownNullness"}) Intent intent, int i2, Bundle bundle) {
        if (this.z == null) {
            this.r.p(fragment, intent, i2, bundle);
            return;
        }
        this.C.addLast(new C0012m(fragment.f677j, i2));
        if (intent != null && bundle != null) {
            intent.putExtra("androidx.activity.result.contract.extra.ACTIVITY_OPTIONS_BUNDLE", bundle);
        }
        this.z.a(intent);
    }

    void K(Menu menu) {
        if (this.q < 1) {
            return;
        }
        for (Fragment fragment : this.f775c.n()) {
            if (fragment != null) {
                fragment.Y0(menu);
            }
        }
    }

    void L0(Fragment fragment) {
        if (!this.f775c.c(fragment.f677j)) {
            if (D0(3)) {
                Log.d("FragmentManager", "Ignoring moving " + fragment + " to state " + this.q + "since it is not added to " + this);
                return;
            }
            return;
        }
        N0(fragment);
        View view = fragment.L;
        if (view != null && fragment.P && fragment.K != null) {
            float f2 = fragment.R;
            if (f2 > 0.0f) {
                view.setAlpha(f2);
            }
            fragment.R = 0.0f;
            fragment.P = false;
            e.d dVarB = androidx.fragment.app.e.b(this.r.k(), fragment, true);
            if (dVarB != null) {
                Animation animation = dVarB.a;
                if (animation != null) {
                    fragment.L.startAnimation(animation);
                } else {
                    dVarB.f758b.setTarget(fragment.L);
                    dVarB.f758b.start();
                }
            }
        }
        if (fragment.Q) {
            u(fragment);
        }
    }

    void M() {
        S(5);
    }

    void M0(int i2, boolean z) {
        androidx.fragment.app.j<?> jVar;
        if (this.r == null && i2 != -1) {
            throw new IllegalStateException("No activity");
        }
        if (z || i2 != this.q) {
            this.q = i2;
            if (P) {
                this.f775c.r();
            } else {
                Iterator<Fragment> it = this.f775c.n().iterator();
                while (it.hasNext()) {
                    L0(it.next());
                }
                for (t tVar : this.f775c.k()) {
                    Fragment fragmentK = tVar.k();
                    if (!fragmentK.P) {
                        L0(fragmentK);
                    }
                    if (fragmentK.q && !fragmentK.V()) {
                        this.f775c.q(tVar);
                    }
                }
            }
            j1();
            if (this.D && (jVar = this.r) != null && this.q == 7) {
                jVar.q();
                this.D = false;
            }
        }
    }

    void N(boolean z) {
        for (Fragment fragment : this.f775c.n()) {
            if (fragment != null) {
                fragment.a1(z);
            }
        }
    }

    void N0(Fragment fragment) {
        O0(fragment, this.q);
    }

    boolean O(Menu menu) {
        boolean z = false;
        if (this.q < 1) {
            return false;
        }
        for (Fragment fragment : this.f775c.n()) {
            if (fragment != null && F0(fragment) && fragment.b1(menu)) {
                z = true;
            }
        }
        return z;
    }

    /* JADX WARN: Removed duplicated region for block: B:31:0x0063  */
    /* JADX WARN: Removed duplicated region for block: B:33:0x0068  */
    /* JADX WARN: Removed duplicated region for block: B:35:0x006d  */
    /* JADX WARN: Removed duplicated region for block: B:37:0x0072  */
    /* JADX WARN: Removed duplicated region for block: B:39:0x0077  */
    /* JADX WARN: Removed duplicated region for block: B:97:0x0159  */
    /* JADX WARN: Removed duplicated region for block: B:99:0x015c  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    void O0(androidx.fragment.app.Fragment r11, int r12) {
        /*
            Method dump skipped, instruction units count: 403
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: androidx.fragment.app.m.O0(androidx.fragment.app.Fragment, int):void");
    }

    void P() {
        k1();
        L(this.u);
    }

    void P0() {
        if (this.r == null) {
            return;
        }
        this.E = false;
        this.F = false;
        this.M.o(false);
        for (Fragment fragment : this.f775c.n()) {
            if (fragment != null) {
                fragment.c0();
            }
        }
    }

    void Q() {
        this.E = false;
        this.F = false;
        this.M.o(false);
        S(7);
    }

    void Q0(t tVar) {
        Fragment fragmentK = tVar.k();
        if (fragmentK.M) {
            if (this.f774b) {
                this.H = true;
                return;
            }
            fragmentK.M = false;
            if (P) {
                tVar.m();
            } else {
                N0(fragmentK);
            }
        }
    }

    void R() {
        this.E = false;
        this.F = false;
        this.M.o(false);
        S(5);
    }

    public void R0(String str, int i2) {
        Y(new p(str, -1, i2), false);
    }

    public boolean S0() {
        return T0(null, -1, 0);
    }

    void T() {
        this.F = true;
        this.M.o(true);
        S(4);
    }

    void U() {
        S(2);
    }

    boolean U0(ArrayList<androidx.fragment.app.a> arrayList, ArrayList<Boolean> arrayList2, String str, int i2, int i3) {
        int i4;
        ArrayList<androidx.fragment.app.a> arrayList3 = this.f776d;
        if (arrayList3 == null) {
            return false;
        }
        if (str == null && i2 < 0 && (i3 & 1) == 0) {
            int size = arrayList3.size() - 1;
            if (size < 0) {
                return false;
            }
            arrayList.add(this.f776d.remove(size));
            arrayList2.add(Boolean.TRUE);
        } else {
            if (str != null || i2 >= 0) {
                int size2 = this.f776d.size() - 1;
                while (size2 >= 0) {
                    androidx.fragment.app.a aVar = this.f776d.get(size2);
                    if ((str != null && str.equals(aVar.u())) || (i2 >= 0 && i2 == aVar.t)) {
                        break;
                    }
                    size2--;
                }
                if (size2 < 0) {
                    return false;
                }
                if ((i3 & 1) != 0) {
                    while (true) {
                        size2--;
                        if (size2 < 0) {
                            break;
                        }
                        androidx.fragment.app.a aVar2 = this.f776d.get(size2);
                        if (str == null || !str.equals(aVar2.u())) {
                            if (i2 < 0 || i2 != aVar2.t) {
                                break;
                            }
                        }
                    }
                }
                i4 = size2;
            } else {
                i4 = -1;
            }
            if (i4 == this.f776d.size() - 1) {
                return false;
            }
            for (int size3 = this.f776d.size() - 1; size3 > i4; size3--) {
                arrayList.add(this.f776d.remove(size3));
                arrayList2.add(Boolean.TRUE);
            }
        }
        return true;
    }

    public void W(String str, FileDescriptor fileDescriptor, PrintWriter printWriter, String[] strArr) {
        int size;
        int size2;
        String str2 = str + "    ";
        this.f775c.e(str, fileDescriptor, printWriter, strArr);
        ArrayList<Fragment> arrayList = this.f777e;
        if (arrayList != null && (size2 = arrayList.size()) > 0) {
            printWriter.print(str);
            printWriter.println("Fragments Created Menus:");
            for (int i2 = 0; i2 < size2; i2++) {
                Fragment fragment = this.f777e.get(i2);
                printWriter.print(str);
                printWriter.print("  #");
                printWriter.print(i2);
                printWriter.print(": ");
                printWriter.println(fragment.toString());
            }
        }
        ArrayList<androidx.fragment.app.a> arrayList2 = this.f776d;
        if (arrayList2 != null && (size = arrayList2.size()) > 0) {
            printWriter.print(str);
            printWriter.println("Back Stack:");
            for (int i3 = 0; i3 < size; i3++) {
                androidx.fragment.app.a aVar = this.f776d.get(i3);
                printWriter.print(str);
                printWriter.print("  #");
                printWriter.print(i3);
                printWriter.print(": ");
                printWriter.println(aVar.toString());
                aVar.p(str2, printWriter);
            }
        }
        printWriter.print(str);
        printWriter.println("Back Stack Index: " + this.f781i.get());
        synchronized (this.a) {
            int size3 = this.a.size();
            if (size3 > 0) {
                printWriter.print(str);
                printWriter.println("Pending Actions:");
                for (int i4 = 0; i4 < size3; i4++) {
                    o oVar = this.a.get(i4);
                    printWriter.print(str);
                    printWriter.print("  #");
                    printWriter.print(i4);
                    printWriter.print(": ");
                    printWriter.println(oVar);
                }
            }
        }
        printWriter.print(str);
        printWriter.println("FragmentManager misc state:");
        printWriter.print(str);
        printWriter.print("  mHost=");
        printWriter.println(this.r);
        printWriter.print(str);
        printWriter.print("  mContainer=");
        printWriter.println(this.s);
        if (this.t != null) {
            printWriter.print(str);
            printWriter.print("  mParent=");
            printWriter.println(this.t);
        }
        printWriter.print(str);
        printWriter.print("  mCurState=");
        printWriter.print(this.q);
        printWriter.print(" mStateSaved=");
        printWriter.print(this.E);
        printWriter.print(" mStopped=");
        printWriter.print(this.F);
        printWriter.print(" mDestroyed=");
        printWriter.println(this.G);
        if (this.D) {
            printWriter.print(str);
            printWriter.print("  mNeedMenuInvalidate=");
            printWriter.println(this.D);
        }
    }

    void W0(Fragment fragment, c.f.h.a aVar) {
        HashSet<c.f.h.a> hashSet = this.m.get(fragment);
        if (hashSet != null && hashSet.remove(aVar) && hashSet.isEmpty()) {
            this.m.remove(fragment);
            if (fragment.f672b < 5) {
                w(fragment);
                N0(fragment);
            }
        }
    }

    void X0(Fragment fragment) {
        if (D0(2)) {
            Log.v("FragmentManager", "remove: " + fragment + " nesting=" + fragment.v);
        }
        boolean z = !fragment.V();
        if (!fragment.E || z) {
            this.f775c.s(fragment);
            if (E0(fragment)) {
                this.D = true;
            }
            fragment.q = true;
            h1(fragment);
        }
    }

    void Y(o oVar, boolean z) {
        if (!z) {
            if (this.r == null) {
                if (!this.G) {
                    throw new IllegalStateException("FragmentManager has not been attached to a host.");
                }
                throw new IllegalStateException("FragmentManager has been destroyed");
            }
            o();
        }
        synchronized (this.a) {
            if (this.r == null) {
                if (!z) {
                    throw new IllegalStateException("Activity has been destroyed");
                }
            } else {
                this.a.add(oVar);
                d1();
            }
        }
    }

    boolean a0(boolean z) {
        Z(z);
        boolean z2 = false;
        while (k0(this.I, this.J)) {
            this.f774b = true;
            try {
                Y0(this.I, this.J);
                p();
                z2 = true;
            } catch (Throwable th) {
                p();
                throw th;
            }
        }
        k1();
        V();
        this.f775c.b();
        return z2;
    }

    void a1(Parcelable parcelable) {
        t tVar;
        if (parcelable == null) {
            return;
        }
        androidx.fragment.app.o oVar = (androidx.fragment.app.o) parcelable;
        if (oVar.f797b == null) {
            return;
        }
        this.f775c.t();
        for (s sVar : oVar.f797b) {
            if (sVar != null) {
                Fragment fragmentH = this.M.h(sVar.f813f);
                if (fragmentH != null) {
                    if (D0(2)) {
                        Log.v("FragmentManager", "restoreSaveState: re-attaching retained " + fragmentH);
                    }
                    tVar = new t(this.o, this.f775c, fragmentH, sVar);
                } else {
                    tVar = new t(this.o, this.f775c, this.r.k().getClassLoader(), p0(), sVar);
                }
                Fragment fragmentK = tVar.k();
                fragmentK.w = this;
                if (D0(2)) {
                    Log.v("FragmentManager", "restoreSaveState: active (" + fragmentK.f677j + "): " + fragmentK);
                }
                tVar.o(this.r.k().getClassLoader());
                this.f775c.p(tVar);
                tVar.t(this.q);
            }
        }
        for (Fragment fragment : this.M.k()) {
            if (!this.f775c.c(fragment.f677j)) {
                if (D0(2)) {
                    Log.v("FragmentManager", "Discarding retained Fragment " + fragment + " that was not found in the set of active Fragments " + oVar.f797b);
                }
                this.M.n(fragment);
                fragment.w = this;
                t tVar2 = new t(this.o, this.f775c, fragment);
                tVar2.t(1);
                tVar2.m();
                fragment.q = true;
                tVar2.m();
            }
        }
        this.f775c.u(oVar.f798f);
        if (oVar.f799g != null) {
            this.f776d = new ArrayList<>(oVar.f799g.length);
            int i2 = 0;
            while (true) {
                androidx.fragment.app.b[] bVarArr = oVar.f799g;
                if (i2 >= bVarArr.length) {
                    break;
                }
                androidx.fragment.app.a aVarA = bVarArr[i2].a(this);
                if (D0(2)) {
                    Log.v("FragmentManager", "restoreAllState: back stack #" + i2 + " (index " + aVarA.t + "): " + aVarA);
                    PrintWriter printWriter = new PrintWriter(new b0("FragmentManager"));
                    aVarA.q("  ", printWriter, false);
                    printWriter.close();
                }
                this.f776d.add(aVarA);
                i2++;
            }
        } else {
            this.f776d = null;
        }
        this.f781i.set(oVar.f800h);
        String str = oVar.f801i;
        if (str != null) {
            Fragment fragmentF0 = f0(str);
            this.u = fragmentF0;
            L(fragmentF0);
        }
        ArrayList<String> arrayList = oVar.f802j;
        if (arrayList != null) {
            for (int i3 = 0; i3 < arrayList.size(); i3++) {
                this.f782j.put(arrayList.get(i3), oVar.f803k.get(i3));
            }
        }
        this.C = new ArrayDeque<>(oVar.l);
    }

    void b0(o oVar, boolean z) {
        if (z && (this.r == null || this.G)) {
            return;
        }
        Z(z);
        if (oVar.a(this.I, this.J)) {
            this.f774b = true;
            try {
                Y0(this.I, this.J);
            } finally {
                p();
            }
        }
        k1();
        V();
        this.f775c.b();
    }

    Parcelable c1() {
        int size;
        j0();
        X();
        a0(true);
        this.E = true;
        this.M.o(true);
        ArrayList<s> arrayListV = this.f775c.v();
        androidx.fragment.app.b[] bVarArr = null;
        if (arrayListV.isEmpty()) {
            if (D0(2)) {
                Log.v("FragmentManager", "saveAllState: no fragments!");
            }
            return null;
        }
        ArrayList<String> arrayListW = this.f775c.w();
        ArrayList<androidx.fragment.app.a> arrayList = this.f776d;
        if (arrayList != null && (size = arrayList.size()) > 0) {
            bVarArr = new androidx.fragment.app.b[size];
            for (int i2 = 0; i2 < size; i2++) {
                bVarArr[i2] = new androidx.fragment.app.b(this.f776d.get(i2));
                if (D0(2)) {
                    Log.v("FragmentManager", "saveAllState: adding back stack #" + i2 + ": " + this.f776d.get(i2));
                }
            }
        }
        androidx.fragment.app.o oVar = new androidx.fragment.app.o();
        oVar.f797b = arrayListV;
        oVar.f798f = arrayListW;
        oVar.f799g = bVarArr;
        oVar.f800h = this.f781i.get();
        Fragment fragment = this.u;
        if (fragment != null) {
            oVar.f801i = fragment.f677j;
        }
        oVar.f802j.addAll(this.f782j.keySet());
        oVar.f803k.addAll(this.f782j.values());
        oVar.l = new ArrayList<>(this.C);
        return oVar;
    }

    void d1() {
        synchronized (this.a) {
            boolean z = (this.L == null || this.L.isEmpty()) ? false : true;
            boolean z2 = this.a.size() == 1;
            if (z || z2) {
                this.r.l().removeCallbacks(this.N);
                this.r.l().post(this.N);
                k1();
            }
        }
    }

    void e(androidx.fragment.app.a aVar) {
        if (this.f776d == null) {
            this.f776d = new ArrayList<>();
        }
        this.f776d.add(aVar);
    }

    void e1(Fragment fragment, boolean z) {
        ViewGroup viewGroupO0 = o0(fragment);
        if (viewGroupO0 == null || !(viewGroupO0 instanceof androidx.fragment.app.g)) {
            return;
        }
        ((androidx.fragment.app.g) viewGroupO0).setDrawDisappearingViewsLast(!z);
    }

    void f(Fragment fragment, c.f.h.a aVar) {
        if (this.m.get(fragment) == null) {
            this.m.put(fragment, new HashSet<>());
        }
        this.m.get(fragment).add(aVar);
    }

    Fragment f0(String str) {
        return this.f775c.f(str);
    }

    void f1(Fragment fragment, f.c cVar) {
        if (fragment.equals(f0(fragment.f677j)) && (fragment.x == null || fragment.w == this)) {
            fragment.U = cVar;
            return;
        }
        throw new IllegalArgumentException("Fragment " + fragment + " is not an active fragment of FragmentManager " + this);
    }

    void g(Fragment fragment) {
        if (D0(2)) {
            Log.v("FragmentManager", "add: " + fragment);
        }
        t tVarV = v(fragment);
        fragment.w = this;
        this.f775c.p(tVarV);
        if (fragment.E) {
            return;
        }
        this.f775c.a(fragment);
        fragment.q = false;
        if (fragment.L == null) {
            fragment.Q = false;
        }
        if (E0(fragment)) {
            this.D = true;
        }
    }

    public Fragment g0(int i2) {
        return this.f775c.g(i2);
    }

    void g1(Fragment fragment) {
        if (fragment == null || (fragment.equals(f0(fragment.f677j)) && (fragment.x == null || fragment.w == this))) {
            Fragment fragment2 = this.u;
            this.u = fragment;
            L(fragment2);
            L(this.u);
            return;
        }
        throw new IllegalArgumentException("Fragment " + fragment + " is not an active fragment of FragmentManager " + this);
    }

    public void h(androidx.fragment.app.q qVar) {
        this.p.add(qVar);
    }

    public Fragment h0(String str) {
        return this.f775c.h(str);
    }

    int i() {
        return this.f781i.getAndIncrement();
    }

    Fragment i0(String str) {
        return this.f775c.i(str);
    }

    void i1(Fragment fragment) {
        if (D0(2)) {
            Log.v("FragmentManager", "show: " + fragment);
        }
        if (fragment.D) {
            fragment.D = false;
            fragment.Q = !fragment.Q;
        }
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Type inference fix 'apply assigned field type' failed
    java.lang.UnsupportedOperationException: ArgType.getObject(), call class: class jadx.core.dex.instructions.args.ArgType$UnknownArg
    	at jadx.core.dex.instructions.args.ArgType.getObject(ArgType.java:593)
    	at jadx.core.dex.attributes.nodes.ClassTypeVarsAttr.getTypeVarsMapFor(ClassTypeVarsAttr.java:35)
    	at jadx.core.dex.nodes.utils.TypeUtils.replaceClassGenerics(TypeUtils.java:177)
    	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.insertExplicitUseCast(FixTypesVisitor.java:397)
    	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.tryFieldTypeWithNewCasts(FixTypesVisitor.java:359)
    	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.applyFieldType(FixTypesVisitor.java:309)
    	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.visit(FixTypesVisitor.java:94)
     */
    @SuppressLint({"SyntheticAccessor"})
    void j(androidx.fragment.app.j<?> jVar, androidx.fragment.app.f fVar, Fragment fragment) {
        String str;
        if (this.r != null) {
            throw new IllegalStateException("Already attached");
        }
        this.r = jVar;
        this.s = fVar;
        this.t = fragment;
        if (fragment != null) {
            h(new i(this, fragment));
        } else if (jVar instanceof androidx.fragment.app.q) {
            h((androidx.fragment.app.q) jVar);
        }
        if (this.t != null) {
            k1();
        }
        if (jVar instanceof androidx.activity.c) {
            androidx.activity.c cVar = (androidx.activity.c) jVar;
            this.f779g = cVar.c();
            androidx.lifecycle.l lVar = cVar;
            if (fragment != null) {
                lVar = fragment;
            }
            this.f779g.a(lVar, this.f780h);
        }
        if (fragment != null) {
            this.M = fragment.w.m0(fragment);
        } else if (jVar instanceof androidx.lifecycle.z) {
            this.M = androidx.fragment.app.p.j(((androidx.lifecycle.z) jVar).j());
        } else {
            this.M = new androidx.fragment.app.p(false);
        }
        this.M.o(I0());
        this.f775c.x(this.M);
        Object obj = this.r;
        if (obj instanceof androidx.activity.result.e) {
            androidx.activity.result.d dVarH = ((androidx.activity.result.e) obj).h();
            if (fragment != null) {
                str = fragment.f677j + ":";
            } else {
                str = "";
            }
            String str2 = "FragmentManager:" + str;
            this.z = dVarH.i(str2 + "StartActivityForResult", new androidx.activity.result.g.c(), new j());
            this.A = dVarH.i(str2 + "StartIntentSenderForResult", new k(), new a());
            this.B = dVarH.i(str2 + "RequestPermissions", new androidx.activity.result.g.b(), new b());
        }
    }

    void k(Fragment fragment) {
        if (D0(2)) {
            Log.v("FragmentManager", "attach: " + fragment);
        }
        if (fragment.E) {
            fragment.E = false;
            if (fragment.p) {
                return;
            }
            this.f775c.a(fragment);
            if (D0(2)) {
                Log.v("FragmentManager", "add from attach: " + fragment);
            }
            if (E0(fragment)) {
                this.D = true;
            }
        }
    }

    public v l() {
        return new androidx.fragment.app.a(this);
    }

    public int l0() {
        ArrayList<androidx.fragment.app.a> arrayList = this.f776d;
        if (arrayList != null) {
            return arrayList.size();
        }
        return 0;
    }

    boolean n() {
        boolean zE0 = false;
        for (Fragment fragment : this.f775c.l()) {
            if (fragment != null) {
                zE0 = E0(fragment);
            }
            if (zE0) {
                return true;
            }
        }
        return false;
    }

    androidx.fragment.app.f n0() {
        return this.s;
    }

    public androidx.fragment.app.i p0() {
        androidx.fragment.app.i iVar = this.v;
        if (iVar != null) {
            return iVar;
        }
        Fragment fragment = this.t;
        return fragment != null ? fragment.w.p0() : this.w;
    }

    public final void q(String str) {
        this.f782j.remove(str);
    }

    u q0() {
        return this.f775c;
    }

    public List<Fragment> r0() {
        return this.f775c.n();
    }

    androidx.fragment.app.j<?> s0() {
        return this.r;
    }

    void t(androidx.fragment.app.a aVar, boolean z, boolean z2, boolean z3) {
        if (z) {
            aVar.s(z3);
        } else {
            aVar.r();
        }
        ArrayList arrayList = new ArrayList(1);
        ArrayList arrayList2 = new ArrayList(1);
        arrayList.add(aVar);
        arrayList2.add(Boolean.valueOf(z));
        if (z2 && this.q >= 1) {
            w.C(this.r.k(), this.s, arrayList, arrayList2, 0, 1, true, this.n);
        }
        if (z3) {
            M0(this.q, true);
        }
        for (Fragment fragment : this.f775c.l()) {
            if (fragment != null && fragment.L != null && fragment.P && aVar.v(fragment.B)) {
                float f2 = fragment.R;
                if (f2 > 0.0f) {
                    fragment.L.setAlpha(f2);
                }
                if (z3) {
                    fragment.R = 0.0f;
                } else {
                    fragment.R = -1.0f;
                    fragment.P = false;
                }
            }
        }
    }

    LayoutInflater.Factory2 t0() {
        return this.f778f;
    }

    public String toString() {
        StringBuilder sb = new StringBuilder(ICmdMsg.ACTION_START_ACTIVITY);
        sb.append("FragmentManager{");
        sb.append(Integer.toHexString(System.identityHashCode(this)));
        sb.append(" in ");
        Fragment fragment = this.t;
        if (fragment != null) {
            sb.append(fragment.getClass().getSimpleName());
            sb.append("{");
            sb.append(Integer.toHexString(System.identityHashCode(this.t)));
            sb.append("}");
        } else {
            androidx.fragment.app.j<?> jVar = this.r;
            if (jVar != null) {
                sb.append(jVar.getClass().getSimpleName());
                sb.append("{");
                sb.append(Integer.toHexString(System.identityHashCode(this.r)));
                sb.append("}");
            } else {
                sb.append("null");
            }
        }
        sb.append("}}");
        return sb.toString();
    }

    androidx.fragment.app.l u0() {
        return this.o;
    }

    t v(Fragment fragment) {
        t tVarM = this.f775c.m(fragment.f677j);
        if (tVarM != null) {
            return tVarM;
        }
        t tVar = new t(this.o, this.f775c, fragment);
        tVar.o(this.r.k().getClassLoader());
        tVar.t(this.q);
        return tVar;
    }

    Fragment v0() {
        return this.t;
    }

    public Fragment w0() {
        return this.u;
    }

    void x(Fragment fragment) {
        if (D0(2)) {
            Log.v("FragmentManager", "detach: " + fragment);
        }
        if (fragment.E) {
            return;
        }
        fragment.E = true;
        if (fragment.p) {
            if (D0(2)) {
                Log.v("FragmentManager", "remove from detach: " + fragment);
            }
            this.f775c.s(fragment);
            if (E0(fragment)) {
                this.D = true;
            }
            h1(fragment);
        }
    }

    d0 x0() {
        d0 d0Var = this.x;
        if (d0Var != null) {
            return d0Var;
        }
        Fragment fragment = this.t;
        return fragment != null ? fragment.w.x0() : this.y;
    }

    void y() {
        this.E = false;
        this.F = false;
        this.M.o(false);
        S(4);
    }

    void z() {
        this.E = false;
        this.F = false;
        this.M.o(false);
        S(0);
    }

    androidx.lifecycle.y z0(Fragment fragment) {
        return this.M.l(fragment);
    }

    /* JADX INFO: renamed from: androidx.fragment.app.m$m, reason: collision with other inner class name */
    /* JADX INFO: compiled from: FragmentManager.java */
    @SuppressLint({"BanParcelableUsage"})
    static class C0012m implements Parcelable {
        public static final Parcelable.Creator<C0012m> CREATOR = new a();

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

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

        /* JADX INFO: renamed from: androidx.fragment.app.m$m$a */
        /* JADX INFO: compiled from: FragmentManager.java */
        class a implements Parcelable.Creator<C0012m> {
            a() {
            }

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

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

        C0012m(String str, int i2) {
            this.f790b = str;
            this.f791f = i2;
        }

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

        @Override // android.os.Parcelable
        public void writeToParcel(Parcel parcel, int i2) {
            parcel.writeString(this.f790b);
            parcel.writeInt(this.f791f);
        }

        C0012m(Parcel parcel) {
            this.f790b = parcel.readString();
            this.f791f = parcel.readInt();
        }
    }
}
