package androidx.fragment.app;

import F1.InterfaceC0178g;
import android.content.res.Configuration;
import android.os.Bundle;
import android.os.Looper;
import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import androidx.core.app.C1000g;
import androidx.lifecycle.EnumC1108q;
import androidx.lifecycle.InterfaceC1113w;
import com.debridstream.tv.R;
import com.revenuecat.purchases.common.Constants;
import d.C1818B;
import d.InterfaceC1819C;
import g.AbstractC2055i;
import g.C2054h;
import g.InterfaceC2056j;
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.Map;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.atomic.AtomicInteger;
import n2.C2616g;
import n2.InterfaceC2618i;
import x1.InterfaceC3211c;
import x1.InterfaceC3212d;

/* JADX INFO: renamed from: androidx.fragment.app.g0, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes.dex */
public abstract class AbstractC1050g0 {

    /* JADX INFO: renamed from: A, reason: collision with root package name */
    public C2054h f11590A;

    /* JADX INFO: renamed from: B, reason: collision with root package name */
    public C2054h f11591B;

    /* JADX INFO: renamed from: C, reason: collision with root package name */
    public C2054h f11592C;

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

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

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

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

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

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

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

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

    /* JADX INFO: renamed from: M, reason: collision with root package name */
    public FragmentManagerViewModel f11602M;

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

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

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

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

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public final X f11611h;

    /* JADX INFO: renamed from: o, reason: collision with root package name */
    public final V f11617o;

    /* JADX INFO: renamed from: p, reason: collision with root package name */
    public final V f11618p;

    /* JADX INFO: renamed from: q, reason: collision with root package name */
    public final V f11619q;

    /* JADX INFO: renamed from: r, reason: collision with root package name */
    public final V f11620r;

    /* JADX INFO: renamed from: u, reason: collision with root package name */
    public S f11623u;

    /* JADX INFO: renamed from: v, reason: collision with root package name */
    public O f11624v;

    /* JADX INFO: renamed from: w, reason: collision with root package name */
    public G f11625w;

    /* JADX INFO: renamed from: x, reason: collision with root package name */
    public G f11626x;

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final ArrayList f11604a = new ArrayList();

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final p0 f11606c = new p0();

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public final U f11609f = new U(this);

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

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    public final Map f11613j = Collections.synchronizedMap(new HashMap());

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    public final Map f11614k = Collections.synchronizedMap(new HashMap());
    public final Map l = Collections.synchronizedMap(new HashMap());

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    public final M f11615m = new M(this);

    /* JADX INFO: renamed from: n, reason: collision with root package name */
    public final CopyOnWriteArrayList f11616n = new CopyOnWriteArrayList();

    /* JADX INFO: renamed from: s, reason: collision with root package name */
    public final Y f11621s = new Y(this);

    /* JADX INFO: renamed from: t, reason: collision with root package name */
    public int f11622t = -1;

    /* JADX INFO: renamed from: y, reason: collision with root package name */
    public final Z f11627y = new Z(this);

    /* JADX INFO: renamed from: z, reason: collision with root package name */
    public final C1038a0 f11628z = new C1038a0();

    /* JADX INFO: renamed from: D, reason: collision with root package name */
    public ArrayDeque f11593D = new ArrayDeque();

    /* JADX INFO: renamed from: N, reason: collision with root package name */
    public final RunnableC1059p f11603N = new RunnableC1059p(this, 2);

    /* JADX WARN: Type inference failed for: r0v13, types: [androidx.fragment.app.V] */
    /* JADX WARN: Type inference failed for: r0v14, types: [androidx.fragment.app.V] */
    /* JADX WARN: Type inference failed for: r0v15, types: [androidx.fragment.app.V] */
    /* JADX WARN: Type inference failed for: r0v16, types: [androidx.fragment.app.V] */
    public AbstractC1050g0() {
        final int i6 = 0;
        this.f11611h = new X(this, i6);
        this.f11617o = new E1.a(this) { // from class: androidx.fragment.app.V

            /* JADX INFO: renamed from: b, reason: collision with root package name */
            public final /* synthetic */ AbstractC1050g0 f11547b;

            {
                this.f11547b = this;
            }

            @Override // E1.a
            public final void accept(Object obj) {
                switch (i6) {
                    case 0:
                        Configuration configuration = (Configuration) obj;
                        AbstractC1050g0 abstractC1050g0 = this.f11547b;
                        if (abstractC1050g0.J()) {
                            abstractC1050g0.h(false, configuration);
                        }
                        break;
                    case 1:
                        Integer num = (Integer) obj;
                        AbstractC1050g0 abstractC1050g02 = this.f11547b;
                        if (abstractC1050g02.J() && num.intValue() == 80) {
                            abstractC1050g02.l(false);
                            break;
                        }
                        break;
                    case 2:
                        C1000g c1000g = (C1000g) obj;
                        AbstractC1050g0 abstractC1050g03 = this.f11547b;
                        if (abstractC1050g03.J()) {
                            abstractC1050g03.m(c1000g.f11231a, false);
                        }
                        break;
                    default:
                        androidx.core.app.P p6 = (androidx.core.app.P) obj;
                        AbstractC1050g0 abstractC1050g04 = this.f11547b;
                        if (abstractC1050g04.J()) {
                            abstractC1050g04.r(p6.f11223a, false);
                        }
                        break;
                }
            }
        };
        final int i7 = 1;
        this.f11618p = new E1.a(this) { // from class: androidx.fragment.app.V

            /* JADX INFO: renamed from: b, reason: collision with root package name */
            public final /* synthetic */ AbstractC1050g0 f11547b;

            {
                this.f11547b = this;
            }

            @Override // E1.a
            public final void accept(Object obj) {
                switch (i7) {
                    case 0:
                        Configuration configuration = (Configuration) obj;
                        AbstractC1050g0 abstractC1050g0 = this.f11547b;
                        if (abstractC1050g0.J()) {
                            abstractC1050g0.h(false, configuration);
                        }
                        break;
                    case 1:
                        Integer num = (Integer) obj;
                        AbstractC1050g0 abstractC1050g02 = this.f11547b;
                        if (abstractC1050g02.J() && num.intValue() == 80) {
                            abstractC1050g02.l(false);
                            break;
                        }
                        break;
                    case 2:
                        C1000g c1000g = (C1000g) obj;
                        AbstractC1050g0 abstractC1050g03 = this.f11547b;
                        if (abstractC1050g03.J()) {
                            abstractC1050g03.m(c1000g.f11231a, false);
                        }
                        break;
                    default:
                        androidx.core.app.P p6 = (androidx.core.app.P) obj;
                        AbstractC1050g0 abstractC1050g04 = this.f11547b;
                        if (abstractC1050g04.J()) {
                            abstractC1050g04.r(p6.f11223a, false);
                        }
                        break;
                }
            }
        };
        final int i8 = 2;
        this.f11619q = new E1.a(this) { // from class: androidx.fragment.app.V

            /* JADX INFO: renamed from: b, reason: collision with root package name */
            public final /* synthetic */ AbstractC1050g0 f11547b;

            {
                this.f11547b = this;
            }

            @Override // E1.a
            public final void accept(Object obj) {
                switch (i8) {
                    case 0:
                        Configuration configuration = (Configuration) obj;
                        AbstractC1050g0 abstractC1050g0 = this.f11547b;
                        if (abstractC1050g0.J()) {
                            abstractC1050g0.h(false, configuration);
                        }
                        break;
                    case 1:
                        Integer num = (Integer) obj;
                        AbstractC1050g0 abstractC1050g02 = this.f11547b;
                        if (abstractC1050g02.J() && num.intValue() == 80) {
                            abstractC1050g02.l(false);
                            break;
                        }
                        break;
                    case 2:
                        C1000g c1000g = (C1000g) obj;
                        AbstractC1050g0 abstractC1050g03 = this.f11547b;
                        if (abstractC1050g03.J()) {
                            abstractC1050g03.m(c1000g.f11231a, false);
                        }
                        break;
                    default:
                        androidx.core.app.P p6 = (androidx.core.app.P) obj;
                        AbstractC1050g0 abstractC1050g04 = this.f11547b;
                        if (abstractC1050g04.J()) {
                            abstractC1050g04.r(p6.f11223a, false);
                        }
                        break;
                }
            }
        };
        final int i9 = 3;
        this.f11620r = new E1.a(this) { // from class: androidx.fragment.app.V

            /* JADX INFO: renamed from: b, reason: collision with root package name */
            public final /* synthetic */ AbstractC1050g0 f11547b;

            {
                this.f11547b = this;
            }

            @Override // E1.a
            public final void accept(Object obj) {
                switch (i9) {
                    case 0:
                        Configuration configuration = (Configuration) obj;
                        AbstractC1050g0 abstractC1050g0 = this.f11547b;
                        if (abstractC1050g0.J()) {
                            abstractC1050g0.h(false, configuration);
                        }
                        break;
                    case 1:
                        Integer num = (Integer) obj;
                        AbstractC1050g0 abstractC1050g02 = this.f11547b;
                        if (abstractC1050g02.J() && num.intValue() == 80) {
                            abstractC1050g02.l(false);
                            break;
                        }
                        break;
                    case 2:
                        C1000g c1000g = (C1000g) obj;
                        AbstractC1050g0 abstractC1050g03 = this.f11547b;
                        if (abstractC1050g03.J()) {
                            abstractC1050g03.m(c1000g.f11231a, false);
                        }
                        break;
                    default:
                        androidx.core.app.P p6 = (androidx.core.app.P) obj;
                        AbstractC1050g0 abstractC1050g04 = this.f11547b;
                        if (abstractC1050g04.J()) {
                            abstractC1050g04.r(p6.f11223a, false);
                        }
                        break;
                }
            }
        };
    }

