package ῲ.Ԕ.K;

import androidx.fragment.app.Fragment;
import androidx.lifecycle.Lifecycle;
import java.io.PrintWriter;
import java.util.ArrayList;
import ඓ.K.K.K.C1293;
import ῲ.Ԕ.K.AbstractC1531;
import ῲ.Ԕ.K.AbstractC1558;
import ῲ.Ԕ.K.LayoutInflater$Factory2C1545;

/* renamed from: ῲ.Ԕ.K.K  reason: contains not printable characters */
/* compiled from: BackStackRecord */
public final class C1535 extends AbstractC1558 implements AbstractC1531.AbstractC1534, LayoutInflater$Factory2C1545.AbstractC1549 {

    /* renamed from: ݜ  reason: contains not printable characters */
    public boolean f5609;

    /* renamed from: 㗽  reason: contains not printable characters */
    public final LayoutInflater$Factory2C1545 f5610;

    /* renamed from: 䀟  reason: contains not printable characters */
    public int f5611 = -1;

    public C1535(LayoutInflater$Factory2C1545 r2) {
        this.f5610 = r2;
    }

    public void setOnStartPostponedListener(Fragment.AbstractC0182 r4) {
        for (int i = 0; i < this.f5716.size(); i++) {
            AbstractC1558.C1559 k = this.f5716.get(i);
            if (m3921(k)) {
                k.f5726.setOnStartEnterTransitionListener(r4);
            }
        }
    }

    public String toString() {
        StringBuilder sb = new StringBuilder(128);
        sb.append("BackStackEntry{");
        sb.append(Integer.toHexString(System.identityHashCode(this)));
        if (this.f5611 >= 0) {
            sb.append(" #");
            sb.append(this.f5611);
        }
        if (this.f5713 != null) {
            sb.append(" ");
            sb.append(this.f5713);
        }
        sb.append("}");
        return sb.toString();
    }

    @Override // ῲ.Ԕ.K.AbstractC1558
    /* renamed from: ʬ  reason: contains not printable characters */
    public AbstractC1558 m3922(Fragment fragment) {
        LayoutInflater$Factory2C1545 r0 = fragment.mFragmentManager;
        if (r0 == null || r0 == this.f5610) {
            super.m4087(fragment);
            return this;
        }
        StringBuilder r1 = C1293.m3416("Cannot hide Fragment attached to a different FragmentManager. Fragment ");
        r1.append(fragment.toString());
        r1.append(" is already attached to a FragmentManager.");
        throw new IllegalStateException(r1.toString());
    }

    @Override // ῲ.Ԕ.K.AbstractC1558
    /* renamed from: ඓ  reason: contains not printable characters */
    public AbstractC1558 m3924(Fragment fragment) {
        LayoutInflater$Factory2C1545 r0 = fragment.mFragmentManager;
        if (r0 == null || r0 == this.f5610) {
            super.m4090(fragment);
            return this;
        }
        StringBuilder r1 = C1293.m3416("Cannot show Fragment attached to a different FragmentManager. Fragment ");
        r1.append(fragment.toString());
        r1.append(" is already attached to a FragmentManager.");
        throw new IllegalStateException(r1.toString());
    }

    /* renamed from: ᨨ  reason: contains not printable characters */
    public void m3925() {
        if (this.f5711 != null) {
            for (int i = 0; i < this.f5711.size(); i++) {
                this.f5711.get(i).run();
            }
            this.f5711 = null;
        }
    }

    @Override // ῲ.Ԕ.K.AbstractC1558
    /* renamed from: ῲ  reason: contains not printable characters */
    public AbstractC1558 m3928(Fragment fragment) {
        LayoutInflater$Factory2C1545 r0 = fragment.mFragmentManager;
        if (r0 == null || r0 == this.f5610) {
            super.m4094(fragment);
            return this;
        }
        StringBuilder r1 = C1293.m3416("Cannot detach Fragment attached to a different FragmentManager. Fragment ");
        r1.append(fragment.toString());
        r1.append(" is already attached to a FragmentManager.");
        throw new IllegalStateException(r1.toString());
    }

    /* renamed from: ⁱ  reason: contains not printable characters */
    public String m3931() {
        return this.f5713;
    }

