package v4;

import androidx.lifecycle.c1;
import androidx.lifecycle.d1;
import androidx.lifecycle.z0;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;

/* loaded from: classes.dex */
public final class k extends z0 implements x {

    /* renamed from: c, reason: collision with root package name */
    public static final b f39135c = new b(null);

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

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

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

        @Override // androidx.lifecycle.c1.c
        public z0 a(Class modelClass) {
            kotlin.jvm.internal.t.g(modelClass, "modelClass");
            return new k();
        }
    }

    /* loaded from: classes.dex */
    public static final class b {
        private b() {
        }

        public /* synthetic */ b(kotlin.jvm.internal.k kVar) {
            this();
        }

        public final k a(d1 viewModelStore) {
            kotlin.jvm.internal.t.g(viewModelStore, "viewModelStore");
            z0 a10 = new c1(viewModelStore, k.f39136d).a(k.class);
            kotlin.jvm.internal.t.f(a10, "get(VM::class.java)");
            return (k) a10;
        }
    }

    /* JADX INFO: Access modifiers changed from: protected */
    @Override // androidx.lifecycle.z0
    public void O() {
        Iterator it = this.f39137b.values().iterator();
        while (it.hasNext()) {
            ((d1) it.next()).a();
        }
        this.f39137b.clear();
    }

    public final void Q(String backStackEntryId) {
        kotlin.jvm.internal.t.g(backStackEntryId, "backStackEntryId");
        d1 d1Var = (d1) this.f39137b.remove(backStackEntryId);
        if (d1Var == null) {
            return;
        }
        d1Var.a();
    }

    @Override // v4.x
    public d1 f(String backStackEntryId) {
        kotlin.jvm.internal.t.g(backStackEntryId, "backStackEntryId");
        d1 d1Var = (d1) this.f39137b.get(backStackEntryId);
        if (d1Var != null) {
            return d1Var;
        }
        d1 d1Var2 = new d1();
        this.f39137b.put(backStackEntryId, d1Var2);
        return d1Var2;
    }

    public String toString() {
        StringBuilder sb2 = new StringBuilder("NavControllerViewModel{");
        sb2.append(Integer.toHexString(System.identityHashCode(this)));
        sb2.append("} ViewModelStores (");
        Iterator it = this.f39137b.keySet().iterator();
        while (it.hasNext()) {
            sb2.append((String) it.next());
            if (it.hasNext()) {
                sb2.append(", ");
            }
        }
        sb2.append(')');
        String sb3 = sb2.toString();
        kotlin.jvm.internal.t.f(sb3, "sb.toString()");
        return sb3;
    }
}