    public static boolean H(int i6) {
        return Log.isLoggable("FragmentManager", i6);
    }

    public static boolean I(G g6) {
        if (g6.mHasMenu && g6.mMenuVisible) {
            return true;
        }
        boolean zI = false;
        for (G g7 : g6.mChildFragmentManager.f11606c.e()) {
            if (g7 != null) {
                zI = I(g7);
            }
            if (zI) {
                return true;
            }
        }
        return false;
    }

    public static boolean K(G g6) {
        if (g6 == null) {
            return true;
        }
        AbstractC1050g0 abstractC1050g0 = g6.mFragmentManager;
        return g6.equals(abstractC1050g0.f11626x) && K(abstractC1050g0.f11625w);
    }

    public static void Z(G g6) {
        if (H(2)) {
            Log.v("FragmentManager", "show: " + g6);
        }
        if (g6.mHidden) {
            g6.mHidden = false;
            g6.mHiddenChanged = !g6.mHiddenChanged;
        }
    }

    public final G A(int i6) {
        p0 p0Var = this.f11606c;
        ArrayList arrayList = p0Var.f11689a;
        for (int size = arrayList.size() - 1; size >= 0; size--) {
            G g6 = (G) arrayList.get(size);
            if (g6 != null && g6.mFragmentId == i6) {
                return g6;
            }
        }
        for (o0 o0Var : p0Var.f11690b.values()) {
            if (o0Var != null) {
                G g7 = o0Var.f11684c;
                if (g7.mFragmentId == i6) {
                    return g7;
                }
            }
        }
        return null;
    }

    public final G B(String str) {
        p0 p0Var = this.f11606c;
        ArrayList arrayList = p0Var.f11689a;
        for (int size = arrayList.size() - 1; size >= 0; size--) {
            G g6 = (G) arrayList.get(size);
            if (g6 != null && str.equals(g6.mTag)) {
                return g6;
            }
        }
        for (o0 o0Var : p0Var.f11690b.values()) {
            if (o0Var != null) {
                G g7 = o0Var.f11684c;
                if (str.equals(g7.mTag)) {
                    return g7;
                }
            }
        }
        return null;
    }

    public final void C() {
        for (C1058o c1058o : e()) {
            if (c1058o.f11681e) {
                if (H(2)) {
                    Log.v("FragmentManager", "SpecialEffectsController: Forcing postponed operations");
                }
                c1058o.f11681e = false;
                c1058o.d();
            }
        }
    }

    public final ViewGroup D(G g6) {
        ViewGroup viewGroup = g6.mContainer;
        if (viewGroup != null) {
            return viewGroup;
        }
        if (g6.mContainerId <= 0 || !this.f11624v.c()) {
            return null;
        }
        View viewB = this.f11624v.b(g6.mContainerId);
        if (viewB instanceof ViewGroup) {
            return (ViewGroup) viewB;
        }
        return null;
    }

    public final Z E() {
        G g6 = this.f11625w;
        return g6 != null ? g6.mFragmentManager.E() : this.f11627y;
    }

    public final C1038a0 F() {
        G g6 = this.f11625w;
        return g6 != null ? g6.mFragmentManager.F() : this.f11628z;
    }

    public final void G(G g6) {
        if (H(2)) {
            Log.v("FragmentManager", "hide: " + g6);
        }
        if (g6.mHidden) {
            return;
        }
        g6.mHidden = true;
        g6.mHiddenChanged = true ^ g6.mHiddenChanged;
        Y(g6);
    }

    public final boolean J() {
        G g6 = this.f11625w;
        if (g6 == null) {
            return true;
        }
        return g6.isAdded() && this.f11625w.getParentFragmentManager().J();
    }

    public final void L(int i6, boolean z6) {
        HashMap map;
        S s6;
        if (this.f11623u == null && i6 != -1) {
            throw new IllegalStateException("No activity");
        }
        if (z6 || i6 != this.f11622t) {
            this.f11622t = i6;
            p0 p0Var = this.f11606c;
            Iterator it = p0Var.f11689a.iterator();
            while (true) {
                boolean zHasNext = it.hasNext();
                map = p0Var.f11690b;
                if (!zHasNext) {
                    break;
                }
                o0 o0Var = (o0) map.get(((G) it.next()).mWho);
                if (o0Var != null) {
                    o0Var.k();
                }
            }
            for (o0 o0Var2 : map.values()) {
                if (o0Var2 != null) {
                    o0Var2.k();
                    G g6 = o0Var2.f11684c;
                    if (g6.mRemoving && !g6.isInBackStack()) {
                        if (g6.mBeingSaved && !p0Var.f11691c.containsKey(g6.mWho)) {
                            p0Var.i(o0Var2.n(), g6.mWho);
                        }
                        p0Var.h(o0Var2);
                    }
                }
            }
            for (o0 o0Var3 : p0Var.d()) {
                G g7 = o0Var3.f11684c;
                if (g7.mDeferStart) {
                    if (this.f11605b) {
                        this.f11598I = true;
                    } else {
                        g7.mDeferStart = false;
                        o0Var3.k();
                    }
                }
            }
            if (this.f11594E && (s6 = this.f11623u) != null && this.f11622t == 7) {
                ((K) s6).f11526e.invalidateMenu();
                this.f11594E = false;
            }
        }
    }

    public final void M() {
        if (this.f11623u == null) {
            return;
        }
        this.f11595F = false;
        this.f11596G = false;
        this.f11602M.setIsStateSaved(false);
        for (G g6 : this.f11606c.f()) {
            if (g6 != null) {
                g6.noteStateNotSaved();
            }
        }
    }

    public final boolean N() {
        return O(-1, 0);
    }

    public final boolean O(int i6, int i7) {
        x(false);
        w(true);
        G g6 = this.f11626x;
        if (g6 != null && i6 < 0 && g6.getChildFragmentManager().N()) {
            return true;
        }
        boolean zP = P(this.f11599J, this.f11600K, i6, i7);
        if (zP) {
            this.f11605b = true;
            try {
                R(this.f11599J, this.f11600K);
            } finally {
                d();
            }
        }
        b0();
        boolean z6 = this.f11598I;
        p0 p0Var = this.f11606c;
        if (z6) {
            this.f11598I = false;
            for (o0 o0Var : p0Var.d()) {
                G g7 = o0Var.f11684c;
                if (g7.mDeferStart) {
                    if (this.f11605b) {
                        this.f11598I = true;
                    } else {
                        g7.mDeferStart = false;
                        o0Var.k();
                    }
                }
            }
        }
        p0Var.f11690b.values().removeAll(Collections.singleton(null));
        return zP;
    }

    public final boolean P(ArrayList arrayList, ArrayList arrayList2, int i6, int i7) {
        boolean z6 = (i7 & 1) != 0;
        ArrayList arrayList3 = this.f11607d;
        int size = -1;
        if (arrayList3 != null && !arrayList3.isEmpty()) {
            if (i6 < 0) {
                size = z6 ? 0 : this.f11607d.size() - 1;
            } else {
                int size2 = this.f11607d.size() - 1;
                while (size2 >= 0) {
                    C1037a c1037a = (C1037a) this.f11607d.get(size2);
                    if (i6 >= 0 && i6 == c1037a.f11557r) {
                        break;
                    }
                    size2--;
                }
                if (size2 < 0) {
                    size = size2;
                } else if (z6) {
                    size = size2;
                    while (size > 0) {
                        C1037a c1037a2 = (C1037a) this.f11607d.get(size - 1);
                        if (i6 < 0 || i6 != c1037a2.f11557r) {
                            break;
                        }
                        size--;
                    }
                } else if (size2 != this.f11607d.size() - 1) {
                    size = size2 + 1;
                }
            }
        }
        if (size < 0) {
            return false;
        }
        for (int size3 = this.f11607d.size() - 1; size3 >= size; size3--) {
            arrayList.add((C1037a) this.f11607d.remove(size3));
            arrayList2.add(Boolean.TRUE);
        }
        return true;
    }

