package n2;

import android.os.Bundle;
import androidx.lifecycle.EnumC1108q;
import androidx.navigation.C1134i;
import e4.C;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.Map;
import p2.C2720a;
import w4.k;

/* JADX INFO: renamed from: n2.h, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes.dex */
public final class C2617h {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final C2720a f21614a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final C2616g f21615b;

    public C2617h(C2720a c2720a) {
        this.f21614a = c2720a;
        this.f21615b = new C2616g(c2720a);
    }

    public final void a() {
        this.f21614a.a();
    }

    public final void b(Bundle bundle) {
        C2720a c2720a = this.f21614a;
        if (!c2720a.f22960a) {
            c2720a.a();
        }
        InterfaceC2618i interfaceC2618i = (InterfaceC2618i) c2720a.f22963d;
        if (interfaceC2618i.getLifecycle().getCurrentState().compareTo(EnumC1108q.f12183d) >= 0) {
            throw new IllegalStateException(("performRestore cannot be called when owner is " + interfaceC2618i.getLifecycle().getCurrentState()).toString());
        }
        if (c2720a.f22961b) {
            throw new IllegalStateException("SavedStateRegistry was already restored.");
        }
        Bundle bundleO = null;
        if (bundle != null && bundle.containsKey("androidx.lifecycle.BundlableSavedStateRegistry.key")) {
            bundleO = AbstractC2612c.o(bundle, "androidx.lifecycle.BundlableSavedStateRegistry.key");
        }
        c2720a.f22967h = bundleO;
        c2720a.f22961b = true;
    }

    public final void c(Bundle bundle) {
        C2720a c2720a = this.f21614a;
        Bundle bundleM = C.m((k[]) Arrays.copyOf(new k[0], 0));
        Bundle bundle2 = (Bundle) c2720a.f22967h;
        if (bundle2 != null) {
            bundleM.putAll(bundle2);
        }
        synchronized (((C1134i) c2720a.f22965f)) {
            for (Map.Entry entry : ((LinkedHashMap) c2720a.f22966g).entrySet()) {
                m1.g.m(bundleM, (String) entry.getKey(), ((InterfaceC2615f) entry.getValue()).a());
            }
        }
        if (bundleM.isEmpty()) {
            return;
        }
        m1.g.m(bundle, "androidx.lifecycle.BundlableSavedStateRegistry.key", bundleM);
    }
}
