package U1;

import O1.C0225a;
import P6.g;
import android.os.Bundle;
import android.view.View;
import androidx.lifecycle.EnumC0509n;
import androidx.lifecycle.InterfaceC0504i;
import androidx.lifecycle.InterfaceC0514t;
import androidx.lifecycle.InterfaceC0516v;
import androidx.lifecycle.P;
import androidx.lifecycle.Q;
import androidx.lifecycle.W;
import androidx.lifecycle.Z;
import androidx.lifecycle.a0;
import d5.AbstractC0844a;
import h0.ComponentCallbacksC1023x;
import java.lang.reflect.Constructor;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import n4.u0;
import v6.h;

/* JADX INFO: loaded from: classes.dex */
public final class b implements InterfaceC0514t {

    /* JADX INFO: renamed from: q, reason: collision with root package name */
    public final /* synthetic */ int f6677q;

    /* JADX INFO: renamed from: r, reason: collision with root package name */
    public final Object f6678r;

    public /* synthetic */ b(int i, Object obj) {
        this.f6677q = i;
        this.f6678r = obj;
    }

    @Override // androidx.lifecycle.InterfaceC0514t
    public final void j(InterfaceC0516v interfaceC0516v, EnumC0509n enumC0509n) {
        View view;
        switch (this.f6677q) {
            case u0.f15495q /* 0 */:
                if (enumC0509n != EnumC0509n.ON_CREATE) {
                    throw new AssertionError("Next event must be ON_CREATE");
                }
                interfaceC0516v.C().y(this);
                e eVar = (e) this.f6678r;
                Bundle bundleH = eVar.h().h("androidx.savedstate.Restarter");
                if (bundleH == null) {
                    return;
                }
                ArrayList<String> stringArrayList = bundleH.getStringArrayList("classes_to_restore");
                if (stringArrayList == null) {
                    throw new IllegalStateException("SavedState with restored state for the component \"androidx.savedstate.Restarter\" must contain list of strings by the key \"classes_to_restore\"");
                }
                int size = stringArrayList.size();
                int i = 0;
                while (i < size) {
                    String str = stringArrayList.get(i);
                    i++;
                    String str2 = str;
                    try {
                        Class<? extends U> clsAsSubclass = Class.forName(str2, false, b.class.getClassLoader()).asSubclass(c.class);
                        g.b(clsAsSubclass);
                        try {
                            Constructor declaredConstructor = clsAsSubclass.getDeclaredConstructor(null);
                            declaredConstructor.setAccessible(true);
                            try {
                                Object objNewInstance = declaredConstructor.newInstance(null);
                                g.b(objNewInstance);
                                if (!(eVar instanceof a0)) {
                                    throw new IllegalStateException(("Internal error: OnRecreation should be registered only on components that implement ViewModelStoreOwner. Received owner: " + eVar).toString());
                                }
                                Z zR = ((a0) eVar).r();
                                C0225a c0225aH = eVar.h();
                                zR.getClass();
                                LinkedHashMap linkedHashMap = zR.f8821a;
                                for (String str3 : new HashSet(linkedHashMap.keySet())) {
                                    g.e(str3, "key");
                                    W w4 = (W) linkedHashMap.get(str3);
                                    if (w4 != null) {
                                        P.a(w4, c0225aH, eVar.C());
                                    }
                                }
                                if (!new HashSet(linkedHashMap.keySet()).isEmpty()) {
                                    c0225aH.u();
                                }
                            } catch (Exception e8) {
                                throw new RuntimeException(AbstractC0844a.x("Failed to instantiate ", str2), e8);
                            }
                        } catch (NoSuchMethodException e9) {
                            throw new IllegalStateException("Class " + clsAsSubclass.getSimpleName() + " must have default constructor in order to be automatically recreated", e9);
                        }
                    } catch (ClassNotFoundException e10) {
                        throw new RuntimeException(I1.a.p("Class ", str2, " wasn't found"), e10);
                    }
                }
                return;
            case 1:
                new HashMap();
                InterfaceC0504i[] interfaceC0504iArr = (InterfaceC0504i[]) this.f6678r;
                if (interfaceC0504iArr.length > 0) {
                    InterfaceC0504i interfaceC0504i = interfaceC0504iArr[0];
                    throw null;
                }
                if (interfaceC0504iArr.length <= 0) {
                    return;
                }
                InterfaceC0504i interfaceC0504i2 = interfaceC0504iArr[0];
                throw null;
            case 2:
                if (enumC0509n != EnumC0509n.ON_CREATE) {
                    throw new IllegalStateException(("Next event must be ON_CREATE, it was " + enumC0509n).toString());
                }
                interfaceC0516v.C().y(this);
                ((Q) this.f6678r).b();
                return;
            case 3:
                if (enumC0509n != EnumC0509n.ON_STOP || (view = ((ComponentCallbacksC1023x) this.f6678r).X) == null) {
                    return;
                }
                view.cancelPendingInputEvents();
                return;
            default:
                if (enumC0509n == EnumC0509n.ON_DESTROY) {
                    h hVar = (h) this.f6678r;
                    hVar.getClass();
                    hVar.f18125a = null;
                    hVar.f18126b = null;
                    return;
                }
                return;
        }
    }
}