    public final void Q(G g6) {
        if (H(2)) {
            Log.v("FragmentManager", "remove: " + g6 + " nesting=" + g6.mBackStackNesting);
        }
        boolean zIsInBackStack = g6.isInBackStack();
        if (g6.mDetached && zIsInBackStack) {
            return;
        }
        p0 p0Var = this.f11606c;
        synchronized (p0Var.f11689a) {
            p0Var.f11689a.remove(g6);
        }
        g6.mAdded = false;
        if (I(g6)) {
            this.f11594E = true;
        }
        g6.mRemoving = true;
        Y(g6);
    }

    public final void R(ArrayList arrayList, ArrayList arrayList2) {
        if (arrayList.isEmpty()) {
            return;
        }
        if (arrayList.size() != arrayList2.size()) {
            throw new IllegalStateException("Internal error with the back stack records");
        }
        int size = arrayList.size();
        int i6 = 0;
        int i7 = 0;
        while (i6 < size) {
            if (!((C1037a) arrayList.get(i6)).f11717o) {
                if (i7 != i6) {
                    z(arrayList, arrayList2, i7, i6);
                }
                i7 = i6 + 1;
                if (((Boolean) arrayList2.get(i6)).booleanValue()) {
                    while (i7 < size && ((Boolean) arrayList2.get(i7)).booleanValue() && !((C1037a) arrayList.get(i7)).f11717o) {
                        i7++;
                    }
                }
                z(arrayList, arrayList2, i6, i7);
                i6 = i7 - 1;
            }
            i6++;
        }
        if (i7 != size) {
            z(arrayList, arrayList2, i7, size);
        }
    }

    public final void S(Bundle bundle) {
        int i6;
        M m6;
        int i7;
        o0 o0Var;
        Bundle bundle2;
        Bundle bundle3;
        for (String str : bundle.keySet()) {
            if (str.startsWith("result_") && (bundle3 = bundle.getBundle(str)) != null) {
                bundle3.setClassLoader(this.f11623u.f11540b.getClassLoader());
                this.f11614k.put(str.substring(7), bundle3);
            }
        }
        HashMap map = new HashMap();
        for (String str2 : bundle.keySet()) {
            if (str2.startsWith("fragment_") && (bundle2 = bundle.getBundle(str2)) != null) {
                bundle2.setClassLoader(this.f11623u.f11540b.getClassLoader());
                map.put(str2.substring(9), bundle2);
            }
        }
        p0 p0Var = this.f11606c;
        HashMap map2 = p0Var.f11691c;
        map2.clear();
        map2.putAll(map);
        j0 j0Var = (j0) bundle.getParcelable("state");
        if (j0Var == null) {
            return;
        }
        HashMap map3 = p0Var.f11690b;
        map3.clear();
        Iterator it = j0Var.f11641a.iterator();
        while (true) {
            boolean zHasNext = it.hasNext();
            i6 = 2;
            m6 = this.f11615m;
            if (!zHasNext) {
                break;
            }
            Bundle bundleI = p0Var.i(null, (String) it.next());
            if (bundleI != null) {
                G gFindRetainedFragmentByWho = this.f11602M.findRetainedFragmentByWho(((m0) bundleI.getParcelable("state")).f11660b);
                if (gFindRetainedFragmentByWho != null) {
                    if (H(2)) {
                        Log.v("FragmentManager", "restoreSaveState: re-attaching retained " + gFindRetainedFragmentByWho);
                    }
                    o0Var = new o0(m6, p0Var, gFindRetainedFragmentByWho, bundleI);
                } else {
                    o0Var = new o0(this.f11615m, this.f11606c, this.f11623u.f11540b.getClassLoader(), E(), bundleI);
                }
                G g6 = o0Var.f11684c;
                g6.mSavedFragmentState = bundleI;
                g6.mFragmentManager = this;
                if (H(2)) {
                    Log.v("FragmentManager", "restoreSaveState: active (" + g6.mWho + "): " + g6);
                }
                o0Var.l(this.f11623u.f11540b.getClassLoader());
                p0Var.g(o0Var);
                o0Var.f11686e = this.f11622t;
            }
        }
        for (G g7 : this.f11602M.getRetainedFragments()) {
            if (map3.get(g7.mWho) == null) {
                if (H(2)) {
                    Log.v("FragmentManager", "Discarding retained Fragment " + g7 + " that was not found in the set of active Fragments " + j0Var.f11641a);
                }
                this.f11602M.removeRetainedFragment(g7);
                g7.mFragmentManager = this;
                o0 o0Var2 = new o0(m6, p0Var, g7);
                o0Var2.f11686e = 1;
                o0Var2.k();
                g7.mRemoving = true;
                o0Var2.k();
            }
        }
        ArrayList<String> arrayList = j0Var.f11642b;
        p0Var.f11689a.clear();
        if (arrayList != null) {
            for (String str3 : arrayList) {
                G gB = p0Var.b(str3);
                if (gB == null) {
                    throw new IllegalStateException(Z0.o.o("No instantiated fragment for (", str3, ")"));
                }
                if (H(2)) {
                    Log.v("FragmentManager", "restoreSaveState: added (" + str3 + "): " + gB);
                }
                p0Var.a(gB);
            }
        }
        if (j0Var.f11643c != null) {
            this.f11607d = new ArrayList(j0Var.f11643c.length);
            int i8 = 0;
            while (true) {
                C1041c[] c1041cArr = j0Var.f11643c;
                if (i8 >= c1041cArr.length) {
                    break;
                }
                C1041c c1041c = c1041cArr[i8];
                c1041c.getClass();
                C1037a c1037a = new C1037a(this);
                int i9 = 0;
                int i10 = 0;
                while (true) {
                    int[] iArr = c1041c.f11560a;
                    if (i9 >= iArr.length) {
                        break;
                    }
                    q0 q0Var = new q0();
                    int i11 = i9 + 1;
                    int i12 = i6;
                    q0Var.f11694a = iArr[i9];
                    if (H(i12)) {
                        Log.v("FragmentManager", "Instantiate " + c1037a + " op #" + i10 + " base fragment #" + iArr[i11]);
                    }
                    q0Var.f11701h = EnumC1108q.values()[c1041c.f11562c[i10]];
                    q0Var.f11702i = EnumC1108q.values()[c1041c.f11563d[i10]];
                    int i13 = i9 + 2;
                    q0Var.f11696c = iArr[i11] != 0;
                    int i14 = iArr[i13];
                    q0Var.f11697d = i14;
                    int i15 = iArr[i9 + 3];
                    q0Var.f11698e = i15;
                    int i16 = i9 + 5;
                    int i17 = iArr[i9 + 4];
                    q0Var.f11699f = i17;
                    i9 += 6;
                    int i18 = iArr[i16];
                    q0Var.f11700g = i18;
                    c1037a.f11705b = i14;
                    c1037a.f11706c = i15;
                    c1037a.f11707d = i17;
                    c1037a.f11708e = i18;
                    c1037a.b(q0Var);
                    i10++;
                    i6 = i12;
                }
                int i19 = i6;
                c1037a.f11709f = c1041c.f11564e;
                c1037a.f11711h = c1041c.f11565f;
                c1037a.f11710g = true;
                c1037a.f11712i = c1041c.f11567k;
                c1037a.f11713j = c1041c.l;
                c1037a.f11714k = c1041c.f11568m;
                c1037a.l = c1041c.f11569n;
                c1037a.f11715m = c1041c.f11570o;
                c1037a.f11716n = c1041c.f11571p;
                c1037a.f11717o = c1041c.f11572q;
                c1037a.f11557r = c1041c.f11566j;
                int i20 = 0;
                while (true) {
                    ArrayList arrayList2 = c1041c.f11561b;
                    if (i20 >= arrayList2.size()) {
                        break;
                    }
                    String str4 = (String) arrayList2.get(i20);
                    if (str4 != null) {
                        ((q0) c1037a.f11704a.get(i20)).f11695b = p0Var.b(str4);
                    }
                    i20++;
                }
                c1037a.d(1);
                if (H(i19)) {
                    StringBuilder sbR = com.google.android.recaptcha.internal.a.r(i8, "restoreAllState: back stack #", " (index ");
                    sbR.append(c1037a.f11557r);
                    sbR.append("): ");
                    sbR.append(c1037a);
                    Log.v("FragmentManager", sbR.toString());
                    PrintWriter printWriter = new PrintWriter(new B0());
                    c1037a.f("  ", printWriter, false);
                    printWriter.close();
                }
                this.f11607d.add(c1037a);
                i8++;
                i6 = i19;
            }
            i7 = 0;
        } else {
            i7 = 0;
            this.f11607d = null;
        }
        this.f11612i.set(j0Var.f11644d);
        String str5 = j0Var.f11645e;
        if (str5 != null) {
            G gB2 = p0Var.b(str5);
            this.f11626x = gB2;
            q(gB2);
        }
        ArrayList arrayList3 = j0Var.f11646f;
        if (arrayList3 != null) {
            for (int i21 = i7; i21 < arrayList3.size(); i21++) {
                this.f11613j.put((String) arrayList3.get(i21), (C1043d) j0Var.f11647j.get(i21));
            }
        }
        this.f11593D = new ArrayDeque(j0Var.f11648k);
    }

