package androidx.fragment.app;

import android.content.res.Configuration;
import android.content.res.TypedArray;
import android.media.MediaDrm;
import android.media.MediaMetadataRetriever;
import android.os.Bundle;
import android.os.Looper;
import android.os.Parcelable;
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 com.google.android.gms.common.R;
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.Objects;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import o.AT;
import o.AbstractC1843mC;
import o.AbstractC2462sn;
import o.C0054Cc;
import o.C0698aC;
import o.C0794bC;
import o.C0889cC;
import o.C1368hC;
import o.C1390hY;
import o.C1640k40;
import o.C1938nC;
import o.C2867x1;
import o.C3024yj;
import o.D1;
import o.E1;
import o.ET;
import o.FO;
import o.FT;
import o.I1;
import o.IT;
import o.InterfaceC0898cL;
import o.InterfaceC1080eC;
import o.InterfaceC1416hm;
import o.InterfaceC1508ik0;
import o.InterfaceC1558jC;
import o.InterfaceC1925n40;
import o.J7;
import o.KM;
import o.OD;
import o.OT;
import o.PT;
import o.RunnableC2017o3;
import o.TT;
import o.UB;
import o.VK;
import o.WB;
import o.XB;
import o.YB;
import o.ZB;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* loaded from: classes.dex */
public abstract class s {
    public D1 A;
    public D1 B;
    public ArrayDeque C;
    public boolean D;
    public boolean E;
    public boolean F;
    public boolean G;
    public boolean H;
    public ArrayList I;
    public ArrayList J;
    public ArrayList K;
    public t L;
    public final RunnableC2017o3 M;
    public boolean b;
    public ArrayList d;
    public ArrayList e;
    public ET g;
    public final C1390hY l;
    public final CopyOnWriteArrayList m;
    public final XB n;

    /* renamed from: o, reason: collision with root package name */
    public final XB f17o;
    public final XB p;
    public final XB q;
    public final C0698aC r;
    public int s;
    public WB t;
    public UB u;
    public l v;
    public l w;
    public final C0794bC x;
    public final J7 y;
    public D1 z;
    public final ArrayList a = new ArrayList();
    public final w c = new w();
    public final r f = new r(this);
    public final ZB h = new ZB(this);
    public final AtomicInteger i = new AtomicInteger();
    public final Map j = Collections.synchronizedMap(new HashMap());
    public final Map k = Collections.synchronizedMap(new HashMap());

    /* JADX WARN: Type inference failed for: r0v12, types: [o.XB] */
    /* JADX WARN: Type inference failed for: r0v13, types: [o.XB] */
    /* JADX WARN: Type inference failed for: r0v14, types: [o.XB] */
    /* JADX WARN: Type inference failed for: r0v15, types: [o.XB] */
    public s() {
        Collections.synchronizedMap(new HashMap());
        this.l = new C1390hY(this);
        this.m = new CopyOnWriteArrayList();
        final int i = 0;
        this.n = new InterfaceC1416hm(this) { // from class: o.XB
            public final /* synthetic */ androidx.fragment.app.s b;

            {
                this.b = this;
            }

            @Override // o.InterfaceC1416hm
            public final void accept(Object obj) {
                switch (i) {
                    case 0:
                        Configuration configuration = (Configuration) obj;
                        androidx.fragment.app.s sVar = this.b;
                        if (sVar.H()) {
                            sVar.h(false, configuration);
                            break;
                        }
                        break;
                    case 1:
                        Integer num = (Integer) obj;
                        androidx.fragment.app.s sVar2 = this.b;
                        if (sVar2.H() && num.intValue() == 80) {
                            sVar2.l(false);
                            break;
                        }
                        break;
                    case 2:
                        BQ bq = (BQ) obj;
                        androidx.fragment.app.s sVar3 = this.b;
                        if (sVar3.H()) {
                            sVar3.m(bq.a, false);
                            break;
                        }
                        break;
                    default:
                        SW sw = (SW) obj;
                        androidx.fragment.app.s sVar4 = this.b;
                        if (sVar4.H()) {
                            sVar4.r(sw.a, false);
                            break;
                        }
                        break;
                }
            }
        };
        final int i2 = 1;
        this.f17o = new InterfaceC1416hm(this) { // from class: o.XB
            public final /* synthetic */ androidx.fragment.app.s b;

            {
                this.b = this;
            }

            @Override // o.InterfaceC1416hm
            public final void accept(Object obj) {
                switch (i2) {
                    case 0:
                        Configuration configuration = (Configuration) obj;
                        androidx.fragment.app.s sVar = this.b;
                        if (sVar.H()) {
                            sVar.h(false, configuration);
                            break;
                        }
                        break;
                    case 1:
                        Integer num = (Integer) obj;
                        androidx.fragment.app.s sVar2 = this.b;
                        if (sVar2.H() && num.intValue() == 80) {
                            sVar2.l(false);
                            break;
                        }
                        break;
                    case 2:
                        BQ bq = (BQ) obj;
                        androidx.fragment.app.s sVar3 = this.b;
                        if (sVar3.H()) {
                            sVar3.m(bq.a, false);
                            break;
                        }
                        break;
                    default:
                        SW sw = (SW) obj;
                        androidx.fragment.app.s sVar4 = this.b;
                        if (sVar4.H()) {
                            sVar4.r(sw.a, false);
                            break;
                        }
                        break;
                }
            }
        };
        final int i3 = 2;
        this.p = new InterfaceC1416hm(this) { // from class: o.XB
            public final /* synthetic */ androidx.fragment.app.s b;

            {
                this.b = this;
            }

            @Override // o.InterfaceC1416hm
            public final void accept(Object obj) {
                switch (i3) {
                    case 0:
                        Configuration configuration = (Configuration) obj;
                        androidx.fragment.app.s sVar = this.b;
                        if (sVar.H()) {
                            sVar.h(false, configuration);
                            break;
                        }
                        break;
                    case 1:
                        Integer num = (Integer) obj;
                        androidx.fragment.app.s sVar2 = this.b;
                        if (sVar2.H() && num.intValue() == 80) {
                            sVar2.l(false);
                            break;
                        }
                        break;
                    case 2:
                        BQ bq = (BQ) obj;
                        androidx.fragment.app.s sVar3 = this.b;
                        if (sVar3.H()) {
                            sVar3.m(bq.a, false);
                            break;
                        }
                        break;
                    default:
                        SW sw = (SW) obj;
                        androidx.fragment.app.s sVar4 = this.b;
                        if (sVar4.H()) {
                            sVar4.r(sw.a, false);
                            break;
                        }
                        break;
                }
            }
        };
        final int i4 = 3;
        this.q = new InterfaceC1416hm(this) { // from class: o.XB
            public final /* synthetic */ androidx.fragment.app.s b;

            {
                this.b = this;
            }

            @Override // o.InterfaceC1416hm
            public final void accept(Object obj) {
                switch (i4) {
                    case 0:
                        Configuration configuration = (Configuration) obj;
                        androidx.fragment.app.s sVar = this.b;
                        if (sVar.H()) {
                            sVar.h(false, configuration);
                            break;
                        }
                        break;
                    case 1:
                        Integer num = (Integer) obj;
                        androidx.fragment.app.s sVar2 = this.b;
                        if (sVar2.H() && num.intValue() == 80) {
                            sVar2.l(false);
                            break;
                        }
                        break;
                    case 2:
                        BQ bq = (BQ) obj;
                        androidx.fragment.app.s sVar3 = this.b;
                        if (sVar3.H()) {
                            sVar3.m(bq.a, false);
                            break;
                        }
                        break;
                    default:
                        SW sw = (SW) obj;
                        androidx.fragment.app.s sVar4 = this.b;
                        if (sVar4.H()) {
                            sVar4.r(sw.a, false);
                            break;
                        }
                        break;
                }
            }
        };
        this.r = new C0698aC(this);
        this.s = -1;
        this.x = new C0794bC(this);
        this.y = new J7(23);
        this.C = new ArrayDeque();
        this.M = new RunnableC2017o3(10, this);
    }

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

