package androidx.lifecycle;

import android.app.Application;
import java.lang.reflect.InvocationTargetException;
import s4.a;
import t4.g;

/* loaded from: classes.dex */
public class c1 {

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

    /* renamed from: c, reason: collision with root package name */
    public static final a.b f4775c = g.a.f36169a;

    /* renamed from: a, reason: collision with root package name */
    private final s4.d f4776a;

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

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

        public final c1 a(d1 store, c factory, s4.a extras) {
            kotlin.jvm.internal.t.g(store, "store");
            kotlin.jvm.internal.t.g(factory, "factory");
            kotlin.jvm.internal.t.g(extras, "extras");
            return new c1(store, factory, extras);
        }
    }

    /* loaded from: classes.dex */
    public interface c {

        /* renamed from: a, reason: collision with root package name */
        public static final a f4781a = a.f4782a;

        /* loaded from: classes.dex */
        public static final class a {

            /* renamed from: a, reason: collision with root package name */
            static final /* synthetic */ a f4782a = new a();

            private a() {
            }
        }

        default z0 a(Class modelClass) {
            kotlin.jvm.internal.t.g(modelClass, "modelClass");
            return t4.g.f36168a.d();
        }

        default z0 b(kn.d modelClass, s4.a extras) {
            kotlin.jvm.internal.t.g(modelClass, "modelClass");
            kotlin.jvm.internal.t.g(extras, "extras");
            return c(cn.a.b(modelClass), extras);
        }

        default z0 c(Class modelClass, s4.a extras) {
            kotlin.jvm.internal.t.g(modelClass, "modelClass");
            kotlin.jvm.internal.t.g(extras, "extras");
            return a(modelClass);
        }
    }

    /* loaded from: classes.dex */
    public static class d implements c {

        /* renamed from: c, reason: collision with root package name */
        private static d f4784c;

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

        /* renamed from: d, reason: collision with root package name */
        public static final a.b f4785d = g.a.f36169a;

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

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

            public final d a() {
                if (d.f4784c == null) {
                    d.f4784c = new d();
                }
                d dVar = d.f4784c;
                kotlin.jvm.internal.t.d(dVar);
                return dVar;
            }
        }

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

        @Override // androidx.lifecycle.c1.c
        public z0 b(kn.d modelClass, s4.a extras) {
            kotlin.jvm.internal.t.g(modelClass, "modelClass");
            kotlin.jvm.internal.t.g(extras, "extras");
            return c(cn.a.b(modelClass), extras);
        }

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

    /* loaded from: classes.dex */
    public static class e {
        public abstract void d(z0 z0Var);
    }

    /* JADX WARN: 'this' call moved to the top of the method (can break code semantics) */
    public c1(d1 store, c factory) {
        this(store, factory, null, 4, null);
        kotlin.jvm.internal.t.g(store, "store");
        kotlin.jvm.internal.t.g(factory, "factory");
    }

    public z0 a(Class modelClass) {
        kotlin.jvm.internal.t.g(modelClass, "modelClass");
        return c(cn.a.e(modelClass));
    }

    public z0 b(String key, Class modelClass) {
        kotlin.jvm.internal.t.g(key, "key");
        kotlin.jvm.internal.t.g(modelClass, "modelClass");
        return this.f4776a.a(cn.a.e(modelClass), key);
    }

    public final z0 c(kn.d modelClass) {
        kotlin.jvm.internal.t.g(modelClass, "modelClass");
        return s4.d.b(this.f4776a, modelClass, null, 2, null);
    }

    /* loaded from: classes.dex */
    public static class a extends d {

        /* renamed from: g, reason: collision with root package name */
        private static a f4778g;

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

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

        /* renamed from: h, reason: collision with root package name */
        public static final a.b f4779h = new C0117a();

        /* renamed from: androidx.lifecycle.c1$a$a, reason: collision with other inner class name */
        /* loaded from: classes.dex */
        public static final class C0117a implements a.b {
            C0117a() {
            }
        }

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

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

            public final a a(Application application) {
                kotlin.jvm.internal.t.g(application, "application");
                if (a.f4778g == null) {
                    a.f4778g = new a(application);
                }
                a aVar = a.f4778g;
                kotlin.jvm.internal.t.d(aVar);
                return aVar;
            }
        }

        private a(Application application, int i10) {
            this.f4780e = application;
        }

        private final z0 h(Class cls, Application application) {
            if (!androidx.lifecycle.b.class.isAssignableFrom(cls)) {
                return super.a(cls);
            }
            try {
                z0 z0Var = (z0) cls.getConstructor(Application.class).newInstance(application);
                kotlin.jvm.internal.t.f(z0Var, "{\n                try {\n…          }\n            }");
                return z0Var;
            } catch (IllegalAccessException e10) {
                throw new RuntimeException("Cannot create an instance of " + cls, e10);
            } catch (InstantiationException e11) {
                throw new RuntimeException("Cannot create an instance of " + cls, e11);
            } catch (NoSuchMethodException e12) {
                throw new RuntimeException("Cannot create an instance of " + cls, e12);
            } catch (InvocationTargetException e13) {
                throw new RuntimeException("Cannot create an instance of " + cls, e13);
            }
        }

        @Override // androidx.lifecycle.c1.d, androidx.lifecycle.c1.c
        public z0 a(Class modelClass) {
            kotlin.jvm.internal.t.g(modelClass, "modelClass");
            Application application = this.f4780e;
            if (application != null) {
                return h(modelClass, application);
            }
            throw new UnsupportedOperationException("AndroidViewModelFactory constructed with empty constructor works only with create(modelClass: Class<T>, extras: CreationExtras).");
        }

        @Override // androidx.lifecycle.c1.d, androidx.lifecycle.c1.c
        public z0 c(Class modelClass, s4.a extras) {
            kotlin.jvm.internal.t.g(modelClass, "modelClass");
            kotlin.jvm.internal.t.g(extras, "extras");
            if (this.f4780e != null) {
                return a(modelClass);
            }
            Application application = (Application) extras.a(f4779h);
            if (application != null) {
                return h(modelClass, application);
            }
            if (androidx.lifecycle.b.class.isAssignableFrom(modelClass)) {
                throw new IllegalArgumentException("CreationExtras must have an application by `APPLICATION_KEY`");
            }
            return super.a(modelClass);
        }

        public a() {
            this(null, 0);
        }

        /* JADX WARN: 'this' call moved to the top of the method (can break code semantics) */
        public a(Application application) {
            this(application, 0);
            kotlin.jvm.internal.t.g(application, "application");
        }
    }

    private c1(s4.d dVar) {
        this.f4776a = dVar;
    }

    public /* synthetic */ c1(d1 d1Var, c cVar, s4.a aVar, int i10, kotlin.jvm.internal.k kVar) {
        this(d1Var, cVar, (i10 & 4) != 0 ? a.C0830a.f35416b : aVar);
    }

    /* JADX WARN: 'this' call moved to the top of the method (can break code semantics) */
    public c1(d1 store, c factory, s4.a defaultCreationExtras) {
        this(new s4.d(store, factory, defaultCreationExtras));
        kotlin.jvm.internal.t.g(store, "store");
        kotlin.jvm.internal.t.g(factory, "factory");
        kotlin.jvm.internal.t.g(defaultCreationExtras, "defaultCreationExtras");
    }

    /* JADX WARN: Illegal instructions before constructor call */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public c1(e1 owner) {
        this(r0, r1.b(owner), r1.a(owner));
        kotlin.jvm.internal.t.g(owner, "owner");
        d1 viewModelStore = owner.getViewModelStore();
        t4.g gVar = t4.g.f36168a;
    }

    /* JADX WARN: 'this' call moved to the top of the method (can break code semantics) */
    public c1(e1 owner, c factory) {
        this(owner.getViewModelStore(), factory, t4.g.f36168a.a(owner));
        kotlin.jvm.internal.t.g(owner, "owner");
        kotlin.jvm.internal.t.g(factory, "factory");
    }
}
