package h0;

import E1.C0113u;
import android.util.Log;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;

/* JADX INFO: loaded from: classes.dex */
public final class S extends androidx.lifecycle.W {

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public static final C0113u f13100h = new C0113u(3);

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public final boolean f13104e;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final HashMap f13101b = new HashMap();

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

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final HashMap f13103d = new HashMap();

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public boolean f13105f = false;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public boolean f13106g = false;

    public S(boolean z8) {
        this.f13104e = z8;
    }

    @Override // androidx.lifecycle.W
    public final void d() {
        if (P.L(3)) {
            Log.d("FragmentManager", "onCleared called for " + this);
        }
        this.f13105f = true;
    }

    public final void e(ComponentCallbacksC1023x componentCallbacksC1023x, boolean z8) {
        if (P.L(3)) {
            Log.d("FragmentManager", "Clearing non-config state for " + componentCallbacksC1023x);
        }
        g(componentCallbacksC1023x.f13297u, z8);
    }

    public final boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj != null && S.class == obj.getClass()) {
            S s8 = (S) obj;
            if (this.f13101b.equals(s8.f13101b) && this.f13102c.equals(s8.f13102c) && this.f13103d.equals(s8.f13103d)) {
                return true;
            }
        }
        return false;
    }

    public final void f(String str, boolean z8) {
        if (P.L(3)) {
            Log.d("FragmentManager", "Clearing non-config state for saved state of Fragment " + str);
        }
        g(str, z8);
    }

    public final void g(String str, boolean z8) {
        HashMap map = this.f13102c;
        S s8 = (S) map.get(str);
        if (s8 != null) {
            if (z8) {
                ArrayList arrayList = new ArrayList();
                arrayList.addAll(s8.f13102c.keySet());
                int size = arrayList.size();
                int i = 0;
                while (i < size) {
                    Object obj = arrayList.get(i);
                    i++;
                    s8.f((String) obj, true);
                }
            }
            s8.d();
            map.remove(str);
        }
        HashMap map2 = this.f13103d;
        androidx.lifecycle.Z z9 = (androidx.lifecycle.Z) map2.get(str);
        if (z9 != null) {
            z9.a();
            map2.remove(str);
        }
    }

    public final void h(ComponentCallbacksC1023x componentCallbacksC1023x) {
        if (this.f13106g) {
            if (P.L(2)) {
                Log.v("FragmentManager", "Ignoring removeRetainedFragment as the state is already saved");
            }
        } else {
            if (this.f13101b.remove(componentCallbacksC1023x.f13297u) == null || !P.L(2)) {
                return;
            }
            Log.v("FragmentManager", "Updating retained Fragments: Removed " + componentCallbacksC1023x);
        }
    }

    public final int hashCode() {
        return this.f13103d.hashCode() + ((this.f13102c.hashCode() + (this.f13101b.hashCode() * 31)) * 31);
    }

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