    public final Bundle T() {
        ArrayList arrayList;
        C1041c[] c1041cArr;
        int size;
        Bundle bundle = new Bundle();
        C();
        Iterator it = e().iterator();
        while (it.hasNext()) {
            ((C1058o) it.next()).g();
        }
        x(true);
        this.f11595F = true;
        this.f11602M.setIsStateSaved(true);
        p0 p0Var = this.f11606c;
        p0Var.getClass();
        HashMap map = p0Var.f11690b;
        ArrayList arrayList2 = new ArrayList(map.size());
        for (o0 o0Var : map.values()) {
            if (o0Var != null) {
                G g6 = o0Var.f11684c;
                p0Var.i(o0Var.n(), g6.mWho);
                arrayList2.add(g6.mWho);
                if (H(2)) {
                    Log.v("FragmentManager", "Saved state of " + g6 + ": " + g6.mSavedFragmentState);
                }
            }
        }
        HashMap map2 = this.f11606c.f11691c;
        if (!map2.isEmpty()) {
            p0 p0Var2 = this.f11606c;
            synchronized (p0Var2.f11689a) {
                try {
                    if (p0Var2.f11689a.isEmpty()) {
                        arrayList = null;
                    } else {
                        arrayList = new ArrayList(p0Var2.f11689a.size());
                        for (G g7 : p0Var2.f11689a) {
                            arrayList.add(g7.mWho);
                            if (H(2)) {
                                Log.v("FragmentManager", "saveAllState: adding fragment (" + g7.mWho + "): " + g7);
                            }
                        }
                    }
                } finally {
                }
            }
            ArrayList arrayList3 = this.f11607d;
            if (arrayList3 == null || (size = arrayList3.size()) <= 0) {
                c1041cArr = null;
            } else {
                c1041cArr = new C1041c[size];
                for (int i6 = 0; i6 < size; i6++) {
                    c1041cArr[i6] = new C1041c((C1037a) this.f11607d.get(i6));
                    if (H(2)) {
                        StringBuilder sbR = com.google.android.recaptcha.internal.a.r(i6, "saveAllState: adding back stack #", ": ");
                        sbR.append(this.f11607d.get(i6));
                        Log.v("FragmentManager", sbR.toString());
                    }
                }
            }
            j0 j0Var = new j0();
            j0Var.f11645e = null;
            ArrayList arrayList4 = new ArrayList();
            j0Var.f11646f = arrayList4;
            ArrayList arrayList5 = new ArrayList();
            j0Var.f11647j = arrayList5;
            j0Var.f11641a = arrayList2;
            j0Var.f11642b = arrayList;
            j0Var.f11643c = c1041cArr;
            j0Var.f11644d = this.f11612i.get();
            G g8 = this.f11626x;
            if (g8 != null) {
                j0Var.f11645e = g8.mWho;
            }
            arrayList4.addAll(this.f11613j.keySet());
            arrayList5.addAll(this.f11613j.values());
            j0Var.f11648k = new ArrayList(this.f11593D);
            bundle.putParcelable("state", j0Var);
            for (String str : this.f11614k.keySet()) {
                bundle.putBundle(A0.a.n("result_", str), (Bundle) this.f11614k.get(str));
            }
            for (String str2 : map2.keySet()) {
                bundle.putBundle(A0.a.n("fragment_", str2), (Bundle) map2.get(str2));
            }
        } else if (H(2)) {
            Log.v("FragmentManager", "saveAllState: no fragments!");
            return bundle;
        }
        return bundle;
    }

    public final void U() {
        synchronized (this.f11604a) {
            try {
                if (this.f11604a.size() == 1) {
                    this.f11623u.f11541c.removeCallbacks(this.f11603N);
                    this.f11623u.f11541c.post(this.f11603N);
                    b0();
                }
            } catch (Throwable th) {
                throw th;
            }
        }
    }

    public final void V(G g6, boolean z6) {
        ViewGroup viewGroupD = D(g6);
        if (viewGroupD == null || !(viewGroupD instanceof P)) {
            return;
        }
        ((P) viewGroupD).setDrawDisappearingViewsLast(!z6);
    }

    public final void W(G g6, EnumC1108q enumC1108q) {
        if (g6.equals(this.f11606c.b(g6.mWho)) && (g6.mHost == null || g6.mFragmentManager == this)) {
            g6.mMaxState = enumC1108q;
            return;
        }
        throw new IllegalArgumentException("Fragment " + g6 + " is not an active fragment of FragmentManager " + this);
    }

    public final void X(G g6) {
        if (g6 != null) {
            if (!g6.equals(this.f11606c.b(g6.mWho)) || (g6.mHost != null && g6.mFragmentManager != this)) {
                throw new IllegalArgumentException("Fragment " + g6 + " is not an active fragment of FragmentManager " + this);
            }
        }
        G g7 = this.f11626x;
        this.f11626x = g6;
        q(g7);
        q(this.f11626x);
    }

    public final void Y(G g6) {
        ViewGroup viewGroupD = D(g6);
        if (viewGroupD != null) {
            if (g6.getPopExitAnim() + g6.getPopEnterAnim() + g6.getExitAnim() + g6.getEnterAnim() > 0) {
                if (viewGroupD.getTag(R.id.visible_removing_fragment_view_tag) == null) {
                    viewGroupD.setTag(R.id.visible_removing_fragment_view_tag, g6);
                }
                ((G) viewGroupD.getTag(R.id.visible_removing_fragment_view_tag)).setPopDirection(g6.getPopDirection());
            }
        }
    }

    public final o0 a(G g6) {
        String str = g6.mPreviousWho;
        if (str != null) {
            X1.d.c(g6, str);
        }
        if (H(2)) {
            Log.v("FragmentManager", "add: " + g6);
        }
        o0 o0VarF = f(g6);
        g6.mFragmentManager = this;
        p0 p0Var = this.f11606c;
        p0Var.g(o0VarF);
        if (!g6.mDetached) {
            p0Var.a(g6);
            g6.mRemoving = false;
            if (g6.mView == null) {
                g6.mHiddenChanged = false;
            }
            if (I(g6)) {
                this.f11594E = true;
            }
        }
        return o0VarF;
    }

    public final void a0(IllegalStateException illegalStateException) {
        Log.e("FragmentManager", illegalStateException.getMessage());
        Log.e("FragmentManager", "Activity state:");
        PrintWriter printWriter = new PrintWriter(new B0());
        S s6 = this.f11623u;
        if (s6 == null) {
            try {
                u("  ", null, printWriter, new String[0]);
                throw illegalStateException;
            } catch (Exception e6) {
                Log.e("FragmentManager", "Failed dumping state", e6);
                throw illegalStateException;
            }
        }
        try {
            ((K) s6).f11526e.dump("  ", null, printWriter, new String[0]);
            throw illegalStateException;
        } catch (Exception e7) {
            Log.e("FragmentManager", "Failed dumping state", e7);
            throw illegalStateException;
        }
    }