    public static boolean G(l lVar) {
        if (lVar.mHasMenu && lVar.mMenuVisible) {
            return true;
        }
        ArrayList arrayListE = lVar.mChildFragmentManager.c.e();
        int size = arrayListE.size();
        boolean zG = false;
        int i = 0;
        while (i < size) {
            Object obj = arrayListE.get(i);
            i++;
            l lVar2 = (l) obj;
            if (lVar2 != null) {
                zG = G(lVar2);
            }
            if (zG) {
                return true;
            }
        }
        return false;
    }

    public static boolean I(l lVar) {
        if (lVar == null) {
            return true;
        }
        s sVar = lVar.mFragmentManager;
        return lVar.equals(sVar.w) && I(sVar.v);
    }

    public final l A(int i) {
        w wVar = this.c;
        ArrayList arrayList = wVar.a;
        for (int size = arrayList.size() - 1; size >= 0; size--) {
            l lVar = (l) arrayList.get(size);
            if (lVar != null && lVar.mFragmentId == i) {
                return lVar;
            }
        }
        for (v vVar : wVar.b.values()) {
            if (vVar != null) {
                l lVar2 = vVar.c;
                if (lVar2.mFragmentId == i) {
                    return lVar2;
                }
            }
        }
        return null;
    }

    public final l B(String str) {
        w wVar = this.c;
        ArrayList arrayList = wVar.a;
        for (int size = arrayList.size() - 1; size >= 0; size--) {
            l lVar = (l) arrayList.get(size);
            if (lVar != null && str.equals(lVar.mTag)) {
                return lVar;
            }
        }
        for (v vVar : wVar.b.values()) {
            if (vVar != null) {
                l lVar2 = vVar.c;
                if (str.equals(lVar2.mTag)) {
                    return lVar2;
                }
            }
        }
        return null;
    }

    public final ViewGroup C(l lVar) {
        ViewGroup viewGroup = lVar.mContainer;
        if (viewGroup != null) {
            return viewGroup;
        }
        if (lVar.mContainerId <= 0 || !this.u.c()) {
            return null;
        }
        View viewB = this.u.b(lVar.mContainerId);
        if (viewB instanceof ViewGroup) {
            return (ViewGroup) viewB;
        }
        return null;
    }

    public final C0794bC D() {
        l lVar = this.v;
        return lVar != null ? lVar.mFragmentManager.D() : this.x;
    }

    public final J7 E() {
        l lVar = this.v;
        return lVar != null ? lVar.mFragmentManager.E() : this.y;
    }

    public final boolean H() {
        l lVar = this.v;
        if (lVar == null) {
            return true;
        }
        return lVar.isAdded() && this.v.getParentFragmentManager().H();
    }

    public final void J(int i, boolean z) {
        WB wb;
        if (this.t == null && i != -1) {
            throw new IllegalStateException("No activity");
        }
        if (z || i != this.s) {
            this.s = i;
            w wVar = this.c;
            HashMap map = wVar.b;
            ArrayList arrayList = wVar.a;
            int size = arrayList.size();
            int i2 = 0;
            while (i2 < size) {
                Object obj = arrayList.get(i2);
                i2++;
                v vVar = (v) map.get(((l) obj).mWho);
                if (vVar != null) {
                    vVar.i();
                }
            }
            for (v vVar2 : map.values()) {
                if (vVar2 != null) {
                    vVar2.i();
                    l lVar = vVar2.c;
                    if (lVar.mRemoving && !lVar.isInBackStack()) {
                        if (lVar.mBeingSaved && !wVar.c.containsKey(lVar.mWho)) {
                            vVar2.l();
                        }
                        wVar.h(vVar2);
                    }
                }
            }
            ArrayList arrayListD = wVar.d();
            int size2 = arrayListD.size();
            int i3 = 0;
            while (i3 < size2) {
                Object obj2 = arrayListD.get(i3);
                i3++;
                v vVar3 = (v) obj2;
                l lVar2 = vVar3.c;
                if (lVar2.mDeferStart) {
                    if (this.b) {
                        this.H = true;
                    } else {
                        lVar2.mDeferStart = false;
                        vVar3.i();
                    }
                }
            }
            if (this.D && (wb = this.t) != null && this.s == 7) {
                ((p) wb).p.invalidateOptionsMenu();
                this.D = false;
            }
        }
    }

    public final void K() {
        if (this.t == null) {
            return;
        }
        this.E = false;
        this.F = false;
        this.L.g = false;
        for (l lVar : this.c.f()) {
            if (lVar != null) {
                lVar.noteStateNotSaved();
            }
        }
    }

    public final boolean L() {
        return M(-1, 0);
    }