    /* renamed from: K  reason: contains not printable characters */
    public void m3938(String str, PrintWriter printWriter) {
        m3939(str, printWriter, true);
    }

    /* renamed from: 㴹  reason: contains not printable characters */
    public void m3942() {
        int size = this.f5716.size();
        for (int i = 0; i < size; i++) {
            AbstractC1558.C1559 k = this.f5716.get(i);
            Fragment fragment = k.f5726;
            if (fragment != null) {
                fragment.setNextTransition(this.f5720, this.f5715);
            }
            switch (k.f5728) {
                case 1:
                    fragment.setNextAnim(k.f5724);
                    this.f5610.m4038(fragment, false);
                    break;
                case 2:
                default:
                    StringBuilder r1 = C1293.m3416("Unknown cmd: ");
                    r1.append(k.f5728);
                    throw new IllegalArgumentException(r1.toString());
                case 3:
                    fragment.setNextAnim(k.f5730);
                    this.f5610.m3998(fragment);
                    break;
                case 4:
                    fragment.setNextAnim(k.f5730);
                    this.f5610.m4003(fragment);
                    break;
                case 5:
                    fragment.setNextAnim(k.f5724);
                    this.f5610.m4069(fragment);
                    break;
                case 6:
                    fragment.setNextAnim(k.f5730);
                    this.f5610.m4071(fragment);
                    break;
                case 7:
                    fragment.setNextAnim(k.f5724);
                    this.f5610.m4007(fragment);
                    break;
                case 8:
                    this.f5610.m3983(fragment);
                    break;
                case 9:
                    this.f5610.m3983(null);
                    break;
                case 10:
                    this.f5610.m4037(fragment, k.f5731);
                    break;
            }
            if (!(this.f5709 || k.f5728 == 1 || fragment == null)) {
                this.f5610.m3982(fragment);
            }
        }
        if (!this.f5709) {
            LayoutInflater$Factory2C1545 r0 = this.f5610;
            r0.m4027(r0.f5658, true);
        }
    }

    @Override // ῲ.Ԕ.K.AbstractC1558
    /* renamed from: 㸾  reason: contains not printable characters */
    public AbstractC1558 m3943(Fragment fragment) {
        LayoutInflater$Factory2C1545 r0 = fragment.mFragmentManager;
        if (r0 == null || r0 == this.f5610) {
            super.m4103(fragment);
            return this;
        }
        StringBuilder r1 = C1293.m3416("Cannot remove Fragment attached to a different FragmentManager. Fragment ");
        r1.append(fragment.toString());
        r1.append(" is already attached to a FragmentManager.");
        throw new IllegalStateException(r1.toString());
    }

    /* renamed from: 㿎  reason: contains not printable characters */
    public boolean m3945() {
        for (int i = 0; i < this.f5716.size(); i++) {
            if (m3921(this.f5716.get(i))) {
                return true;
            }
        }
        return false;
    }