    /* JADX WARN: Multi-variable type inference failed */
    public final void b(S s6, O o6, G g6) {
        if (this.f11623u != null) {
            throw new IllegalStateException("Already attached");
        }
        this.f11623u = s6;
        this.f11624v = o6;
        this.f11625w = g6;
        CopyOnWriteArrayList copyOnWriteArrayList = this.f11616n;
        if (g6 != null) {
            copyOnWriteArrayList.add(new C1040b0(g6));
        } else if (s6 instanceof l0) {
            copyOnWriteArrayList.add((l0) s6);
        }
        if (this.f11625w != null) {
            b0();
        }
        if (s6 instanceof InterfaceC1819C) {
            InterfaceC1819C interfaceC1819C = (InterfaceC1819C) s6;
            C1818B onBackPressedDispatcher = interfaceC1819C.getOnBackPressedDispatcher();
            this.f11610g = onBackPressedDispatcher;
            InterfaceC1113w interfaceC1113w = interfaceC1819C;
            if (g6 != null) {
                interfaceC1113w = g6;
            }
            onBackPressedDispatcher.a(interfaceC1113w, this.f11611h);
        }
        if (g6 != null) {
            this.f11602M = g6.mFragmentManager.f11602M.getChildNonConfig(g6);
        } else if (s6 instanceof androidx.lifecycle.j0) {
            this.f11602M = FragmentManagerViewModel.getInstance(((androidx.lifecycle.j0) s6).getViewModelStore());
        } else {
            this.f11602M = new FragmentManagerViewModel(false);
        }
        this.f11602M.setIsStateSaved(this.f11595F || this.f11596G);
        this.f11606c.f11692d = this.f11602M;
        Object obj = this.f11623u;
        if ((obj instanceof InterfaceC2618i) && g6 == null) {
            C2616g savedStateRegistry = ((InterfaceC2618i) obj).getSavedStateRegistry();
            savedStateRegistry.c("android:support:fragments", new H(this, 1));
            Bundle bundleA = savedStateRegistry.a("android:support:fragments");
            if (bundleA != null) {
                S(bundleA);
            }
        }
        Object obj2 = this.f11623u;
        if (obj2 instanceof InterfaceC2056j) {
            AbstractC2055i activityResultRegistry = ((InterfaceC2056j) obj2).getActivityResultRegistry();
            String strN = A0.a.n("FragmentManager:", g6 != null ? com.google.android.recaptcha.internal.a.n(new StringBuilder(), g6.mWho, Constants.SUBS_ID_BASE_PLAN_ID_SEPARATOR) : "");
            this.f11590A = activityResultRegistry.d(Z0.o.n(strN, "StartActivityForResult"), new C1042c0(3), new W(this, 1));
            this.f11591B = activityResultRegistry.d(Z0.o.n(strN, "StartIntentSenderForResult"), new C1042c0(0), new W(this, 2));
            this.f11592C = activityResultRegistry.d(Z0.o.n(strN, "RequestPermissions"), new C1042c0(1), new W(this, 0));
        }
        Object obj3 = this.f11623u;
        if (obj3 instanceof InterfaceC3211c) {
            ((InterfaceC3211c) obj3).addOnConfigurationChangedListener(this.f11617o);
        }
        Object obj4 = this.f11623u;
        if (obj4 instanceof InterfaceC3212d) {
            ((InterfaceC3212d) obj4).addOnTrimMemoryListener(this.f11618p);
        }
        Object obj5 = this.f11623u;
        if (obj5 instanceof androidx.core.app.M) {
            ((androidx.core.app.M) obj5).addOnMultiWindowModeChangedListener(this.f11619q);
        }
        Object obj6 = this.f11623u;
        if (obj6 instanceof androidx.core.app.N) {
            ((androidx.core.app.N) obj6).addOnPictureInPictureModeChangedListener(this.f11620r);
        }
        Object obj7 = this.f11623u;
        if ((obj7 instanceof InterfaceC0178g) && g6 == null) {
            ((InterfaceC0178g) obj7).addMenuProvider(this.f11621s);
        }
    }

    /* JADX WARN: Type inference failed for: r0v2, types: [J4.a, kotlin.jvm.internal.l] */
    /* JADX WARN: Type inference failed for: r1v10, types: [J4.a, kotlin.jvm.internal.l] */
    public final void b0() {
        synchronized (this.f11604a) {
            try {
                if (!this.f11604a.isEmpty()) {
                    X x6 = this.f11611h;
                    x6.f14498a = true;
                    ?? r12 = x6.f14500c;
                    if (r12 != 0) {
                        r12.invoke();
                    }
                    return;
                }
                X x7 = this.f11611h;
                ArrayList arrayList = this.f11607d;
                x7.f14498a = (arrayList != null ? arrayList.size() : 0) > 0 && K(this.f11625w);
                ?? r02 = x7.f14500c;
                if (r02 != 0) {
                    r02.invoke();
                }
            } catch (Throwable th) {
                throw th;
            }
        }
    }

    public final void c(G g6) {
        if (H(2)) {
            Log.v("FragmentManager", "attach: " + g6);
        }
        if (g6.mDetached) {
            g6.mDetached = false;
            if (g6.mAdded) {
                return;
            }
            this.f11606c.a(g6);
            if (H(2)) {
                Log.v("FragmentManager", "add from attach: " + g6);
            }
            if (I(g6)) {
                this.f11594E = true;
            }
        }
    }

    public final void d() {
        this.f11605b = false;
        this.f11600K.clear();
        this.f11599J.clear();
    }

    public final HashSet e() {
        C1058o c1058o;
        HashSet hashSet = new HashSet();
        Iterator it = this.f11606c.d().iterator();
        while (it.hasNext()) {
            ViewGroup viewGroup = ((o0) it.next()).f11684c.mContainer;
            if (viewGroup != null) {
                C1038a0 factory = F();
                kotlin.jvm.internal.o.h(factory, "factory");
                Object tag = viewGroup.getTag(R.id.special_effects_controller_view_tag);
                if (tag instanceof C1058o) {
                    c1058o = (C1058o) tag;
                } else {
                    c1058o = new C1058o(viewGroup);
                    viewGroup.setTag(R.id.special_effects_controller_view_tag, c1058o);
                }
                hashSet.add(c1058o);
            }
        }
        return hashSet;
    }

    public final o0 f(G g6) {
        String str = g6.mWho;
        p0 p0Var = this.f11606c;
        o0 o0Var = (o0) p0Var.f11690b.get(str);
        if (o0Var != null) {
            return o0Var;
        }
        o0 o0Var2 = new o0(this.f11615m, p0Var, g6);
        o0Var2.l(this.f11623u.f11540b.getClassLoader());
        o0Var2.f11686e = this.f11622t;
        return o0Var2;
    }

    public final void g(G g6) {
        if (H(2)) {
            Log.v("FragmentManager", "detach: " + g6);
        }
        if (g6.mDetached) {
            return;
        }
        g6.mDetached = true;
        if (g6.mAdded) {
            if (H(2)) {
                Log.v("FragmentManager", "remove from detach: " + g6);
            }
            p0 p0Var = this.f11606c;
            synchronized (p0Var.f11689a) {
                p0Var.f11689a.remove(g6);
            }
            g6.mAdded = false;
            if (I(g6)) {
                this.f11594E = true;
            }
            Y(g6);
        }
    }

    public final void h(boolean z6, Configuration configuration) {
        if (z6 && (this.f11623u instanceof InterfaceC3211c)) {
            a0(new IllegalStateException("Do not call dispatchConfigurationChanged() on host. Host implements OnConfigurationChangedProvider and automatically dispatches configuration changes to fragments."));
            throw null;
        }
        for (G g6 : this.f11606c.f()) {
            if (g6 != null) {
                g6.performConfigurationChanged(configuration);
                if (z6) {
                    g6.mChildFragmentManager.h(true, configuration);
                }
            }
        }
    }

    public final boolean i(MenuItem menuItem) {
        if (this.f11622t < 1) {
            return false;
        }
        for (G g6 : this.f11606c.f()) {
            if (g6 != null && g6.performContextItemSelected(menuItem)) {
                return true;
            }
        }
        return false;
    }

    public final boolean j(Menu menu, MenuInflater menuInflater) {
        if (this.f11622t < 1) {
            return false;
        }
        ArrayList arrayList = null;
        boolean z6 = false;
        for (G g6 : this.f11606c.f()) {
            if (g6 != null && g6.isMenuVisible() && g6.performCreateOptionsMenu(menu, menuInflater)) {
                if (arrayList == null) {
                    arrayList = new ArrayList();
                }
                arrayList.add(g6);
                z6 = true;
            }
        }
        if (this.f11608e != null) {
            for (int i6 = 0; i6 < this.f11608e.size(); i6++) {
                G g7 = (G) this.f11608e.get(i6);
                if (arrayList == null || !arrayList.contains(g7)) {
                    g7.onDestroyOptionsMenu();
                }
            }
        }
        this.f11608e = arrayList;
        return z6;
    }

    public final void k() {
        boolean zIsChangingConfigurations = true;
        this.f11597H = true;
        x(true);
        Iterator it = e().iterator();
        while (it.hasNext()) {
            ((C1058o) it.next()).g();
        }
        S s6 = this.f11623u;
        boolean z6 = s6 instanceof androidx.lifecycle.j0;
        p0 p0Var = this.f11606c;
        if (z6) {
            zIsChangingConfigurations = p0Var.f11692d.isCleared();
        } else {
            L l = s6.f11540b;
            if (l != null) {
                zIsChangingConfigurations = true ^ l.isChangingConfigurations();
            }
        }
        if (zIsChangingConfigurations) {
            Iterator it2 = this.f11613j.values().iterator();
            while (it2.hasNext()) {
                Iterator it3 = ((C1043d) it2.next()).f11574a.iterator();
                while (it3.hasNext()) {
                    p0Var.f11692d.clearNonConfigState((String) it3.next());
                }
            }
        }
        t(-1);
        Object obj = this.f11623u;
        if (obj instanceof InterfaceC3212d) {
            ((InterfaceC3212d) obj).removeOnTrimMemoryListener(this.f11618p);
        }
        Object obj2 = this.f11623u;
        if (obj2 instanceof InterfaceC3211c) {
            ((InterfaceC3211c) obj2).removeOnConfigurationChangedListener(this.f11617o);
        }
        Object obj3 = this.f11623u;
        if (obj3 instanceof androidx.core.app.M) {
            ((androidx.core.app.M) obj3).removeOnMultiWindowModeChangedListener(this.f11619q);
        }
        Object obj4 = this.f11623u;
        if (obj4 instanceof androidx.core.app.N) {
            ((androidx.core.app.N) obj4).removeOnPictureInPictureModeChangedListener(this.f11620r);
        }
        Object obj5 = this.f11623u;
        if ((obj5 instanceof InterfaceC0178g) && this.f11625w == null) {
            ((InterfaceC0178g) obj5).removeMenuProvider(this.f11621s);
        }
        this.f11623u = null;
        this.f11624v = null;
        this.f11625w = null;
        if (this.f11610g != null) {
            this.f11611h.e();
            this.f11610g = null;
        }
        C2054h c2054h = this.f11590A;
        if (c2054h != null) {
            c2054h.b();
            this.f11591B.b();
            this.f11592C.b();
        }
    }

