package d.q;

import android.annotation.SuppressLint;
import android.os.Bundle;
import androidx.savedstate.Recreator;

/* JADX INFO: loaded from: classes.dex */
@SuppressLint({"RestrictedApi"})
public final class a {

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public Bundle f3356b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public boolean f3357c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public Recreator.a f3358d;
    public d.c.a.b.b<String, b> a = new d.c.a.b.b<>();

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public boolean f3359e = true;

    /* JADX INFO: renamed from: d.q.a$a, reason: collision with other inner class name */
    public interface InterfaceC0046a {
        void a(c cVar);
    }

    public interface b {
        Bundle a();
    }

    public Bundle a(String str) {
        if (!this.f3357c) {
            throw new IllegalStateException("You can consumeRestoredStateForKey only after super.onCreate of corresponding component");
        }
        Bundle bundle = this.f3356b;
        if (bundle == null) {
            return null;
        }
        Bundle bundle2 = bundle.getBundle(str);
        this.f3356b.remove(str);
        if (this.f3356b.isEmpty()) {
            this.f3356b = null;
        }
        return bundle2;
    }

    public void b(String str, b bVar) {
        if (this.a.d(str, bVar) != null) {
            throw new IllegalArgumentException("SavedStateProvider with the given key is already registered");
        }
    }

    public void c(Class<? extends InterfaceC0046a> cls) {
        if (!this.f3359e) {
            throw new IllegalStateException("Can not perform this action after onSaveInstanceState");
        }
        if (this.f3358d == null) {
            this.f3358d = new Recreator.a(this);
        }
        try {
            cls.getDeclaredConstructor(new Class[0]);
            Recreator.a aVar = this.f3358d;
            aVar.a.add(cls.getName());
        } catch (NoSuchMethodException e2) {
            StringBuilder sbF = g.a.a.a.a.F("Class");
            sbF.append(cls.getSimpleName());
            sbF.append(" must have default constructor in order to be automatically recreated");
            throw new IllegalArgumentException(sbF.toString(), e2);
        }
    }
}