    /* renamed from: K  reason: contains not printable characters */
    public void m3939(String str, PrintWriter printWriter, boolean z) {
        String str2;
        if (z) {
            printWriter.print(str);
            printWriter.print("mName=");
            printWriter.print(this.f5713);
            printWriter.print(" mIndex=");
            printWriter.print(this.f5611);
            printWriter.print(" mCommitted=");
            printWriter.println(this.f5609);
            if (this.f5720 != 0) {
                printWriter.print(str);
                printWriter.print("mTransition=#");
                printWriter.print(Integer.toHexString(this.f5720));
                printWriter.print(" mTransitionStyle=#");
                printWriter.println(Integer.toHexString(this.f5715));
            }
            if (!(this.f5714 == 0 && this.f5707 == 0)) {
                printWriter.print(str);
                printWriter.print("mEnterAnim=#");
                printWriter.print(Integer.toHexString(this.f5714));
                printWriter.print(" mExitAnim=#");
                printWriter.println(Integer.toHexString(this.f5707));
            }
            if (!(this.f5721 == 0 && this.f5710 == 0)) {
                printWriter.print(str);
                printWriter.print("mPopEnterAnim=#");
                printWriter.print(Integer.toHexString(this.f5721));
                printWriter.print(" mPopExitAnim=#");
                printWriter.println(Integer.toHexString(this.f5710));
            }
            if (!(this.f5719 == 0 && this.f5712 == null)) {
                printWriter.print(str);
                printWriter.print("mBreadCrumbTitleRes=#");
                printWriter.print(Integer.toHexString(this.f5719));
                printWriter.print(" mBreadCrumbTitleText=");
                printWriter.println(this.f5712);
            }
            if (!(this.f5717 == 0 && this.f5723 == null)) {
                printWriter.print(str);
                printWriter.print("mBreadCrumbShortTitleRes=#");
                printWriter.print(Integer.toHexString(this.f5717));
                printWriter.print(" mBreadCrumbShortTitleText=");
                printWriter.println(this.f5723);
            }
        }
        if (!this.f5716.isEmpty()) {
            printWriter.print(str);
            printWriter.println("Operations:");
            int size = this.f5716.size();
            for (int i = 0; i < size; i++) {
                AbstractC1558.C1559 k = this.f5716.get(i);
                switch (k.f5728) {
                    case 0:
                        str2 = "NULL";
                        break;
                    case 1:
                        str2 = "ADD";
                        break;
                    case 2:
                        str2 = "REPLACE";
                        break;
                    case 3:
                        str2 = "REMOVE";
                        break;
                    case 4:
                        str2 = "HIDE";
                        break;
                    case 5:
                        str2 = "SHOW";
                        break;
                    case 6:
                        str2 = "DETACH";
                        break;
                    case 7:
                        str2 = "ATTACH";
                        break;
                    case 8:
                        str2 = "SET_PRIMARY_NAV";
                        break;
                    case 9:
                        str2 = "UNSET_PRIMARY_NAV";
                        break;
                    case 10:
                        str2 = "OP_SET_MAX_LIFECYCLE";
                        break;
                    default:
                        StringBuilder r3 = C1293.m3416("cmd=");
                        r3.append(k.f5728);
                        str2 = r3.toString();
                        break;
                }
                printWriter.print(str);
                printWriter.print("  Op #");
                printWriter.print(i);
                printWriter.print(": ");
                printWriter.print(str2);
                printWriter.print(" ");
                printWriter.println(k.f5726);
                if (z) {
                    if (!(k.f5724 == 0 && k.f5730 == 0)) {
                        printWriter.print(str);
                        printWriter.print("enterAnim=#");
                        printWriter.print(Integer.toHexString(k.f5724));
                        printWriter.print(" exitAnim=#");
                        printWriter.println(Integer.toHexString(k.f5730));
                    }
                    if (k.f5725 != 0 || k.f5729 != 0) {
                        printWriter.print(str);
                        printWriter.print("popEnterAnim=#");
                        printWriter.print(Integer.toHexString(k.f5725));
                        printWriter.print(" popExitAnim=#");
                        printWriter.println(Integer.toHexString(k.f5729));
                    }
                }
            }
        }
    }

    @Override // ῲ.Ԕ.K.AbstractC1558
    /* renamed from: ʬ  reason: contains not printable characters */
    public void m3923() {
        m4089();
        this.f5610.m4011((LayoutInflater$Factory2C1545.AbstractC1549) this, false);
    }

    @Override // ῲ.Ԕ.K.AbstractC1558
    /* renamed from: ῲ  reason: contains not printable characters */
    public int m3926() {
        return m3933(true);
    }

    @Override // ῲ.Ԕ.K.AbstractC1558
    /* renamed from: 㸾  reason: contains not printable characters */
    public void m3944() {
        m4089();
        this.f5610.m4011((LayoutInflater$Factory2C1545.AbstractC1549) this, true);
    }

    /* renamed from: ῲ  reason: contains not printable characters */
    public boolean m3930(int i) {
        int size = this.f5716.size();
        for (int i2 = 0; i2 < size; i2++) {
            Fragment fragment = this.f5716.get(i2).f5726;
            int i3 = fragment != null ? fragment.mContainerId : 0;
            if (i3 != 0 && i3 == i) {
                return true;
            }
        }
        return false;
    }