    public final boolean M(int i, int i2) {
        x(false);
        w(true);
        l lVar = this.w;
        if (lVar != null && i < 0 && lVar.getChildFragmentManager().L()) {
            return true;
        }
        boolean zN = N(this.I, this.J, i, i2);
        if (zN) {
            this.b = true;
            try {
                P(this.I, this.J);
            } finally {
                d();
            }
        }
        Y();
        boolean z = this.H;
        w wVar = this.c;
        if (z) {
            this.H = false;
            ArrayList arrayListD = wVar.d();
            int size = arrayListD.size();
            int i3 = 0;
            while (i3 < size) {
                Object obj = arrayListD.get(i3);
                i3++;
                v vVar = (v) obj;
                l lVar2 = vVar.c;
                if (lVar2.mDeferStart) {
                    if (this.b) {
                        this.H = true;
                    } else {
                        lVar2.mDeferStart = false;
                        vVar.i();
                    }
                }
            }
        }
        wVar.b.values().removeAll(Collections.singleton(null));
        return zN;
    }

    public final boolean N(ArrayList arrayList, ArrayList arrayList2, int i, int i2) {
        boolean z = (i2 & 1) != 0;
        ArrayList arrayList3 = this.d;
        int size = -1;
        if (arrayList3 != null && !arrayList3.isEmpty()) {
            if (i < 0) {
                size = z ? 0 : this.d.size() - 1;
            } else {
                int size2 = this.d.size() - 1;
                while (size2 >= 0) {
                    a aVar = (a) this.d.get(size2);
                    if (i >= 0 && i == aVar.r) {
                        break;
                    }
                    size2--;
                }
                if (size2 < 0) {
                    size = size2;
                } else if (z) {
                    size = size2;
                    while (size > 0) {
                        a aVar2 = (a) this.d.get(size - 1);
                        if (i < 0 || i != aVar2.r) {
                            break;
                        }
                        size--;
                    }
                } else if (size2 != this.d.size() - 1) {
                    size = size2 + 1;
                }
            }
        }
        if (size < 0) {
            return false;
        }
        for (int size3 = this.d.size() - 1; size3 >= size; size3--) {
            arrayList.add((a) this.d.remove(size3));
            arrayList2.add(Boolean.TRUE);
        }
        return true;
    }

    public final void O(l lVar) {
        if (F(2)) {
            Objects.toString(lVar);
        }
        boolean zIsInBackStack = lVar.isInBackStack();
        if (lVar.mDetached && zIsInBackStack) {
            return;
        }
        w wVar = this.c;
        synchronized (wVar.a) {
            wVar.a.remove(lVar);
        }
        lVar.mAdded = false;
        if (G(lVar)) {
            this.D = true;
        }
        lVar.mRemoving = true;
        W(lVar);
    }

    public final void P(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 i = 0;
        int i2 = 0;
        while (i < size) {
            if (!((a) arrayList.get(i)).f660o) {
                if (i2 != i) {
                    z(arrayList, arrayList2, i2, i);
                }
                i2 = i + 1;
                if (((Boolean) arrayList2.get(i)).booleanValue()) {
                    while (i2 < size && ((Boolean) arrayList2.get(i2)).booleanValue() && !((a) arrayList.get(i2)).f660o) {
                        i2++;
                    }
                }
                z(arrayList, arrayList2, i, i2);
                i = i2 - 1;
            }
            i++;
        }
        if (i2 != size) {
            z(arrayList, arrayList2, i2, size);
        }
    }

    public final void Q(Parcelable parcelable) {
        C1390hY c1390hY;
        int i;
        int i2;
        v vVar;
        Bundle bundle;
        Bundle bundle2;
        Bundle bundle3 = (Bundle) parcelable;
        for (String str : bundle3.keySet()) {
            if (str.startsWith("result_") && (bundle2 = bundle3.getBundle(str)) != null) {
                bundle2.setClassLoader(this.t.m.getClassLoader());
                this.k.put(str.substring(7), bundle2);
            }
        }
        ArrayList arrayList = new ArrayList();
        for (String str2 : bundle3.keySet()) {
            if (str2.startsWith("fragment_") && (bundle = bundle3.getBundle(str2)) != null) {
                bundle.setClassLoader(this.t.m.getClassLoader());
                arrayList.add((u) bundle.getParcelable("state"));
            }
        }
        w wVar = this.c;
        HashMap map = wVar.c;
        HashMap map2 = wVar.b;
        map.clear();
        int size = arrayList.size();
        int i3 = 0;
        while (i3 < size) {
            Object obj = arrayList.get(i3);
            i3++;
            u uVar = (u) obj;
            map.put(uVar.m, uVar);
        }
        C1368hC c1368hC = (C1368hC) bundle3.getParcelable("state");
        if (c1368hC == null) {
            return;
        }
        map2.clear();
        ArrayList arrayList2 = c1368hC.l;
        int size2 = arrayList2.size();
        int i4 = 0;
        while (true) {
            c1390hY = this.l;
            i = 2;
            if (i4 >= size2) {
                break;
            }
            Object obj2 = arrayList2.get(i4);
            i4++;
            u uVar2 = (u) wVar.c.remove((String) obj2);
            if (uVar2 != null) {
                l lVar = (l) this.L.b.get(uVar2.m);
                if (lVar != null) {
                    if (F(2)) {
                        lVar.toString();
                    }
                    vVar = new v(c1390hY, wVar, lVar, uVar2);
                } else {
                    vVar = new v(this.l, this.c, this.t.m.getClassLoader(), D(), uVar2);
                }
                l lVar2 = vVar.c;
                lVar2.mFragmentManager = this;
                if (F(2)) {
                    lVar2.toString();
                }
                vVar.j(this.t.m.getClassLoader());
                wVar.g(vVar);
                vVar.e = this.s;
            }
        }
        t tVar = this.L;
        tVar.getClass();
        ArrayList arrayList3 = new ArrayList(tVar.b.values());
        int size3 = arrayList3.size();
        int i5 = 0;
        while (i5 < size3) {
            Object obj3 = arrayList3.get(i5);
            i5++;
            l lVar3 = (l) obj3;
            if (map2.get(lVar3.mWho) == null) {
                if (F(2)) {
                    lVar3.toString();
                    Objects.toString(c1368hC.l);
                }
                this.L.e(lVar3);
                lVar3.mFragmentManager = this;
                v vVar2 = new v(c1390hY, wVar, lVar3);
                vVar2.e = 1;
                vVar2.i();
                lVar3.mRemoving = true;
                vVar2.i();
            }
        }
        ArrayList arrayList4 = c1368hC.m;
        wVar.a.clear();
        if (arrayList4 != null) {
            int size4 = arrayList4.size();
            int i6 = 0;
            while (i6 < size4) {
                Object obj4 = arrayList4.get(i6);
                i6++;
                String str3 = (String) obj4;
                l lVarB = wVar.b(str3);
                if (lVarB == null) {
                    throw new IllegalStateException(AbstractC2462sn.j("No instantiated fragment for (", str3, ")"));
                }
                if (F(2)) {
                    lVarB.toString();
                }
                wVar.a(lVarB);
            }
        }
        if (c1368hC.n != null) {
            this.d = new ArrayList(c1368hC.n.length);
            int i7 = 0;
            while (true) {
                b[] bVarArr = c1368hC.n;
                if (i7 >= bVarArr.length) {
                    break;
                }
                b bVar = bVarArr[i7];
                ArrayList arrayList5 = bVar.m;
                a aVar = new a(this);
                int[] iArr = bVar.l;
                int i8 = 0;
                int i9 = 0;
                while (i8 < iArr.length) {
                    C1938nC c1938nC = new C1938nC();
                    int i10 = i8 + 1;
                    c1938nC.a = iArr[i8];
                    if (F(i)) {
                        Objects.toString(aVar);
                        int i11 = iArr[i10];
                    }
                    int i12 = i;
                    c1938nC.h = VK.values()[bVar.n[i9]];
                    c1938nC.i = VK.values()[bVar.f16o[i9]];
                    int i13 = i8 + 2;
                    c1938nC.c = iArr[i10] != 0;
                    int i14 = iArr[i13];
                    c1938nC.d = i14;
                    int i15 = iArr[i8 + 3];
                    c1938nC.e = i15;
                    int i16 = i8 + 5;
                    int i17 = iArr[i8 + 4];
                    c1938nC.f = i17;
                    i8 += 6;
                    int i18 = iArr[i16];
                    c1938nC.g = i18;
                    aVar.b = i14;
                    aVar.c = i15;
                    aVar.d = i17;
                    aVar.e = i18;
                    aVar.b(c1938nC);
                    i9++;
                    i = i12;
                }
                int i19 = i;
                aVar.f = bVar.p;
                aVar.h = bVar.q;
                aVar.g = true;
                aVar.i = bVar.s;
                aVar.j = bVar.t;
                aVar.k = bVar.u;
                aVar.l = bVar.v;
                aVar.m = bVar.w;
                aVar.n = bVar.x;
                aVar.f660o = bVar.y;
                aVar.r = bVar.r;
                for (int i20 = 0; i20 < arrayList5.size(); i20++) {
                    String str4 = (String) arrayList5.get(i20);
                    if (str4 != null) {
                        ((C1938nC) aVar.a.get(i20)).b = wVar.b(str4);
                    }
                }
                aVar.d(1);
                if (F(i19)) {
                    aVar.toString();
                    PrintWriter printWriter = new PrintWriter(new KM());
                    aVar.f("  ", printWriter, false);
                    printWriter.close();
                }
                this.d.add(aVar);
                i7++;
                i = i19;
            }
            i2 = 0;
        } else {
            i2 = 0;
            this.d = null;
        }
        this.i.set(c1368hC.f557o);
        String str5 = c1368hC.p;
        if (str5 != null) {
            l lVarB2 = wVar.b(str5);
            this.w = lVarB2;
            q(lVarB2);
        }
        ArrayList arrayList6 = c1368hC.q;
        if (arrayList6 != null) {
            for (int i21 = i2; i21 < arrayList6.size(); i21++) {
                this.j.put((String) arrayList6.get(i21), (C0054Cc) c1368hC.r.get(i21));
            }
        }
        this.C = new ArrayDeque(c1368hC.s);
    }

