package O3;

import T3.X;
import java.security.GeneralSecurityException;
import java.util.HashMap;
import java.util.concurrent.atomic.AtomicReference;

/* JADX INFO: loaded from: classes.dex */
public final class k {

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public static final k f5155b = new k();

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final AtomicReference f5156a = new AtomicReference(new u(new C2.a(5)));

    public final H3.b a(q qVar) {
        AtomicReference atomicReference = this.f5156a;
        u uVar = (u) atomicReference.get();
        uVar.getClass();
        V3.a aVar = (V3.a) qVar.f5166b;
        if (!uVar.f5177b.containsKey(new s(q.class, aVar))) {
            try {
                g gVar = new g();
                ((X) qVar.f5168d).ordinal();
                return gVar;
            } catch (GeneralSecurityException e8) {
                throw new A6.b("Creating a LegacyProtoKey failed", e8);
            }
        }
        u uVar2 = (u) atomicReference.get();
        uVar2.getClass();
        s sVar = new s(q.class, aVar);
        HashMap map = uVar2.f5177b;
        if (map.containsKey(sVar)) {
            return ((a) map.get(sVar)).f5142b.c(qVar);
        }
        throw new GeneralSecurityException("No Key Parser for requested key type " + sVar + " available");
    }

    public final synchronized void b(a aVar) {
        C2.a aVar2 = new C2.a((u) this.f5156a.get());
        aVar2.C(aVar);
        this.f5156a.set(new u(aVar2));
    }

    public final synchronized void c(c cVar) {
        C2.a aVar = new C2.a((u) this.f5156a.get());
        aVar.D(cVar);
        this.f5156a.set(new u(aVar));
    }

    public final synchronized void d(l lVar) {
        C2.a aVar = new C2.a((u) this.f5156a.get());
        aVar.E(lVar);
        this.f5156a.set(new u(aVar));
    }

    public final synchronized void e(m mVar) {
        C2.a aVar = new C2.a((u) this.f5156a.get());
        aVar.F(mVar);
        this.f5156a.set(new u(aVar));
    }
}