    /* renamed from: ῲ  reason: contains not printable characters */
    public void m3929(boolean z) {
        for (int size = this.f5716.size() - 1; size >= 0; size--) {
            AbstractC1558.C1559 k = this.f5716.get(size);
            Fragment fragment = k.f5726;
            if (fragment != null) {
                fragment.setNextTransition(LayoutInflater$Factory2C1545.m3972(this.f5720), this.f5715);
            }
            switch (k.f5728) {
                case 1:
                    fragment.setNextAnim(k.f5729);
                    this.f5610.m3998(fragment);
                    break;
                case 2:
                default:
                    StringBuilder r0 = C1293.m3416("Unknown cmd: ");
                    r0.append(k.f5728);
                    throw new IllegalArgumentException(r0.toString());
                case 3:
                    fragment.setNextAnim(k.f5725);
                    this.f5610.m4038(fragment, false);
                    break;
                case 4:
                    fragment.setNextAnim(k.f5725);
                    this.f5610.m4069(fragment);
                    break;
                case 5:
                    fragment.setNextAnim(k.f5729);
                    this.f5610.m4003(fragment);
                    break;
                case 6:
                    fragment.setNextAnim(k.f5725);
                    this.f5610.m4007(fragment);
                    break;
                case 7:
                    fragment.setNextAnim(k.f5729);
                    this.f5610.m4071(fragment);
                    break;
                case 8:
                    this.f5610.m3983(null);
                    break;
                case 9:
                    this.f5610.m3983(fragment);
                    break;
                case 10:
                    this.f5610.m4037(fragment, k.f5727);
                    break;
            }
            if (!(this.f5709 || k.f5728 == 3 || fragment == null)) {
                this.f5610.m3982(fragment);
            }
        }
        if (!this.f5709 && z) {
            LayoutInflater$Factory2C1545 r7 = this.f5610;
            r7.m4027(r7.f5658, true);
        }
    }

    /* renamed from: ῲ  reason: contains not printable characters */
    public Fragment m3927(ArrayList<Fragment> arrayList, Fragment fragment) {
        for (int size = this.f5716.size() - 1; size >= 0; size--) {
            AbstractC1558.C1559 k = this.f5716.get(size);
            int i = k.f5728;
            if (i != 1) {
                if (i != 3) {
                    switch (i) {
                        case 8:
                            fragment = null;
                            break;
                        case 9:
                            fragment = k.f5726;
                            break;
                        case 10:
                            k.f5731 = k.f5727;
                            break;
                    }
                }
                arrayList.add(k.f5726);
            }
            arrayList.remove(k.f5726);
        }
        return fragment;
    }

    /* renamed from: ῲ  reason: contains not printable characters */
    public static boolean m3921(AbstractC1558.C1559 k) {
        Fragment fragment = k.f5726;
        return fragment != null && fragment.mAdded && fragment.mView != null && !fragment.mDetached && !fragment.mHidden && fragment.isPostponed();
    }

    @Override // ῲ.Ԕ.K.AbstractC1558
    /* renamed from: K  reason: contains not printable characters */
    public void m3937(int i, Fragment fragment, String str, int i2) {
        super.m4101(i, fragment, str, i2);
        fragment.mFragmentManager = this.f5610;
    }

    @Override // ῲ.Ԕ.K.AbstractC1558
    /* renamed from: K  reason: contains not printable characters */
    public AbstractC1558 m3935(Fragment fragment, Lifecycle.State state) {
        if (fragment.mFragmentManager != this.f5610) {
            StringBuilder r4 = C1293.m3416("Cannot setMaxLifecycle for Fragment not attached to FragmentManager ");
            r4.append(this.f5610);
            throw new IllegalArgumentException(r4.toString());
        } else if (state.isAtLeast(Lifecycle.State.CREATED)) {
            super.m4099(fragment, state);
            return this;
        } else {
            StringBuilder r42 = C1293.m3416("Cannot set maximum Lifecycle below ");
            r42.append(Lifecycle.State.CREATED);
            throw new IllegalArgumentException(r42.toString());
        }
    }

    /* renamed from: K  reason: contains not printable characters */
    public void m3936(int i) {
        if (this.f5722) {
            int size = this.f5716.size();
            for (int i2 = 0; i2 < size; i2++) {
                Fragment fragment = this.f5716.get(i2).f5726;
                if (fragment != null) {
                    fragment.mBackStackNesting += i;
                }
            }
        }
    }