    public final Bundle R() {
        int i;
        ArrayList arrayList;
        b[] bVarArr;
        int size;
        Bundle bundle = new Bundle();
        Iterator it = e().iterator();
        while (true) {
            i = 0;
            if (!it.hasNext()) {
                break;
            }
            f fVar = (f) it.next();
            if (fVar.e) {
                F(2);
                fVar.e = false;
                fVar.d();
            }
        }
        Iterator it2 = e().iterator();
        while (it2.hasNext()) {
            ((f) it2.next()).g();
        }
        x(true);
        this.E = true;
        this.L.g = true;
        w wVar = this.c;
        wVar.getClass();
        HashMap map = wVar.b;
        ArrayList arrayList2 = new ArrayList(map.size());
        for (v vVar : map.values()) {
            if (vVar != null) {
                l lVar = vVar.c;
                vVar.l();
                arrayList2.add(lVar.mWho);
                if (F(2)) {
                    lVar.toString();
                    Objects.toString(lVar.mSavedFragmentState);
                }
            }
        }
        w wVar2 = this.c;
        wVar2.getClass();
        ArrayList arrayList3 = new ArrayList(wVar2.c.values());
        if (arrayList3.isEmpty()) {
            F(2);
            return bundle;
        }
        w wVar3 = this.c;
        synchronized (wVar3.a) {
            try {
                if (wVar3.a.isEmpty()) {
                    arrayList = null;
                } else {
                    arrayList = new ArrayList(wVar3.a.size());
                    ArrayList arrayList4 = wVar3.a;
                    int size2 = arrayList4.size();
                    int i2 = 0;
                    while (i2 < size2) {
                        Object obj = arrayList4.get(i2);
                        i2++;
                        l lVar2 = (l) obj;
                        arrayList.add(lVar2.mWho);
                        if (F(2)) {
                            lVar2.toString();
                        }
                    }
                }
            } finally {
            }
        }
        ArrayList arrayList5 = this.d;
        if (arrayList5 == null || (size = arrayList5.size()) <= 0) {
            bVarArr = null;
        } else {
            bVarArr = new b[size];
            for (int i3 = 0; i3 < size; i3++) {
                bVarArr[i3] = new b((a) this.d.get(i3));
                if (F(2)) {
                    Objects.toString(this.d.get(i3));
                }
            }
        }
        C1368hC c1368hC = new C1368hC();
        c1368hC.p = null;
        ArrayList arrayList6 = new ArrayList();
        c1368hC.q = arrayList6;
        ArrayList arrayList7 = new ArrayList();
        c1368hC.r = arrayList7;
        c1368hC.l = arrayList2;
        c1368hC.m = arrayList;
        c1368hC.n = bVarArr;
        c1368hC.f557o = this.i.get();
        l lVar3 = this.w;
        if (lVar3 != null) {
            c1368hC.p = lVar3.mWho;
        }
        arrayList6.addAll(this.j.keySet());
        arrayList7.addAll(this.j.values());
        c1368hC.s = new ArrayList(this.C);
        bundle.putParcelable("state", c1368hC);
        for (String str : this.k.keySet()) {
            bundle.putBundle(AbstractC2462sn.u("result_", str), (Bundle) this.k.get(str));
        }
        int size3 = arrayList3.size();
        while (i < size3) {
            Object obj2 = arrayList3.get(i);
            i++;
            u uVar = (u) obj2;
            Bundle bundle2 = new Bundle();
            bundle2.putParcelable("state", uVar);
            bundle.putBundle("fragment_" + uVar.m, bundle2);
        }
        return bundle;
    }