    public final void l(boolean z6) {
        if (z6 && (this.f11623u instanceof InterfaceC3212d)) {
            a0(new IllegalStateException("Do not call dispatchLowMemory() on host. Host implements OnTrimMemoryProvider and automatically dispatches low memory callbacks to fragments."));
            throw null;
        }
        for (G g6 : this.f11606c.f()) {
            if (g6 != null) {
                g6.performLowMemory();
                if (z6) {
                    g6.mChildFragmentManager.l(true);
                }
            }
        }
    }

    public final void m(boolean z6, boolean z7) {
        if (z7 && (this.f11623u instanceof androidx.core.app.M)) {
            a0(new IllegalStateException("Do not call dispatchMultiWindowModeChanged() on host. Host implements OnMultiWindowModeChangedProvider and automatically dispatches multi-window mode changes to fragments."));
            throw null;
        }
        for (G g6 : this.f11606c.f()) {
            if (g6 != null) {
                g6.performMultiWindowModeChanged(z6);
                if (z7) {
                    g6.mChildFragmentManager.m(z6, true);
                }
            }
        }
    }

    public final void n() {
        for (G g6 : this.f11606c.e()) {
            if (g6 != null) {
                g6.onHiddenChanged(g6.isHidden());
                g6.mChildFragmentManager.n();
            }
        }
    }

    public final boolean o(MenuItem menuItem) {
        if (this.f11622t < 1) {
            return false;
        }
        for (G g6 : this.f11606c.f()) {
            if (g6 != null && g6.performOptionsItemSelected(menuItem)) {
                return true;
            }
        }
        return false;
    }

    public final void p(Menu menu) {
        if (this.f11622t < 1) {
            return;
        }
        for (G g6 : this.f11606c.f()) {
            if (g6 != null) {
                g6.performOptionsMenuClosed(menu);
            }
        }
    }

    public final void q(G g6) {
        if (g6 != null) {
            if (g6.equals(this.f11606c.b(g6.mWho))) {
                g6.performPrimaryNavigationFragmentChanged();
            }
        }
    }

    public final void r(boolean z6, boolean z7) {
        if (z7 && (this.f11623u instanceof androidx.core.app.N)) {
            a0(new IllegalStateException("Do not call dispatchPictureInPictureModeChanged() on host. Host implements OnPictureInPictureModeChangedProvider and automatically dispatches picture-in-picture mode changes to fragments."));
            throw null;
        }
        for (G g6 : this.f11606c.f()) {
            if (g6 != null) {
                g6.performPictureInPictureModeChanged(z6);
                if (z7) {
                    g6.mChildFragmentManager.r(z6, true);
                }
            }
        }
    }

    public final boolean s(Menu menu) {
        boolean z6 = false;
        if (this.f11622t < 1) {
            return false;
        }
        for (G g6 : this.f11606c.f()) {
            if (g6 != null && g6.isMenuVisible() && g6.performPrepareOptionsMenu(menu)) {
                z6 = true;
            }
        }
        return z6;
    }

    public final void t(int i6) {
        try {
            this.f11605b = true;
            for (o0 o0Var : this.f11606c.f11690b.values()) {
                if (o0Var != null) {
                    o0Var.f11686e = i6;
                }
            }
            L(i6, false);
            Iterator it = e().iterator();
            while (it.hasNext()) {
                ((C1058o) it.next()).g();
            }
            this.f11605b = false;
            x(true);
        } catch (Throwable th) {
            this.f11605b = false;
            throw th;
        }
    }

    public final String toString() {
        StringBuilder sb = new StringBuilder(128);
        sb.append("FragmentManager{");
        sb.append(Integer.toHexString(System.identityHashCode(this)));
        sb.append(" in ");
        G g6 = this.f11625w;
        if (g6 != null) {
            sb.append(g6.getClass().getSimpleName());
            sb.append("{");
            sb.append(Integer.toHexString(System.identityHashCode(this.f11625w)));
            sb.append("}");
        } else {
            S s6 = this.f11623u;
            if (s6 != null) {
                sb.append(s6.getClass().getSimpleName());
                sb.append("{");
                sb.append(Integer.toHexString(System.identityHashCode(this.f11623u)));
                sb.append("}");
            } else {
                sb.append("null");
            }
        }
        sb.append("}}");
        return sb.toString();
    }

    public final void u(String str, FileDescriptor fileDescriptor, PrintWriter printWriter, String[] strArr) {
        int size;
        int size2;
        String strN = Z0.o.n(str, "    ");
        p0 p0Var = this.f11606c;
        p0Var.getClass();
        String str2 = str + "    ";
        HashMap map = p0Var.f11690b;
        if (!map.isEmpty()) {
            printWriter.print(str);
            printWriter.println("Active Fragments:");
            for (o0 o0Var : map.values()) {
                printWriter.print(str);
                if (o0Var != null) {
                    G g6 = o0Var.f11684c;
                    printWriter.println(g6);
                    g6.dump(str2, fileDescriptor, printWriter, strArr);
                } else {
                    printWriter.println("null");
                }
            }
        }
        ArrayList arrayList = p0Var.f11689a;
        int size3 = arrayList.size();
        if (size3 > 0) {
            printWriter.print(str);
            printWriter.println("Added Fragments:");
            for (int i6 = 0; i6 < size3; i6++) {
                G g7 = (G) arrayList.get(i6);
                printWriter.print(str);
                printWriter.print("  #");
                printWriter.print(i6);
                printWriter.print(": ");
                printWriter.println(g7.toString());
            }
        }
        ArrayList arrayList2 = this.f11608e;
        if (arrayList2 != null && (size2 = arrayList2.size()) > 0) {
            printWriter.print(str);
            printWriter.println("Fragments Created Menus:");
            for (int i7 = 0; i7 < size2; i7++) {
                G g8 = (G) this.f11608e.get(i7);
                printWriter.print(str);
                printWriter.print("  #");
                printWriter.print(i7);
                printWriter.print(": ");
                printWriter.println(g8.toString());
            }
        }
        ArrayList arrayList3 = this.f11607d;
        if (arrayList3 != null && (size = arrayList3.size()) > 0) {
            printWriter.print(str);
            printWriter.println("Back Stack:");
            for (int i8 = 0; i8 < size; i8++) {
                C1037a c1037a = (C1037a) this.f11607d.get(i8);
                printWriter.print(str);
                printWriter.print("  #");
                printWriter.print(i8);
                printWriter.print(": ");
                printWriter.println(c1037a.toString());
                c1037a.f(strN, printWriter, true);
            }
        }
        printWriter.print(str);
        printWriter.println("Back Stack Index: " + this.f11612i.get());
        synchronized (this.f11604a) {
            try {
                int size4 = this.f11604a.size();
                if (size4 > 0) {
                    printWriter.print(str);
                    printWriter.println("Pending Actions:");
                    for (int i9 = 0; i9 < size4; i9++) {
                        Object obj = (InterfaceC1046e0) this.f11604a.get(i9);
                        printWriter.print(str);
                        printWriter.print("  #");
                        printWriter.print(i9);
                        printWriter.print(": ");
                        printWriter.println(obj);
                    }
                }
            } catch (Throwable th) {
                throw th;
            }
        }
        printWriter.print(str);
        printWriter.println("FragmentManager misc state:");
        printWriter.print(str);
        printWriter.print("  mHost=");
        printWriter.println(this.f11623u);
        printWriter.print(str);
        printWriter.print("  mContainer=");
        printWriter.println(this.f11624v);
        if (this.f11625w != null) {
            printWriter.print(str);
            printWriter.print("  mParent=");
            printWriter.println(this.f11625w);
        }
        printWriter.print(str);
        printWriter.print("  mCurState=");
        printWriter.print(this.f11622t);
        printWriter.print(" mStateSaved=");
        printWriter.print(this.f11595F);
        printWriter.print(" mStopped=");
        printWriter.print(this.f11596G);
        printWriter.print(" mDestroyed=");
        printWriter.println(this.f11597H);
        if (this.f11594E) {
            printWriter.print(str);
            printWriter.print("  mNeedMenuInvalidate=");
            printWriter.println(this.f11594E);
        }
    }

