package l3;

import i3.C0636d;
import i3.C0639g;
import java.io.IOException;
import java.lang.reflect.Array;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import q3.C0957b;

/* JADX INFO: renamed from: l3.b, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes.dex */
public final class C0830b extends i3.k {

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public static final C0829a f8905d = new C0829a(0);

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final /* synthetic */ int f8906a = 0;

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

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

    public C0830b(C0636d c0636d, i3.k kVar, Class cls) {
        this.f8907b = new com.dexterous.flutterlocalnotifications.m(c0636d, kVar, cls);
        this.f8908c = cls;
    }

    @Override // i3.k
    public final Object a(C0957b c0957b) throws IOException {
        switch (this.f8906a) {
            case 0:
                if (c0957b.G() == 9) {
                    c0957b.C();
                    return null;
                }
                ArrayList arrayList = new ArrayList();
                c0957b.a();
                while (c0957b.t()) {
                    arrayList.add(((i3.k) ((com.dexterous.flutterlocalnotifications.m) this.f8907b).f4788c).a(c0957b));
                }
                c0957b.k();
                int size = arrayList.size();
                Class cls = (Class) this.f8908c;
                if (!cls.isPrimitive()) {
                    return arrayList.toArray((Object[]) Array.newInstance((Class<?>) cls, size));
                }
                Object objNewInstance = Array.newInstance((Class<?>) cls, size);
                for (int i = 0; i < size; i++) {
                    Array.set(objNewInstance, i, arrayList.get(i));
                }
                return objNewInstance;
            case 1:
                if (c0957b.G() == 9) {
                    c0957b.C();
                    return null;
                }
                Collection collection = (Collection) ((k3.p) this.f8908c).z();
                c0957b.a();
                while (c0957b.t()) {
                    collection.add(((i3.k) ((com.dexterous.flutterlocalnotifications.m) this.f8907b).f4788c).a(c0957b));
                }
                c0957b.k();
                return collection;
            default:
                Object objA = ((v) this.f8907b).f8966m.a(c0957b);
                if (objA != null) {
                    Class cls2 = (Class) this.f8908c;
                    if (!cls2.isInstance(objA)) {
                        throw new C0639g("Expected a " + cls2.getName() + " but was " + objA.getClass().getName() + "; at path " + c0957b.r());
                    }
                }
                return objA;
        }
    }

    @Override // i3.k
    public final void b(q3.c cVar, Object obj) throws IOException {
        switch (this.f8906a) {
            case 0:
                if (obj == null) {
                    cVar.o();
                } else {
                    cVar.e();
                    int length = Array.getLength(obj);
                    for (int i = 0; i < length; i++) {
                        ((com.dexterous.flutterlocalnotifications.m) this.f8907b).b(cVar, Array.get(obj, i));
                    }
                    cVar.k();
                }
                break;
            case 1:
                Collection collection = (Collection) obj;
                if (collection == null) {
                    cVar.o();
                } else {
                    cVar.e();
                    Iterator it = collection.iterator();
                    while (it.hasNext()) {
                        ((com.dexterous.flutterlocalnotifications.m) this.f8907b).b(cVar, it.next());
                    }
                    cVar.k();
                }
                break;
            default:
                ((v) this.f8907b).f8966m.b(cVar, obj);
                break;
        }
    }

    public C0830b(C0636d c0636d, Type type, i3.k kVar, k3.p pVar) {
        this.f8907b = new com.dexterous.flutterlocalnotifications.m(c0636d, kVar, type);
        this.f8908c = pVar;
    }

    public C0830b(v vVar, Class cls) {
        this.f8907b = vVar;
        this.f8908c = cls;
    }
}