    public final void S() {
        synchronized (this.a) {
            try {
                if (this.a.size() == 1) {
                    this.t.n.removeCallbacks(this.M);
                    this.t.n.post(this.M);
                    Y();
                }
            } catch (Throwable th) {
                throw th;
            }
        }
    }

    public final void T(l lVar, boolean z) {
        ViewGroup viewGroupC = C(lVar);
        if (viewGroupC == null || !(viewGroupC instanceof FragmentContainerView)) {
            return;
        }
        ((FragmentContainerView) viewGroupC).setDrawDisappearingViewsLast(!z);
    }

    public final void U(l lVar, VK vk) {
        if (lVar.equals(this.c.b(lVar.mWho)) && (lVar.mHost == null || lVar.mFragmentManager == this)) {
            lVar.mMaxState = vk;
            return;
        }
        throw new IllegalArgumentException("Fragment " + lVar + " is not an active fragment of FragmentManager " + this);
    }

    public final void V(l lVar) {
        if (lVar != null) {
            if (!lVar.equals(this.c.b(lVar.mWho)) || (lVar.mHost != null && lVar.mFragmentManager != this)) {
                throw new IllegalArgumentException("Fragment " + lVar + " is not an active fragment of FragmentManager " + this);
            }
        }
        l lVar2 = this.w;
        this.w = lVar;
        q(lVar2);
        q(this.w);
    }

    public final void W(l lVar) {
        ViewGroup viewGroupC = C(lVar);
        if (viewGroupC != null) {
            if (lVar.getPopExitAnim() + lVar.getPopEnterAnim() + lVar.getExitAnim() + lVar.getEnterAnim() > 0) {
                if (viewGroupC.getTag(R.id.visible_removing_fragment_view_tag) == null) {
                    viewGroupC.setTag(R.id.visible_removing_fragment_view_tag, lVar);
                }
                ((l) viewGroupC.getTag(R.id.visible_removing_fragment_view_tag)).setPopDirection(lVar.getPopDirection());
            }
        }
    }

    public final void X(IllegalStateException illegalStateException) {
        illegalStateException.getMessage();
        PrintWriter printWriter = new PrintWriter(new KM());
        WB wb = this.t;
        try {
            if (wb != null) {
                ((p) wb).p.dump("  ", null, printWriter, new String[0]);
            } else {
                u("  ", null, printWriter, new String[0]);
            }
            throw illegalStateException;
        } catch (Exception unused) {
            throw illegalStateException;
        }
    }

    public final void Y() {
        synchronized (this.a) {
            try {
                int i = 0;
                if (!this.a.isEmpty()) {
                    ZB zb = this.h;
                    zb.b = true;
                    ArrayList arrayList = zb.a;
                    int size = arrayList.size();
                    while (i < size) {
                        Object obj = arrayList.get(i);
                        i++;
                        ((AT) obj).b(true);
                    }
                    return;
                }
                ZB zb2 = this.h;
                ArrayList arrayList2 = this.d;
                boolean z = (arrayList2 != null ? arrayList2.size() : 0) > 0 && I(this.v);
                zb2.b = z;
                ArrayList arrayList3 = zb2.a;
                int size2 = arrayList3.size();
                while (i < size2) {
                    Object obj2 = arrayList3.get(i);
                    i++;
                    ((AT) obj2).b(z);
                }
            } catch (Throwable th) {
                throw th;
            }
        }
    }

    public final v a(l lVar) {
        String str = lVar.mPreviousWho;
        if (str != null) {
            AbstractC1843mC.c(lVar, str);
        }
        if (F(2)) {
            lVar.toString();
        }
        v vVarF = f(lVar);
        lVar.mFragmentManager = this;
        w wVar = this.c;
        wVar.g(vVarF);
        if (!lVar.mDetached) {
            wVar.a(lVar);
            lVar.mRemoving = false;
            if (lVar.mView == null) {
                lVar.mHiddenChanged = false;
            }
            if (G(lVar)) {
                this.D = true;
            }
        }
        return vVarF;
    }

    /* JADX WARN: Multi-variable type inference failed */
    public final void b(WB wb, UB ub, l lVar) {
        if (this.t != null) {
            throw new IllegalStateException("Already attached");
        }
        this.t = wb;
        this.u = ub;
        this.v = lVar;
        CopyOnWriteArrayList copyOnWriteArrayList = this.m;
        if (lVar != null) {
            copyOnWriteArrayList.add(new C0889cC(lVar));
        } else if (wb instanceof InterfaceC1558jC) {
            copyOnWriteArrayList.add((InterfaceC1558jC) wb);
        }
        if (this.v != null) {
            Y();
        }
        if (wb instanceof FT) {
            FT ft = (FT) wb;
            ET onBackPressedDispatcher = ft.getOnBackPressedDispatcher();
            this.g = onBackPressedDispatcher;
            InterfaceC0898cL interfaceC0898cL = ft;
            if (lVar != null) {
                interfaceC0898cL = lVar;
            }
            onBackPressedDispatcher.a(this.h, interfaceC0898cL);
        }
        if (lVar != null) {
            t tVar = lVar.mFragmentManager.L;
            HashMap map = tVar.c;
            t tVar2 = (t) map.get(lVar.mWho);
            if (tVar2 == null) {
                tVar2 = new t(tVar.e);
                map.put(lVar.mWho, tVar2);
            }
            this.L = tVar2;
        } else if (wb instanceof InterfaceC1508ik0) {
            this.L = (t) new OD(((InterfaceC1508ik0) wb).getViewModelStore(), t.h).y(t.class);
        } else {
            this.L = new t(false);
        }
        t tVar3 = this.L;
        tVar3.g = this.E || this.F;
        this.c.d = tVar3;
        Object obj = this.t;
        if ((obj instanceof InterfaceC1925n40) && lVar == null) {
            C1640k40 savedStateRegistry = ((InterfaceC1925n40) obj).getSavedStateRegistry();
            savedStateRegistry.c("android:support:fragments", new C3024yj(2, this));
            Bundle bundleA = savedStateRegistry.a("android:support:fragments");
            if (bundleA != null) {
                Q(bundleA);
            }
        }
        Object obj2 = this.t;
        if (obj2 instanceof I1) {
            E1 activityResultRegistry = ((I1) obj2).getActivityResultRegistry();
            String strU = AbstractC2462sn.u("FragmentManager:", lVar != null ? AbstractC2462sn.n(new StringBuilder(), lVar.mWho, ":") : "");
            this.z = activityResultRegistry.c(AbstractC2462sn.i(strU, "StartActivityForResult"), new C2867x1(3), new YB(this, 1));
            this.A = activityResultRegistry.c(AbstractC2462sn.i(strU, "StartIntentSenderForResult"), new C2867x1(4), new YB(this, 2));
            this.B = activityResultRegistry.c(AbstractC2462sn.i(strU, "RequestPermissions"), new C2867x1(1), new YB(this, 0));
        }
        Object obj3 = this.t;
        if (obj3 instanceof IT) {
            ((IT) obj3).addOnConfigurationChangedListener(this.n);
        }
        Object obj4 = this.t;
        if (obj4 instanceof TT) {
            ((TT) obj4).addOnTrimMemoryListener(this.f17o);
        }
        Object obj5 = this.t;
        if (obj5 instanceof OT) {
            ((OT) obj5).addOnMultiWindowModeChangedListener(this.p);
        }
        Object obj6 = this.t;
        if (obj6 instanceof PT) {
            ((PT) obj6).addOnPictureInPictureModeChangedListener(this.q);
        }
        Object obj7 = this.t;
        if ((obj7 instanceof FO) && lVar == null) {
            ((FO) obj7).addMenuProvider(this.r);
        }
    }