    public final void v(InterfaceC1046e0 interfaceC1046e0, boolean z6) {
        if (!z6) {
            if (this.f11623u == null) {
                if (!this.f11597H) {
                    throw new IllegalStateException("FragmentManager has not been attached to a host.");
                }
                throw new IllegalStateException("FragmentManager has been destroyed");
            }
            if (this.f11595F || this.f11596G) {
                throw new IllegalStateException("Can not perform this action after onSaveInstanceState");
            }
        }
        synchronized (this.f11604a) {
            try {
                if (this.f11623u == null) {
                    if (!z6) {
                        throw new IllegalStateException("Activity has been destroyed");
                    }
                } else {
                    this.f11604a.add(interfaceC1046e0);
                    U();
                }
            } catch (Throwable th) {
                throw th;
            }
        }
    }

    public final void w(boolean z6) {
        if (this.f11605b) {
            throw new IllegalStateException("FragmentManager is already executing transactions");
        }
        if (this.f11623u == null) {
            if (!this.f11597H) {
                throw new IllegalStateException("FragmentManager has not been attached to a host.");
            }
            throw new IllegalStateException("FragmentManager has been destroyed");
        }
        if (Looper.myLooper() != this.f11623u.f11541c.getLooper()) {
            throw new IllegalStateException("Must be called from main thread of fragment host");
        }
        if (!z6 && (this.f11595F || this.f11596G)) {
            throw new IllegalStateException("Can not perform this action after onSaveInstanceState");
        }
        if (this.f11599J == null) {
            this.f11599J = new ArrayList();
            this.f11600K = new ArrayList();
        }
    }

    public final boolean x(boolean z6) {
        boolean zA;
        w(z6);
        boolean z7 = false;
        while (true) {
            ArrayList arrayList = this.f11599J;
            ArrayList arrayList2 = this.f11600K;
            synchronized (this.f11604a) {
                if (this.f11604a.isEmpty()) {
                    zA = false;
                } else {
                    try {
                        int size = this.f11604a.size();
                        zA = false;
                        for (int i6 = 0; i6 < size; i6++) {
                            zA |= ((InterfaceC1046e0) this.f11604a.get(i6)).a(arrayList, arrayList2);
                        }
                    } finally {
                    }
                }
            }
            if (!zA) {
                break;
            }
            this.f11605b = true;
            try {
                R(this.f11599J, this.f11600K);
                d();
                z7 = true;
            } catch (Throwable th) {
                d();
                throw th;
            }
        }
        b0();
        if (this.f11598I) {
            this.f11598I = false;
            for (o0 o0Var : this.f11606c.d()) {
                G g6 = o0Var.f11684c;
                if (g6.mDeferStart) {
                    if (this.f11605b) {
                        this.f11598I = true;
                    } else {
                        g6.mDeferStart = false;
                        o0Var.k();
                    }
                }
            }
        }
        this.f11606c.f11690b.values().removeAll(Collections.singleton(null));
        return z7;
    }

