package c5; import java.lang.reflect.Field; import java.lang.reflect.Type; import java.util.ArrayList; import java.util.Collections; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import z4.o; import z4.q; import z4.r; /* loaded from: classes2.dex */ public final class i implements r { /* renamed from: a, reason: collision with root package name */ private final b5.c f3757a; /* renamed from: b, reason: collision with root package name */ private final z4.d f3758b; /* renamed from: c, reason: collision with root package name */ private final b5.d f3759c; /* renamed from: d, reason: collision with root package name */ private final d f3760d; /* renamed from: e, reason: collision with root package name */ private final e5.b f3761e = e5.b.a(); class a extends c { /* renamed from: d, reason: collision with root package name */ final /* synthetic */ Field f3762d; /* renamed from: e, reason: collision with root package name */ final /* synthetic */ boolean f3763e; /* renamed from: f, reason: collision with root package name */ final /* synthetic */ q f3764f; /* renamed from: g, reason: collision with root package name */ final /* synthetic */ z4.e f3765g; /* renamed from: h, reason: collision with root package name */ final /* synthetic */ f5.a f3766h; /* renamed from: i, reason: collision with root package name */ final /* synthetic */ boolean f3767i; /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */ a(String str, boolean z10, boolean z11, Field field, boolean z12, q qVar, z4.e eVar, f5.a aVar, boolean z13) { super(str, z10, z11); this.f3762d = field; this.f3763e = z12; this.f3764f = qVar; this.f3765g = eVar; this.f3766h = aVar; this.f3767i = z13; } @Override // c5.i.c void a(g5.a aVar, Object obj) { Object b10 = this.f3764f.b(aVar); if (b10 == null && this.f3767i) { return; } this.f3762d.set(obj, b10); } @Override // c5.i.c void b(g5.c cVar, Object obj) { (this.f3763e ? this.f3764f : new l(this.f3765g, this.f3764f, this.f3766h.e())).d(cVar, this.f3762d.get(obj)); } @Override // c5.i.c public boolean c(Object obj) { return this.f3772b && this.f3762d.get(obj) != obj; } } public static final class b extends q { /* renamed from: a, reason: collision with root package name */ private final b5.i f3769a; /* renamed from: b, reason: collision with root package name */ private final Map f3770b; b(b5.i iVar, Map map) { this.f3769a = iVar; this.f3770b = map; } @Override // z4.q public Object b(g5.a aVar) { if (aVar.F0() == g5.b.NULL) { aVar.w0(); return null; } Object a10 = this.f3769a.a(); try { aVar.z(); while (aVar.Y()) { c cVar = (c) this.f3770b.get(aVar.r0()); if (cVar != null && cVar.f3773c) { cVar.a(aVar, a10); } aVar.P0(); } aVar.R(); return a10; } catch (IllegalAccessException e10) { throw new AssertionError(e10); } catch (IllegalStateException e11) { throw new o(e11); } } @Override // z4.q public void d(g5.c cVar, Object obj) { if (obj == null) { cVar.j0(); return; } cVar.I(); try { for (c cVar2 : this.f3770b.values()) { if (cVar2.c(obj)) { cVar.d0(cVar2.f3771a); cVar2.b(cVar, obj); } } cVar.R(); } catch (IllegalAccessException e10) { throw new AssertionError(e10); } } } static abstract class c { /* renamed from: a, reason: collision with root package name */ final String f3771a; /* renamed from: b, reason: collision with root package name */ final boolean f3772b; /* renamed from: c, reason: collision with root package name */ final boolean f3773c; protected c(String str, boolean z10, boolean z11) { this.f3771a = str; this.f3772b = z10; this.f3773c = z11; } abstract void a(g5.a aVar, Object obj); abstract void b(g5.c cVar, Object obj); abstract boolean c(Object obj); } public i(b5.c cVar, z4.d dVar, b5.d dVar2, d dVar3) { this.f3757a = cVar; this.f3758b = dVar; this.f3759c = dVar2; this.f3760d = dVar3; } private c b(z4.e eVar, Field field, String str, f5.a aVar, boolean z10, boolean z11) { boolean a10 = b5.k.a(aVar.c()); a5.b bVar = (a5.b) field.getAnnotation(a5.b.class); q b10 = bVar != null ? this.f3760d.b(this.f3757a, eVar, aVar, bVar) : null; boolean z12 = b10 != null; if (b10 == null) { b10 = eVar.m(aVar); } return new a(str, z10, z11, field, z12, b10, eVar, aVar, a10); } static boolean d(Field field, boolean z10, b5.d dVar) { return (dVar.d(field.getType(), z10) || dVar.g(field, z10)) ? false : true; } private Map e(z4.e eVar, f5.a aVar, Class cls) { LinkedHashMap linkedHashMap = new LinkedHashMap(); if (cls.isInterface()) { return linkedHashMap; } Type e10 = aVar.e(); f5.a aVar2 = aVar; Class cls2 = cls; while (cls2 != Object.class) { Field[] declaredFields = cls2.getDeclaredFields(); int length = declaredFields.length; boolean z10 = false; int i10 = 0; while (i10 < length) { Field field = declaredFields[i10]; boolean c10 = c(field, true); boolean c11 = c(field, z10); if (c10 || c11) { this.f3761e.b(field); Type p10 = b5.b.p(aVar2.e(), cls2, field.getGenericType()); List f10 = f(field); int size = f10.size(); c cVar = null; int i11 = 0; while (i11 < size) { String str = (String) f10.get(i11); boolean z11 = i11 != 0 ? false : c10; int i12 = i11; c cVar2 = cVar; int i13 = size; List list = f10; Field field2 = field; cVar = cVar2 == null ? (c) linkedHashMap.put(str, b(eVar, field, str, f5.a.b(p10), z11, c11)) : cVar2; i11 = i12 + 1; c10 = z11; f10 = list; size = i13; field = field2; } c cVar3 = cVar; if (cVar3 != null) { throw new IllegalArgumentException(e10 + " declares multiple JSON fields named " + cVar3.f3771a); } } i10++; z10 = false; } aVar2 = f5.a.b(b5.b.p(aVar2.e(), cls2, cls2.getGenericSuperclass())); cls2 = aVar2.c(); } return linkedHashMap; } private List f(Field field) { a5.c cVar = (a5.c) field.getAnnotation(a5.c.class); if (cVar == null) { return Collections.singletonList(this.f3758b.a(field)); } String value = cVar.value(); String[] alternate = cVar.alternate(); if (alternate.length == 0) { return Collections.singletonList(value); } ArrayList arrayList = new ArrayList(alternate.length + 1); arrayList.add(value); for (String str : alternate) { arrayList.add(str); } return arrayList; } @Override // z4.r public q a(z4.e eVar, f5.a aVar) { Class c10 = aVar.c(); if (Object.class.isAssignableFrom(c10)) { return new b(this.f3757a.a(aVar), e(eVar, aVar, c10)); } return null; } public boolean c(Field field, boolean z10) { return d(field, z10, this.f3759c); } }