    public final void c(l lVar) {
        if (F(2)) {
            Objects.toString(lVar);
        }
        if (lVar.mDetached) {
            lVar.mDetached = false;
            if (lVar.mAdded) {
                return;
            }
            this.c.a(lVar);
            if (F(2)) {
                lVar.toString();
            }
            if (G(lVar)) {
                this.D = true;
            }
        }
    }

    public final void d() {
        this.b = false;
        this.J.clear();
        this.I.clear();
    }

    public final HashSet e() {
        HashSet hashSet = new HashSet();
        ArrayList arrayListD = this.c.d();
        int size = arrayListD.size();
        int i = 0;
        while (i < size) {
            Object obj = arrayListD.get(i);
            i++;
            ViewGroup viewGroup = ((v) obj).c.mContainer;
            if (viewGroup != null) {
                hashSet.add(f.i(viewGroup, E()));
            }
        }
        return hashSet;
    }

    public final v f(l lVar) {
        String str = lVar.mWho;
        w wVar = this.c;
        v vVar = (v) wVar.b.get(str);
        if (vVar != null) {
            return vVar;
        }
        v vVar2 = new v(this.l, wVar, lVar);
        vVar2.j(this.t.m.getClassLoader());
        vVar2.e = this.s;
        return vVar2;
    }

    public final void g(l lVar) {
        if (F(2)) {
            Objects.toString(lVar);
        }
        if (lVar.mDetached) {
            return;
        }
        lVar.mDetached = true;
        if (lVar.mAdded) {
            if (F(2)) {
                lVar.toString();
            }
            w wVar = this.c;
            synchronized (wVar.a) {
                wVar.a.remove(lVar);
            }
            lVar.mAdded = false;
            if (G(lVar)) {
                this.D = true;
            }
            W(lVar);
        }
    }

    public final void h(boolean z, Configuration configuration) {
        if (z && (this.t instanceof IT)) {
            X(new IllegalStateException("Do not call dispatchConfigurationChanged() on host. Host implements OnConfigurationChangedProvider and automatically dispatches configuration changes to fragments."));
            throw null;
        }
        for (l lVar : this.c.f()) {
            if (lVar != null) {
                lVar.performConfigurationChanged(configuration);
                if (z) {
                    lVar.mChildFragmentManager.h(true, configuration);
                }
            }
        }
    }

    public final boolean i(MenuItem menuItem) {
        if (this.s < 1) {
            return false;
        }
        for (l lVar : this.c.f()) {
            if (lVar != null && lVar.performContextItemSelected(menuItem)) {
                return true;
            }
        }
        return false;
    }

    public final boolean j(Menu menu, MenuInflater menuInflater) {
        if (this.s < 1) {
            return false;
        }
        ArrayList arrayList = null;
        boolean z = false;
        for (l lVar : this.c.f()) {
            if (lVar != null && lVar.isMenuVisible() && lVar.performCreateOptionsMenu(menu, menuInflater)) {
                if (arrayList == null) {
                    arrayList = new ArrayList();
                }
                arrayList.add(lVar);
                z = true;
            }
        }
        if (this.e != null) {
            for (int i = 0; i < this.e.size(); i++) {
                l lVar2 = (l) this.e.get(i);
                if (arrayList == null || !arrayList.contains(lVar2)) {
                    lVar2.onDestroyOptionsMenu();
                }
            }
        }
        this.e = arrayList;
        return z;
    }

