package G;

import I2.InterfaceC0339x;
import I2.Y;
import T0.C0606q;
import android.content.Context;
import androidx.compose.runtime.PrimitiveSnapshotStateKt;
import androidx.compose.runtime.SnapshotIntStateKt;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import x4.AbstractC3251q;

/* JADX INFO: loaded from: classes.dex */
public final class B implements n5.e {

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

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

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

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

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public Object f1648e;

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

    public B(Context context, InterfaceC0339x interfaceC0339x, T.p pVar) {
        this.f1645b = context;
        this.f1646c = interfaceC0339x;
        this.f1647d = pVar;
        this.f1648e = new Y(this, true);
        this.f1649f = new Y(this, false);
    }

    public static void e(B b5, Q4.c cVar, Q4.c concreteClass, g5.a concreteSerializer) {
        Object next;
        b5.getClass();
        kotlin.jvm.internal.o.h(concreteClass, "concreteClass");
        kotlin.jvm.internal.o.h(concreteSerializer, "concreteSerializer");
        String strA = concreteSerializer.getDescriptor().a();
        HashMap map = (HashMap) b5.f1646c;
        Object map2 = map.get(cVar);
        if (map2 == null) {
            map2 = new HashMap();
            map.put(cVar, map2);
        }
        Map map3 = (Map) map2;
        g5.a aVar = (g5.a) map3.get(concreteClass);
        HashMap map4 = (HashMap) b5.f1648e;
        Object map5 = map4.get(cVar);
        if (map5 == null) {
            map5 = new HashMap();
            map4.put(cVar, map5);
        }
        Map map6 = (Map) map5;
        if (aVar != null) {
            if (!aVar.equals(concreteSerializer)) {
                throw new n5.d("Serializer for " + concreteClass + " already registered in the scope of " + cVar);
            }
        }
        g5.a aVar2 = (g5.a) map6.get(strA);
        if (aVar2 == null) {
            map3.put(concreteClass, concreteSerializer);
            map6.put(strA, concreteSerializer);
            return;
        }
        Object obj = map.get(cVar);
        kotlin.jvm.internal.o.e(obj);
        Iterator it = ((Iterable) AbstractC3251q.W(((Map) obj).entrySet()).f2102b).iterator();
        while (true) {
            if (!it.hasNext()) {
                next = null;
                break;
            } else {
                next = it.next();
                if (((Map.Entry) next).getValue() == aVar2) {
                    break;
                }
            }
        }
        throw new IllegalArgumentException("Multiple polymorphic serializers for base class '" + cVar + "' have the same serial name '" + strA + "': '" + concreteClass + "' and '" + ((Map.Entry) next) + '\'');
    }

    public static void h(B b5, Q4.c forClass, n5.c cVar) {
        b5.getClass();
        kotlin.jvm.internal.o.h(forClass, "forClass");
        HashMap map = (HashMap) b5.f1645b;
        n5.c cVar2 = (n5.c) map.get(forClass);
        if (cVar2 != null && !cVar2.equals(cVar)) {
            throw new n5.d("Contextual serializer or serializer provider for " + forClass + " already registered in this module");
        }
        map.put(forClass, cVar);
        if (k5.P.g(forClass)) {
            b5.f1644a = true;
        }
    }

    @Override // n5.e
    public void a(Q4.c cVar, J4.c cVar2) {
        HashMap map = (HashMap) this.f1647d;
        J4.c cVar3 = (J4.c) map.get(cVar);
        if (cVar3 == null || cVar3.equals(cVar2)) {
            map.put(cVar, cVar2);
            return;
        }
        throw new IllegalArgumentException("Default serializers provider for " + cVar + " is already registered: " + cVar3);
    }

    @Override // n5.e
    public void b(Q4.c cVar, g5.a aVar) {
        h(this, cVar, new n5.a(aVar));
    }

    @Override // n5.e
    public void c(Q4.c cVar, Q4.c cVar2, g5.a aVar) {
        e(this, cVar, cVar2, aVar);
    }

    public C0606q d() {
        return new C0606q((HashMap) this.f1645b, (HashMap) this.f1646c, (HashMap) this.f1647d, (HashMap) this.f1648e, (HashMap) this.f1649f, this.f1644a);
    }

    @Override // n5.e
    public void f(Q4.c cVar, J4.c cVar2) {
        HashMap map = (HashMap) this.f1649f;
        J4.c cVar3 = (J4.c) map.get(cVar);
        if (cVar3 == null || cVar3.equals(cVar2)) {
            map.put(cVar, cVar2);
            return;
        }
        throw new IllegalArgumentException("Default deserializers provider for " + cVar + " is already registered: " + cVar3);
    }

    @Override // n5.e
    public void g(Q4.c kClass, J4.c cVar) {
        kotlin.jvm.internal.o.h(kClass, "kClass");
        h(this, kClass, new n5.b(cVar));
    }

    public B(int i6, float f6, L l) {
        this.f1645b = l;
        this.f1646c = SnapshotIntStateKt.mutableIntStateOf(i6);
        this.f1647d = PrimitiveSnapshotStateKt.mutableFloatStateOf(f6);
        this.f1649f = new F.K(i6, 30, 100);
    }

    public B() {
        this.f1645b = new HashMap();
        this.f1646c = new HashMap();
        this.f1647d = new HashMap();
        this.f1648e = new HashMap();
        this.f1649f = new HashMap();
    }
}
