package androidx.fragment.app;

import android.util.Log;
import androidx.lifecycle.c1;
import androidx.lifecycle.d1;
import androidx.lifecycle.z0;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;

/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes.dex */
public final class c0 extends z0 {

    /* renamed from: i, reason: collision with root package name */
    private static final c1.c f4427i = new a();

    /* renamed from: e, reason: collision with root package name */
    private final boolean f4431e;

    /* renamed from: b, reason: collision with root package name */
    private final HashMap f4428b = new HashMap();

    /* renamed from: c, reason: collision with root package name */
    private final HashMap f4429c = new HashMap();

    /* renamed from: d, reason: collision with root package name */
    private final HashMap f4430d = new HashMap();

    /* renamed from: f, reason: collision with root package name */
    private boolean f4432f = false;

    /* renamed from: g, reason: collision with root package name */
    private boolean f4433g = false;

    /* renamed from: h, reason: collision with root package name */
    private boolean f4434h = false;

    /* loaded from: classes.dex */
    class a implements c1.c {
        a() {
        }

        @Override // androidx.lifecycle.c1.c
        public z0 a(Class cls) {
            return new c0(true);
        }
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public c0(boolean z10) {
        this.f4431e = z10;
    }

    private void S(String str) {
        c0 c0Var = (c0) this.f4429c.get(str);
        if (c0Var != null) {
            c0Var.O();
            this.f4429c.remove(str);
        }
        d1 d1Var = (d1) this.f4430d.get(str);
        if (d1Var != null) {
            d1Var.a();
            this.f4430d.remove(str);
        }
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public static c0 V(d1 d1Var) {
        return (c0) new c1(d1Var, f4427i).a(c0.class);
    }

    /* JADX INFO: Access modifiers changed from: protected */
    @Override // androidx.lifecycle.z0
    public void O() {
        if (z.N0(3)) {
            Log.d("FragmentManager", "onCleared called for " + this);
        }
        this.f4432f = true;
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public void P(f fVar) {
        if (this.f4434h) {
            if (z.N0(2)) {
                Log.v("FragmentManager", "Ignoring addRetainedFragment as the state is already saved");
            }
        } else {
            if (this.f4428b.containsKey(fVar.mWho)) {
                return;
            }
            this.f4428b.put(fVar.mWho, fVar);
            if (z.N0(2)) {
                Log.v("FragmentManager", "Updating retained Fragments: Added " + fVar);
            }
        }
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public void Q(f fVar) {
        if (z.N0(3)) {
            Log.d("FragmentManager", "Clearing non-config state for " + fVar);
        }
        S(fVar.mWho);
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public void R(String str) {
        if (z.N0(3)) {
            Log.d("FragmentManager", "Clearing non-config state for saved state of Fragment " + str);
        }
        S(str);
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public f T(String str) {
        return (f) this.f4428b.get(str);
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public c0 U(f fVar) {
        c0 c0Var = (c0) this.f4429c.get(fVar.mWho);
        if (c0Var != null) {
            return c0Var;
        }
        c0 c0Var2 = new c0(this.f4431e);
        this.f4429c.put(fVar.mWho, c0Var2);
        return c0Var2;
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public Collection W() {
        return new ArrayList(this.f4428b.values());
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public d1 X(f fVar) {
        d1 d1Var = (d1) this.f4430d.get(fVar.mWho);
        if (d1Var != null) {
            return d1Var;
        }
        d1 d1Var2 = new d1();
        this.f4430d.put(fVar.mWho, d1Var2);
        return d1Var2;
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public boolean Y() {
        return this.f4432f;
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public void Z(f fVar) {
        if (this.f4434h) {
            if (z.N0(2)) {
                Log.v("FragmentManager", "Ignoring removeRetainedFragment as the state is already saved");
                return;
            }
            return;
        }
        if ((this.f4428b.remove(fVar.mWho) != null) && z.N0(2)) {
            Log.v("FragmentManager", "Updating retained Fragments: Removed " + fVar);
        }
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public void a0(boolean z10) {
        this.f4434h = z10;
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public boolean b0(f fVar) {
        if (this.f4428b.containsKey(fVar.mWho)) {
            return this.f4431e ? this.f4432f : !this.f4433g;
        }
        return true;
    }

    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null || c0.class != obj.getClass()) {
            return false;
        }
        c0 c0Var = (c0) obj;
        return this.f4428b.equals(c0Var.f4428b) && this.f4429c.equals(c0Var.f4429c) && this.f4430d.equals(c0Var.f4430d);
    }

    public int hashCode() {
        return (((this.f4428b.hashCode() * 31) + this.f4429c.hashCode()) * 31) + this.f4430d.hashCode();
    }

    public String toString() {
        StringBuilder sb2 = new StringBuilder("FragmentManagerViewModel{");
        sb2.append(Integer.toHexString(System.identityHashCode(this)));
        sb2.append("} Fragments (");
        Iterator it = this.f4428b.values().iterator();
        while (it.hasNext()) {
            sb2.append(it.next());
            if (it.hasNext()) {
                sb2.append(", ");
            }
        }
        sb2.append(") Child Non Config (");
        Iterator it2 = this.f4429c.keySet().iterator();
        while (it2.hasNext()) {
            sb2.append((String) it2.next());
            if (it2.hasNext()) {
                sb2.append(", ");
            }
        }
        sb2.append(") ViewModelStores (");
        Iterator it3 = this.f4430d.keySet().iterator();
        while (it3.hasNext()) {
            sb2.append((String) it3.next());
            if (it3.hasNext()) {
                sb2.append(", ");
            }
        }
        sb2.append(')');
        return sb2.toString();
    }
}