    public final void k() {
        boolean z;
        boolean zIsTerminated;
        this.G = true;
        x(true);
        Iterator it = e().iterator();
        while (it.hasNext()) {
            ((f) it.next()).g();
        }
        WB wb = this.t;
        boolean z2 = wb instanceof InterfaceC1508ik0;
        w wVar = this.c;
        if (z2) {
            z = wVar.d.f;
        } else {
            z = wb.m != null ? !r1.isChangingConfigurations() : true;
        }
        int i = 0;
        if (z) {
            Iterator it2 = this.j.values().iterator();
            while (it2.hasNext()) {
                ArrayList arrayList = ((C0054Cc) it2.next()).l;
                int size = arrayList.size();
                int i2 = 0;
                while (i2 < size) {
                    Object obj = arrayList.get(i2);
                    i2++;
                    t tVar = wVar.d;
                    tVar.getClass();
                    F(3);
                    tVar.d((String) obj);
                }
            }
        }
        t(-1);
        Object obj2 = this.t;
        if (obj2 instanceof TT) {
            ((TT) obj2).removeOnTrimMemoryListener(this.f17o);
        }
        Object obj3 = this.t;
        if (obj3 instanceof IT) {
            ((IT) obj3).removeOnConfigurationChangedListener(this.n);
        }
        Object obj4 = this.t;
        if (obj4 instanceof OT) {
            ((OT) obj4).removeOnMultiWindowModeChangedListener(this.p);
        }
        Object obj5 = this.t;
        if (obj5 instanceof PT) {
            ((PT) obj5).removeOnPictureInPictureModeChangedListener(this.q);
        }
        Object obj6 = this.t;
        if (obj6 instanceof FO) {
            ((FO) obj6).removeMenuProvider(this.r);
        }
        this.t = null;
        this.u = null;
        this.v = null;
        if (this.g != null) {
            ZB zb = this.h;
            ArrayList arrayList2 = zb.a;
            CopyOnWriteArrayList copyOnWriteArrayList = zb.c;
            Iterator it3 = copyOnWriteArrayList.iterator();
            while (it3.hasNext()) {
                AutoCloseable autoCloseable = (AutoCloseable) it3.next();
                if (autoCloseable instanceof AutoCloseable) {
                    autoCloseable.close();
                } else if (autoCloseable instanceof ExecutorService) {
                    ExecutorService executorService = (ExecutorService) autoCloseable;
                    if (executorService != ForkJoinPool.commonPool() && !(zIsTerminated = executorService.isTerminated())) {
                        executorService.shutdown();
                        boolean z3 = false;
                        while (!zIsTerminated) {
                            try {
                                zIsTerminated = executorService.awaitTermination(1L, TimeUnit.DAYS);
                            } catch (InterruptedException unused) {
                                if (!z3) {
                                    executorService.shutdownNow();
                                    z3 = true;
                                }
                            }
                        }
                        if (z3) {
                            Thread.currentThread().interrupt();
                        }
                    }
                } else if (autoCloseable instanceof TypedArray) {
                    ((TypedArray) autoCloseable).recycle();
                } else if (autoCloseable instanceof MediaMetadataRetriever) {
                    ((MediaMetadataRetriever) autoCloseable).release();
                } else {
                    if (!(autoCloseable instanceof MediaDrm)) {
                        throw new IllegalArgumentException();
                    }
                    ((MediaDrm) autoCloseable).release();
                }
            }
            copyOnWriteArrayList.clear();
            int size2 = arrayList2.size();
            while (i < size2) {
                Object obj7 = arrayList2.get(i);
                i++;
                ((AT) obj7).a();
            }
            arrayList2.clear();
            this.g = null;
        }
        D1 d1 = this.z;
        if (d1 != null) {
            d1.b();
            this.A.b();
            this.B.b();
        }
    }

    public final void l(boolean z) {
        if (z && (this.t instanceof TT)) {
            X(new IllegalStateException("Do not call dispatchLowMemory() on host. Host implements OnTrimMemoryProvider and automatically dispatches low memory callbacks to fragments."));
            throw null;
        }
        for (l lVar : this.c.f()) {
            if (lVar != null) {
                lVar.performLowMemory();
                if (z) {
                    lVar.mChildFragmentManager.l(true);
                }
            }
        }
    }

    public final void m(boolean z, boolean z2) {
        if (z2 && (this.t instanceof OT)) {
            X(new IllegalStateException("Do not call dispatchMultiWindowModeChanged() on host. Host implements OnMultiWindowModeChangedProvider and automatically dispatches multi-window mode changes to fragments."));
            throw null;
        }
        for (l lVar : this.c.f()) {
            if (lVar != null) {
                lVar.performMultiWindowModeChanged(z);
                if (z2) {
                    lVar.mChildFragmentManager.m(z, true);
                }
            }
        }
    }

    public final void n() {
        ArrayList arrayListE = this.c.e();
        int size = arrayListE.size();
        int i = 0;
        while (i < size) {
            Object obj = arrayListE.get(i);
            i++;
            l lVar = (l) obj;
            if (lVar != null) {
                lVar.onHiddenChanged(lVar.isHidden());
                lVar.mChildFragmentManager.n();
            }
        }
    }

    public final boolean o(MenuItem menuItem) {
        if (this.s < 1) {
            return false;
        }
        for (l lVar : this.c.f()) {
            if (lVar != null && lVar.performOptionsItemSelected(menuItem)) {
                return true;
            }
        }
        return false;
    }

    public final void p(Menu menu) {
        if (this.s < 1) {
            return;
        }
        for (l lVar : this.c.f()) {
            if (lVar != null) {
                lVar.performOptionsMenuClosed(menu);
            }
        }
    }

    public final void q(l lVar) {
        if (lVar != null) {
            if (lVar.equals(this.c.b(lVar.mWho))) {
                lVar.performPrimaryNavigationFragmentChanged();
            }
        }
    }

    public final void r(boolean z, boolean z2) {
        if (z2 && (this.t instanceof PT)) {
            X(new IllegalStateException("Do not call dispatchPictureInPictureModeChanged() on host. Host implements OnPictureInPictureModeChangedProvider and automatically dispatches picture-in-picture mode changes to fragments."));
            throw null;
        }
        for (l lVar : this.c.f()) {
            if (lVar != null) {
                lVar.performPictureInPictureModeChanged(z);
                if (z2) {
                    lVar.mChildFragmentManager.r(z, true);
                }
            }
        }
    }

    public final boolean s(Menu menu) {
        boolean z = false;
        if (this.s < 1) {
            return false;
        }
        for (l lVar : this.c.f()) {
            if (lVar != null && lVar.isMenuVisible() && lVar.performPrepareOptionsMenu(menu)) {
                z = true;
            }
        }
        return z;
    }

