package c5; import java.lang.reflect.Type; import java.util.ArrayList; import java.util.Map; import z4.n; import z4.o; import z4.q; import z4.r; /* loaded from: classes2.dex */ public final class g implements r { /* renamed from: a, reason: collision with root package name */ private final b5.c f3748a; /* renamed from: b, reason: collision with root package name */ final boolean f3749b; private final class a extends q { /* renamed from: a, reason: collision with root package name */ private final q f3750a; /* renamed from: b, reason: collision with root package name */ private final q f3751b; /* renamed from: c, reason: collision with root package name */ private final b5.i f3752c; public a(z4.e eVar, Type type, q qVar, Type type2, q qVar2, b5.i iVar) { this.f3750a = new l(eVar, qVar, type); this.f3751b = new l(eVar, qVar2, type2); this.f3752c = iVar; } private String e(z4.h hVar) { if (!hVar.n()) { if (hVar.l()) { return "null"; } throw new AssertionError(); } n h10 = hVar.h(); if (h10.s()) { return String.valueOf(h10.p()); } if (h10.q()) { return Boolean.toString(h10.b()); } if (h10.t()) { return h10.j(); } throw new AssertionError(); } @Override // z4.q /* renamed from: f, reason: merged with bridge method [inline-methods] */ public Map b(g5.a aVar) { g5.b F0 = aVar.F0(); if (F0 == g5.b.NULL) { aVar.w0(); return null; } Map map = (Map) this.f3752c.a(); if (F0 == g5.b.BEGIN_ARRAY) { aVar.c(); while (aVar.Y()) { aVar.c(); Object b10 = this.f3750a.b(aVar); if (map.put(b10, this.f3751b.b(aVar)) != null) { throw new o("duplicate key: " + b10); } aVar.P(); } aVar.P(); } else { aVar.z(); while (aVar.Y()) { b5.f.f3187a.a(aVar); Object b11 = this.f3750a.b(aVar); if (map.put(b11, this.f3751b.b(aVar)) != null) { throw new o("duplicate key: " + b11); } } aVar.R(); } return map; } @Override // z4.q /* renamed from: g, reason: merged with bridge method [inline-methods] */ public void d(g5.c cVar, Map map) { if (map == null) { cVar.j0(); return; } if (!g.this.f3749b) { cVar.I(); for (Map.Entry entry : map.entrySet()) { cVar.d0(String.valueOf(entry.getKey())); this.f3751b.d(cVar, entry.getValue()); } cVar.R(); return; } ArrayList arrayList = new ArrayList(map.size()); ArrayList arrayList2 = new ArrayList(map.size()); int i10 = 0; boolean z10 = false; for (Map.Entry entry2 : map.entrySet()) { z4.h c10 = this.f3750a.c(entry2.getKey()); arrayList.add(c10); arrayList2.add(entry2.getValue()); z10 |= c10.k() || c10.m(); } if (!z10) { cVar.I(); int size = arrayList.size(); while (i10 < size) { cVar.d0(e((z4.h) arrayList.get(i10))); this.f3751b.d(cVar, arrayList2.get(i10)); i10++; } cVar.R(); return; } cVar.G(); int size2 = arrayList.size(); while (i10 < size2) { cVar.G(); b5.l.b((z4.h) arrayList.get(i10), cVar); this.f3751b.d(cVar, arrayList2.get(i10)); cVar.P(); i10++; } cVar.P(); } } public g(b5.c cVar, boolean z10) { this.f3748a = cVar; this.f3749b = z10; } private q b(z4.e eVar, Type type) { return (type == Boolean.TYPE || type == Boolean.class) ? m.f3786f : eVar.m(f5.a.b(type)); } @Override // z4.r public q a(z4.e eVar, f5.a aVar) { Type e10 = aVar.e(); if (!Map.class.isAssignableFrom(aVar.c())) { return null; } Type[] j10 = b5.b.j(e10, b5.b.k(e10)); return new a(eVar, j10[0], b(eVar, j10[0]), j10[1], eVar.m(f5.a.b(j10[1])), this.f3748a.a(aVar)); } }