    @Override // ῲ.Ԕ.K.AbstractC1558
    /* renamed from: K  reason: contains not printable characters */
    public int m3932() {
        return m3933(false);
    }

    /* renamed from: K  reason: contains not printable characters */
    public int m3933(boolean z) {
        if (!this.f5609) {
            this.f5609 = true;
            if (this.f5722) {
                this.f5611 = this.f5610.m4004(this);
            } else {
                this.f5611 = -1;
            }
            this.f5610.m4046(this, z);
            return this.f5611;
        }
        throw new IllegalStateException("commit already called");
    }

    @Override // ῲ.Ԕ.K.LayoutInflater$Factory2C1545.AbstractC1549
    /* renamed from: K  reason: contains not printable characters */
    public boolean m3941(ArrayList<C1535> arrayList, ArrayList<Boolean> arrayList2) {
        arrayList.add(this);
        arrayList2.add(false);
        if (!this.f5722) {
            return true;
        }
        this.f5610.m4043(this);
        return true;
    }

    /* renamed from: K  reason: contains not printable characters */
    public boolean m3940(ArrayList<C1535> arrayList, int i, int i2) {
        if (i2 == i) {
            return false;
        }
        int size = this.f5716.size();
        int i3 = -1;
        for (int i4 = 0; i4 < size; i4++) {
            Fragment fragment = this.f5716.get(i4).f5726;
            int i5 = fragment != null ? fragment.mContainerId : 0;
            if (!(i5 == 0 || i5 == i3)) {
                for (int i6 = i; i6 < i2; i6++) {
                    C1535 k = arrayList.get(i6);
                    int size2 = k.f5716.size();
                    for (int i7 = 0; i7 < size2; i7++) {
                        Fragment fragment2 = k.f5716.get(i7).f5726;
                        if ((fragment2 != null ? fragment2.mContainerId : 0) == i5) {
                            return true;
                        }
                    }
                }
                i3 = i5;
            }
        }
        return false;
    }

    /* renamed from: K  reason: contains not printable characters */
    public Fragment m3934(ArrayList<Fragment> arrayList, Fragment fragment) {
        Fragment fragment2 = fragment;
        int i = 0;
        while (i < this.f5716.size()) {
            AbstractC1558.C1559 k = this.f5716.get(i);
            int i2 = k.f5728;
            if (i2 != 1) {
                if (i2 == 2) {
                    Fragment fragment3 = k.f5726;
                    int i3 = fragment3.mContainerId;
                    Fragment fragment4 = fragment2;
                    int i4 = i;
                    boolean z = false;
                    for (int size = arrayList.size() - 1; size >= 0; size--) {
                        Fragment fragment5 = arrayList.get(size);
                        if (fragment5.mContainerId == i3) {
                            if (fragment5 == fragment3) {
                                z = true;
                            } else {
                                if (fragment5 == fragment4) {
                                    this.f5716.add(i4, new AbstractC1558.C1559(9, fragment5));
                                    i4++;
                                    fragment4 = null;
                                }
                                AbstractC1558.C1559 k2 = new AbstractC1558.C1559(3, fragment5);
                                k2.f5724 = k.f5724;
                                k2.f5725 = k.f5725;
                                k2.f5730 = k.f5730;
                                k2.f5729 = k.f5729;
                                this.f5716.add(i4, k2);
                                arrayList.remove(fragment5);
                                i4++;
                            }
                        }
                    }
                    if (z) {
                        this.f5716.remove(i4);
                        i4--;
                    } else {
                        k.f5728 = 1;
                        arrayList.add(fragment3);
                    }
                    i = i4;
                    fragment2 = fragment4;
                } else if (i2 == 3 || i2 == 6) {
                    arrayList.remove(k.f5726);
                    Fragment fragment6 = k.f5726;
                    if (fragment6 == fragment2) {
                        this.f5716.add(i, new AbstractC1558.C1559(9, fragment6));
                        i++;
                        fragment2 = null;
                    }
                } else if (i2 != 7) {
                    if (i2 == 8) {
                        this.f5716.add(i, new AbstractC1558.C1559(9, fragment2));
                        i++;
                        fragment2 = k.f5726;
                    }
                }
                i++;
            }
            arrayList.add(k.f5726);
            i++;
        }
        return fragment2;
    }
}