    public final void t(int i) {
        try {
            this.b = true;
            for (v vVar : this.c.b.values()) {
                if (vVar != null) {
                    vVar.e = i;
                }
            }
            J(i, false);
            Iterator it = e().iterator();
            while (it.hasNext()) {
                ((f) it.next()).g();
            }
            this.b = false;
            x(true);
        } catch (Throwable th) {
            this.b = 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 ");
        l lVar = this.v;
        if (lVar != null) {
            sb.append(lVar.getClass().getSimpleName());
            sb.append("{");
            sb.append(Integer.toHexString(System.identityHashCode(this.v)));
            sb.append("}");
        } else {
            WB wb = this.t;
            if (wb != null) {
                sb.append(wb.getClass().getSimpleName());
                sb.append("{");
                sb.append(Integer.toHexString(System.identityHashCode(this.t)));
                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 strI = AbstractC2462sn.i(str, "    ");
        w wVar = this.c;
        ArrayList arrayList = wVar.a;
        String strI2 = AbstractC2462sn.i(str, "    ");
        HashMap map = wVar.b;
        if (!map.isEmpty()) {
            printWriter.print(str);
            printWriter.println("Active Fragments:");
            for (v vVar : map.values()) {
                printWriter.print(str);
                if (vVar != null) {
                    l lVar = vVar.c;
                    printWriter.println(lVar);
                    lVar.dump(strI2, fileDescriptor, printWriter, strArr);
                } else {
                    printWriter.println("null");
                }
            }
        }
        int size3 = arrayList.size();
        if (size3 > 0) {
            printWriter.print(str);
            printWriter.println("Added Fragments:");
            for (int i = 0; i < size3; i++) {
                l lVar2 = (l) arrayList.get(i);
                printWriter.print(str);
                printWriter.print("  #");
                printWriter.print(i);
                printWriter.print(": ");
                printWriter.println(lVar2.toString());
            }
        }
        ArrayList arrayList2 = this.e;
        if (arrayList2 != null && (size2 = arrayList2.size()) > 0) {
            printWriter.print(str);
            printWriter.println("Fragments Created Menus:");
            for (int i2 = 0; i2 < size2; i2++) {
                l lVar3 = (l) this.e.get(i2);
                printWriter.print(str);
                printWriter.print("  #");
                printWriter.print(i2);
                printWriter.print(": ");
                printWriter.println(lVar3.toString());
            }
        }
        ArrayList arrayList3 = this.d;
        if (arrayList3 != null && (size = arrayList3.size()) > 0) {
            printWriter.print(str);
            printWriter.println("Back Stack:");
            for (int i3 = 0; i3 < size; i3++) {
                a aVar = (a) this.d.get(i3);
                printWriter.print(str);
                printWriter.print("  #");
                printWriter.print(i3);
                printWriter.print(": ");
                printWriter.println(aVar.toString());
                aVar.f(strI, printWriter, true);
            }
        }
        printWriter.print(str);
        printWriter.println("Back Stack Index: " + this.i.get());
        synchronized (this.a) {
            try {
                int size4 = this.a.size();
                if (size4 > 0) {
                    printWriter.print(str);
                    printWriter.println("Pending Actions:");
                    for (int i4 = 0; i4 < size4; i4++) {
                        Object obj = (InterfaceC1080eC) this.a.get(i4);
                        printWriter.print(str);
                        printWriter.print("  #");
                        printWriter.print(i4);
                        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.t);
        printWriter.print(str);
        printWriter.print("  mContainer=");
        printWriter.println(this.u);
        if (this.v != null) {
            printWriter.print(str);
            printWriter.print("  mParent=");
            printWriter.println(this.v);
        }
        printWriter.print(str);
        printWriter.print("  mCurState=");
        printWriter.print(this.s);
        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);
        }
    }

    public final void v(InterfaceC1080eC interfaceC1080eC, boolean z) {
        if (!z) {
            if (this.t == null) {
                if (!this.G) {
                    throw new IllegalStateException("FragmentManager has not been attached to a host.");
                }
                throw new IllegalStateException("FragmentManager has been destroyed");
            }
            if (this.E || this.F) {
                throw new IllegalStateException("Can not perform this action after onSaveInstanceState");
            }
        }
        synchronized (this.a) {
            try {
                if (this.t == null) {
                    if (!z) {
                        throw new IllegalStateException("Activity has been destroyed");
                    }
                } else {
                    this.a.add(interfaceC1080eC);
                    S();
                }
            } catch (Throwable th) {
                throw th;
            }
        }
    }

    public final void w(boolean z) {
        if (this.b) {
            throw new IllegalStateException("FragmentManager is already executing transactions");
        }
        if (this.t == 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.t.n.getLooper()) {
            throw new IllegalStateException("Must be called from main thread of fragment host");
        }
        if (!z && (this.E || this.F)) {
            throw new IllegalStateException("Can not perform this action after onSaveInstanceState");
        }
        if (this.I == null) {
            this.I = new ArrayList();
            this.J = new ArrayList();
        }
    }

    public final boolean x(boolean z) {
        boolean zA;
        w(z);
        boolean z2 = false;
        while (true) {
            ArrayList arrayList = this.I;
            ArrayList arrayList2 = this.J;
            synchronized (this.a) {
                if (this.a.isEmpty()) {
                    zA = false;
                } else {
                    try {
                        int size = this.a.size();
                        zA = false;
                        for (int i = 0; i < size; i++) {
                            zA |= ((InterfaceC1080eC) this.a.get(i)).a(arrayList, arrayList2);
                        }
                    } finally {
                    }
                }
            }
            if (!zA) {
                break;
            }
            this.b = true;
            try {
                P(this.I, this.J);
                d();
                z2 = true;
            } catch (Throwable th) {
                d();
                throw th;
            }
        }
        Y();
        if (this.H) {
            this.H = false;
            ArrayList arrayListD = this.c.d();
            int size2 = arrayListD.size();
            int i2 = 0;
            while (i2 < size2) {
                Object obj = arrayListD.get(i2);
                i2++;
                v vVar = (v) obj;
                l lVar = vVar.c;
                if (lVar.mDeferStart) {
                    if (this.b) {
                        this.H = true;
                    } else {
                        lVar.mDeferStart = false;
                        vVar.i();
                    }
                }
            }
        }
        this.c.b.values().removeAll(Collections.singleton(null));
        return z2;
    }

    public final void y(a aVar, boolean z) {
        if (z && (this.t == null || this.G)) {
            return;
        }
        w(z);
        aVar.a(this.I, this.J);
        this.b = true;
        try {
            P(this.I, this.J);
            d();
            Y();
            boolean z2 = this.H;
            w wVar = this.c;
            if (z2) {
                this.H = false;
                ArrayList arrayListD = wVar.d();
                int size = arrayListD.size();
                int i = 0;
                while (i < size) {
                    Object obj = arrayListD.get(i);
                    i++;
                    v vVar = (v) obj;
                    l lVar = vVar.c;
                    if (lVar.mDeferStart) {
                        if (this.b) {
                            this.H = true;
                        } else {
                            lVar.mDeferStart = false;
                            vVar.i();
                        }
                    }
                }
            }
            wVar.b.values().removeAll(Collections.singleton(null));
        } catch (Throwable th) {
            d();
            throw th;
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:106:0x022f A[PHI: r14
      0x022f: PHI (r14v14 int) = (r14v13 int), (r14v15 int) binds: [B:99:0x021f, B:104:0x022b] A[DONT_GENERATE, DONT_INLINE]] */
    /* JADX WARN: Removed duplicated region for block: B:64:0x0182  */
    /* JADX WARN: Removed duplicated region for block: B:65:0x0188  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public final void z(java.util.ArrayList r25, java.util.ArrayList r26, int r27, int r28) {
        /*
            Method dump skipped, instructions count: 1298
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: androidx.fragment.app.s.z(java.util.ArrayList, java.util.ArrayList, int, int):void");
    }
}