    public final void y(C1037a c1037a, boolean z6) {
        if (z6 && (this.f11623u == null || this.f11597H)) {
            return;
        }
        w(z6);
        c1037a.a(this.f11599J, this.f11600K);
        this.f11605b = true;
        try {
            R(this.f11599J, this.f11600K);
            d();
            b0();
            boolean z7 = this.f11598I;
            p0 p0Var = this.f11606c;
            if (z7) {
                this.f11598I = false;
                for (o0 o0Var : p0Var.d()) {
                    G g6 = o0Var.f11684c;
                    if (g6.mDeferStart) {
                        if (this.f11605b) {
                            this.f11598I = true;
                        } else {
                            g6.mDeferStart = false;
                            o0Var.k();
                        }
                    }
                }
            }
            p0Var.f11690b.values().removeAll(Collections.singleton(null));
        } catch (Throwable th) {
            d();
            throw th;
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:109:0x0225 A[PHI: r13
      0x0225: PHI (r13v9 int) = (r13v8 int), (r13v10 int) binds: [B:102:0x0215, B:107:0x0221] A[DONT_GENERATE, DONT_INLINE]] */
    /* JADX WARN: Removed duplicated region for block: B:65:0x0178  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void z(ArrayList arrayList, ArrayList arrayList2, int i6, int i7) {
        ViewGroup viewGroup;
        boolean z6;
        int i8;
        boolean z7;
        boolean z8;
        int i9;
        int i10;
        boolean z9;
        boolean z10;
        int i11;
        boolean z11 = ((C1037a) arrayList.get(i6)).f11717o;
        ArrayList arrayList3 = this.f11601L;
        if (arrayList3 == null) {
            this.f11601L = new ArrayList();
        } else {
            arrayList3.clear();
        }
        ArrayList arrayList4 = this.f11601L;
        p0 p0Var = this.f11606c;
        arrayList4.addAll(p0Var.f());
        G g6 = this.f11626x;
        int i12 = i6;
        boolean z12 = false;
        while (true) {
            int i13 = 1;
            if (i12 >= i7) {
                boolean z13 = z11;
                this.f11601L.clear();
                if (!z13 && this.f11622t >= 1) {
                    for (int i14 = i6; i14 < i7; i14++) {
                        Iterator it = ((C1037a) arrayList.get(i14)).f11704a.iterator();
                        while (it.hasNext()) {
                            G g7 = ((q0) it.next()).f11695b;
                            if (g7 != null && g7.mFragmentManager != null) {
                                p0Var.g(f(g7));
                            }
                        }
                    }
                }
                for (int i15 = i6; i15 < i7; i15++) {
                    C1037a c1037a = (C1037a) arrayList.get(i15);
                    if (((Boolean) arrayList2.get(i15)).booleanValue()) {
                        c1037a.d(-1);
                        ArrayList arrayList5 = c1037a.f11704a;
                        boolean z14 = true;
                        for (int size = arrayList5.size() - 1; size >= 0; size--) {
                            q0 q0Var = (q0) arrayList5.get(size);
                            G g8 = q0Var.f11695b;
                            if (g8 != null) {
                                g8.mBeingSaved = false;
                                g8.setPopDirection(z14);
                                int i16 = c1037a.f11709f;
                                int i17 = 8194;
                                int i18 = 4097;
                                if (i16 != 4097) {
                                    if (i16 != 8194) {
                                        i17 = 4100;
                                        i18 = 8197;
                                        if (i16 != 8197) {
                                            i17 = i16 != 4099 ? i16 != 4100 ? 0 : i18 : 4099;
                                        }
                                    }
                                }
                                g8.setNextTransition(i17);
                                g8.setSharedElementNames(c1037a.f11716n, c1037a.f11715m);
                            }
                            int i19 = q0Var.f11694a;
                            AbstractC1050g0 abstractC1050g0 = c1037a.f11555p;
                            switch (i19) {
                                case 1:
                                    g8.setAnimations(q0Var.f11697d, q0Var.f11698e, q0Var.f11699f, q0Var.f11700g);
                                    z14 = true;
                                    abstractC1050g0.V(g8, true);
                                    abstractC1050g0.Q(g8);
                                    break;
                                case 2:
                                default:
                                    throw new IllegalArgumentException("Unknown cmd: " + q0Var.f11694a);
                                case 3:
                                    g8.setAnimations(q0Var.f11697d, q0Var.f11698e, q0Var.f11699f, q0Var.f11700g);
                                    abstractC1050g0.a(g8);
                                    z14 = true;
                                    break;
                                case 4:
                                    g8.setAnimations(q0Var.f11697d, q0Var.f11698e, q0Var.f11699f, q0Var.f11700g);
                                    abstractC1050g0.getClass();
                                    Z(g8);
                                    z14 = true;
                                    break;
                                case 5:
                                    g8.setAnimations(q0Var.f11697d, q0Var.f11698e, q0Var.f11699f, q0Var.f11700g);
                                    abstractC1050g0.V(g8, true);
                                    abstractC1050g0.G(g8);
                                    z14 = true;
                                    break;
                                case 6:
                                    g8.setAnimations(q0Var.f11697d, q0Var.f11698e, q0Var.f11699f, q0Var.f11700g);
                                    abstractC1050g0.c(g8);
                                    z14 = true;
                                    break;
                                case 7:
                                    g8.setAnimations(q0Var.f11697d, q0Var.f11698e, q0Var.f11699f, q0Var.f11700g);
                                    abstractC1050g0.V(g8, true);
                                    abstractC1050g0.g(g8);
                                    z14 = true;
                                    break;
                                case 8:
                                    abstractC1050g0.X(null);
                                    z14 = true;
                                    break;
                                case 9:
                                    abstractC1050g0.X(g8);
                                    z14 = true;
                                    break;
                                case 10:
                                    abstractC1050g0.W(g8, q0Var.f11701h);
                                    z14 = true;
                                    break;
                            }
                        }
                    } else {
                        c1037a.d(1);
                        ArrayList arrayList6 = c1037a.f11704a;
                        int size2 = arrayList6.size();
                        for (int i20 = 0; i20 < size2; i20++) {
                            q0 q0Var2 = (q0) arrayList6.get(i20);
                            G g9 = q0Var2.f11695b;
                            if (g9 != null) {
                                g9.mBeingSaved = false;
                                g9.setPopDirection(false);
                                g9.setNextTransition(c1037a.f11709f);
                                g9.setSharedElementNames(c1037a.f11715m, c1037a.f11716n);
                            }
                            int i21 = q0Var2.f11694a;
                            AbstractC1050g0 abstractC1050g02 = c1037a.f11555p;
                            switch (i21) {
                                case 1:
                                    g9.setAnimations(q0Var2.f11697d, q0Var2.f11698e, q0Var2.f11699f, q0Var2.f11700g);
                                    abstractC1050g02.V(g9, false);
                                    abstractC1050g02.a(g9);
                                    break;
                                case 2:
                                default:
                                    throw new IllegalArgumentException("Unknown cmd: " + q0Var2.f11694a);
                                case 3:
                                    g9.setAnimations(q0Var2.f11697d, q0Var2.f11698e, q0Var2.f11699f, q0Var2.f11700g);
                                    abstractC1050g02.Q(g9);
                                    break;
                                case 4:
                                    g9.setAnimations(q0Var2.f11697d, q0Var2.f11698e, q0Var2.f11699f, q0Var2.f11700g);
                                    abstractC1050g02.G(g9);
                                    break;
                                case 5:
                                    g9.setAnimations(q0Var2.f11697d, q0Var2.f11698e, q0Var2.f11699f, q0Var2.f11700g);
                                    abstractC1050g02.V(g9, false);
                                    Z(g9);
                                    break;
                                case 6:
                                    g9.setAnimations(q0Var2.f11697d, q0Var2.f11698e, q0Var2.f11699f, q0Var2.f11700g);
                                    abstractC1050g02.g(g9);
                                    break;
                                case 7:
                                    g9.setAnimations(q0Var2.f11697d, q0Var2.f11698e, q0Var2.f11699f, q0Var2.f11700g);
                                    abstractC1050g02.V(g9, false);
                                    abstractC1050g02.c(g9);
                                    break;
                                case 8:
                                    abstractC1050g02.X(g9);
                                    break;
                                case 9:
                                    abstractC1050g02.X(null);
                                    break;
                                case 10:
                                    abstractC1050g02.W(g9, q0Var2.f11702i);
                                    break;
                            }
                        }
                    }
                }
                boolean zBooleanValue = ((Boolean) arrayList2.get(i7 - 1)).booleanValue();
                for (int i22 = i6; i22 < i7; i22++) {
                    C1037a c1037a2 = (C1037a) arrayList.get(i22);
                    if (zBooleanValue) {
                        for (int size3 = c1037a2.f11704a.size() - 1; size3 >= 0; size3--) {
                            G g10 = ((q0) c1037a2.f11704a.get(size3)).f11695b;
                            if (g10 != null) {
                                f(g10).k();
                            }
                        }
                    } else {
                        Iterator it2 = c1037a2.f11704a.iterator();
                        while (it2.hasNext()) {
                            G g11 = ((q0) it2.next()).f11695b;
                            if (g11 != null) {
                                f(g11).k();
                            }
                        }
                    }
                }
                L(this.f11622t, true);
                HashSet<C1058o> hashSet = new HashSet();
                for (int i23 = i6; i23 < i7; i23++) {
                    Iterator it3 = ((C1037a) arrayList.get(i23)).f11704a.iterator();
                    while (it3.hasNext()) {
                        G g12 = ((q0) it3.next()).f11695b;
                        if (g12 != null && (viewGroup = g12.mContainer) != null) {
                            hashSet.add(C1058o.h(viewGroup, this));
                        }
                    }
                }
                for (C1058o c1058o : hashSet) {
                    c1058o.f11680d = zBooleanValue;
                    c1058o.i();
                    c1058o.d();
                }
                for (int i24 = i6; i24 < i7; i24++) {
                    C1037a c1037a3 = (C1037a) arrayList.get(i24);
                    if (((Boolean) arrayList2.get(i24)).booleanValue() && c1037a3.f11557r >= 0) {
                        c1037a3.f11557r = -1;
                    }
                    c1037a3.getClass();
                }
                return;
            }
            C1037a c1037a4 = (C1037a) arrayList.get(i12);
            if (((Boolean) arrayList2.get(i12)).booleanValue()) {
                z6 = z11;
                i8 = i12;
                z7 = z12;
                int i25 = 1;
                ArrayList arrayList7 = this.f11601L;
                ArrayList arrayList8 = c1037a4.f11704a;
                int size4 = arrayList8.size() - 1;
                while (size4 >= 0) {
                    q0 q0Var3 = (q0) arrayList8.get(size4);
                    int i26 = q0Var3.f11694a;
                    if (i26 != i25) {
                        if (i26 != 3) {
                            switch (i26) {
                                case 6:
                                    arrayList7.add(q0Var3.f11695b);
                                    break;
                                case 8:
                                    g6 = null;
                                    break;
                                case 9:
                                    g6 = q0Var3.f11695b;
                                    break;
                                case 10:
                                    q0Var3.f11702i = q0Var3.f11701h;
                                    break;
                            }
                        }
                        size4--;
                        i25 = 1;
                    }
                    arrayList7.remove(q0Var3.f11695b);
                    size4--;
                    i25 = 1;
                }
            } else {
                ArrayList arrayList9 = this.f11601L;
                int i27 = 0;
                while (true) {
                    ArrayList arrayList10 = c1037a4.f11704a;
                    if (i27 < arrayList10.size()) {
                        q0 q0Var4 = (q0) arrayList10.get(i27);
                        int i28 = q0Var4.f11694a;
                        if (i28 != i13) {
                            z8 = z11;
                            if (i28 != 2) {
                                if (i28 == 3 || i28 == 6) {
                                    arrayList9.remove(q0Var4.f11695b);
                                    G g13 = q0Var4.f11695b;
                                    if (g13 == g6) {
                                        arrayList10.add(i27, new q0(g13, 9));
                                        i27++;
                                        i10 = i12;
                                        z9 = z12;
                                        i9 = 1;
                                        g6 = null;
                                    }
                                } else if (i28 == 7) {
                                    i9 = 1;
                                } else if (i28 == 8) {
                                    arrayList10.add(i27, new q0(g6, 9, 0));
                                    q0Var4.f11696c = true;
                                    i27++;
                                    g6 = q0Var4.f11695b;
                                }
                                i10 = i12;
                                z9 = z12;
                                i9 = 1;
                            } else {
                                G g14 = q0Var4.f11695b;
                                int i29 = g14.mContainerId;
                                int size5 = arrayList9.size() - 1;
                                boolean z15 = false;
                                while (size5 >= 0) {
                                    int i30 = size5;
                                    G g15 = (G) arrayList9.get(size5);
                                    int i31 = i12;
                                    if (g15.mContainerId != i29) {
                                        z10 = z12;
                                    } else if (g15 == g14) {
                                        z10 = z12;
                                        z15 = true;
                                    } else {
                                        if (g15 == g6) {
                                            z10 = z12;
                                            i11 = 0;
                                            arrayList10.add(i27, new q0(g15, 9, 0));
                                            i27++;
                                            g6 = null;
                                        } else {
                                            z10 = z12;
                                            i11 = 0;
                                        }
                                        q0 q0Var5 = new q0(g15, 3, i11);
                                        q0Var5.f11697d = q0Var4.f11697d;
                                        q0Var5.f11699f = q0Var4.f11699f;
                                        q0Var5.f11698e = q0Var4.f11698e;
                                        q0Var5.f11700g = q0Var4.f11700g;
                                        arrayList10.add(i27, q0Var5);
                                        arrayList9.remove(g15);
                                        i27++;
                                        g6 = g6;
                                    }
                                    size5 = i30 - 1;
                                    z12 = z10;
                                    i12 = i31;
                                }
                                i10 = i12;
                                z9 = z12;
                                i9 = 1;
                                if (z15) {
                                    arrayList10.remove(i27);
                                    i27--;
                                } else {
                                    q0Var4.f11694a = 1;
                                    q0Var4.f11696c = true;
                                    arrayList9.add(g14);
                                }
                            }
                            i27 += i9;
                            i13 = i9;
                            z11 = z8;
                            z12 = z9;
                            i12 = i10;
                        } else {
                            z8 = z11;
                            i9 = i13;
                        }
                        i10 = i12;
                        z9 = z12;
                        arrayList9.add(q0Var4.f11695b);
                        i27 += i9;
                        i13 = i9;
                        z11 = z8;
                        z12 = z9;
                        i12 = i10;
                    } else {
                        z6 = z11;
                        i8 = i12;
                        z7 = z12;
                    }
                }
            }
            z12 = z7 || c1037a4.f11710g;
            i12 = i8 + 1;
            z11 = z6;
        }
    }
}
