package com.google.ads.interactivemedia.v3.internal;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

/* JADX INFO: loaded from: classes2.dex */
final class zzadp {
    private static final zzadp zzb = new zzadp(true);
    final zzagd zza = new zzafw();
    private boolean zzc;
    private boolean zzd;

    private zzadp() {
    }

    public static int zza(zzags zzagsVar, int i10, Object obj) {
        zzadf.zzz(i10 << 3);
        if (zzags.zzj == null) {
            zzafb zzafbVar = (zzafb) obj;
            byte[] bArr = zzaee.zzb;
            if (zzafbVar instanceof zzaci) {
                throw null;
            }
        }
        zzagt zzagtVar = zzagt.INT;
        throw null;
    }

    public static int zzb(zzado zzadoVar, Object obj) {
        zzags zzagsVarZzb = zzadoVar.zzb();
        int iZza = zzadoVar.zza();
        if (!zzadoVar.zze()) {
            return zza(zzagsVarZzb, iZza, obj);
        }
        List list = (List) obj;
        int size = list.size();
        if (!zzadoVar.zzd()) {
            int iZza2 = 0;
            for (int i10 = 0; i10 < size; i10++) {
                iZza2 += zza(zzagsVarZzb, iZza, list.get(i10));
            }
            return iZza2;
        }
        if (list.isEmpty()) {
            return 0;
        }
        if (size <= 0) {
            return zzadf.zzz(0) + zzadf.zzz(iZza << 3);
        }
        list.get(0);
        zzags zzagsVar = zzags.zza;
        zzagt zzagtVar = zzagt.INT;
        throw null;
    }

    public static zzadp zzd() {
        return zzb;
    }

    private static boolean zzi(Map.Entry entry) {
        zzado zzadoVar = (zzado) entry.getKey();
        if (zzadoVar.zzc() != zzagt.MESSAGE) {
            return true;
        }
        if (!zzadoVar.zze()) {
            return zzj(entry.getValue());
        }
        List list = (List) entry.getValue();
        int size = list.size();
        for (int i10 = 0; i10 < size; i10++) {
            if (!zzj(list.get(i10))) {
                return false;
            }
        }
        return true;
    }

    private static boolean zzj(Object obj) {
        if (obj instanceof zzafc) {
            return ((zzafc) obj).zzaT();
        }
        if (obj instanceof zzael) {
            return true;
        }
        throw new IllegalArgumentException("Wrong object type used with protocol message reflection.");
    }

    private static final int zzk(Map.Entry entry) {
        int i10;
        int iZzz;
        int iA;
        zzado zzadoVar = (zzado) entry.getKey();
        Object value = entry.getValue();
        if (zzadoVar.zzc() != zzagt.MESSAGE || zzadoVar.zze() || zzadoVar.zzd()) {
            return zzb(zzadoVar, value);
        }
        if (value instanceof zzael) {
            int iZza = ((zzado) entry.getKey()).zza();
            int iZzz2 = zzadf.zzz(8);
            i10 = iZzz2 + iZzz2;
            iZzz = zzadf.zzz(iZza) + zzadf.zzz(16);
            int iZzz3 = zzadf.zzz(24);
            int iZza2 = ((zzael) value).zza();
            iA = com.bytedance.sdk.component.adexpress.dynamic.dynamicview.b.a(iZza2, iZza2, iZzz3);
        } else {
            int iZza3 = ((zzado) entry.getKey()).zza();
            int iZzz4 = zzadf.zzz(8);
            i10 = iZzz4 + iZzz4;
            iZzz = zzadf.zzz(iZza3) + zzadf.zzz(16);
            int iZzz5 = zzadf.zzz(24);
            int iZzax = ((zzafb) value).zzax();
            iA = com.bytedance.sdk.component.adexpress.dynamic.dynamicview.b.a(iZzax, iZzax, iZzz5);
        }
        return i10 + iZzz + iA;
    }

    /* JADX WARN: Can't fix incorrect switch cases order, some code will duplicate */
    /* JADX WARN: Removed duplicated region for block: B:32:? A[RETURN, SYNTHETIC] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    private static final void zzl(zzado zzadoVar, Object obj) {
        boolean z10;
        zzadoVar.zzb();
        byte[] bArr = zzaee.zzb;
        obj.getClass();
        zzags zzagsVar = zzags.zza;
        zzagt zzagtVar = zzagt.INT;
        switch (r0.zza()) {
            case INT:
                z10 = obj instanceof Integer;
                if (z10) {
                    return;
                }
                throw new IllegalArgumentException(String.format("Wrong object type used with protocol message reflection.\nField number: %d, field java type: %s, value type: %s\n", Integer.valueOf(zzadoVar.zza()), zzadoVar.zzb().zza(), obj.getClass().getName()));
            case LONG:
                z10 = obj instanceof Long;
                if (z10) {
                }
                throw new IllegalArgumentException(String.format("Wrong object type used with protocol message reflection.\nField number: %d, field java type: %s, value type: %s\n", Integer.valueOf(zzadoVar.zza()), zzadoVar.zzb().zza(), obj.getClass().getName()));
            case FLOAT:
                z10 = obj instanceof Float;
                if (z10) {
                }
                throw new IllegalArgumentException(String.format("Wrong object type used with protocol message reflection.\nField number: %d, field java type: %s, value type: %s\n", Integer.valueOf(zzadoVar.zza()), zzadoVar.zzb().zza(), obj.getClass().getName()));
            case DOUBLE:
                z10 = obj instanceof Double;
                if (z10) {
                }
                throw new IllegalArgumentException(String.format("Wrong object type used with protocol message reflection.\nField number: %d, field java type: %s, value type: %s\n", Integer.valueOf(zzadoVar.zza()), zzadoVar.zzb().zza(), obj.getClass().getName()));
            case BOOLEAN:
                z10 = obj instanceof Boolean;
                if (z10) {
                }
                throw new IllegalArgumentException(String.format("Wrong object type used with protocol message reflection.\nField number: %d, field java type: %s, value type: %s\n", Integer.valueOf(zzadoVar.zza()), zzadoVar.zzb().zza(), obj.getClass().getName()));
            case STRING:
                z10 = obj instanceof String;
                if (z10) {
                }
                throw new IllegalArgumentException(String.format("Wrong object type used with protocol message reflection.\nField number: %d, field java type: %s, value type: %s\n", Integer.valueOf(zzadoVar.zza()), zzadoVar.zzb().zza(), obj.getClass().getName()));
            case BYTE_STRING:
                if ((obj instanceof zzacw) || (obj instanceof byte[])) {
                    return;
                }
                throw new IllegalArgumentException(String.format("Wrong object type used with protocol message reflection.\nField number: %d, field java type: %s, value type: %s\n", Integer.valueOf(zzadoVar.zza()), zzadoVar.zzb().zza(), obj.getClass().getName()));
            case ENUM:
                if ((obj instanceof Integer) || (obj instanceof zzaea)) {
                    return;
                }
                throw new IllegalArgumentException(String.format("Wrong object type used with protocol message reflection.\nField number: %d, field java type: %s, value type: %s\n", Integer.valueOf(zzadoVar.zza()), zzadoVar.zzb().zza(), obj.getClass().getName()));
            case MESSAGE:
                if ((obj instanceof zzafb) || (obj instanceof zzael)) {
                    return;
                }
                throw new IllegalArgumentException(String.format("Wrong object type used with protocol message reflection.\nField number: %d, field java type: %s, value type: %s\n", Integer.valueOf(zzadoVar.zza()), zzadoVar.zzb().zza(), obj.getClass().getName()));
            default:
                throw new IllegalArgumentException(String.format("Wrong object type used with protocol message reflection.\nField number: %d, field java type: %s, value type: %s\n", Integer.valueOf(zzadoVar.zza()), zzadoVar.zzb().zza(), obj.getClass().getName()));
        }
    }

    public final /* bridge */ /* synthetic */ Object clone() throws CloneNotSupportedException {
        zzadp zzadpVar = new zzadp();
        int iZzc = this.zza.zzc();
        for (int i10 = 0; i10 < iZzc; i10++) {
            Map.Entry entryZzg = this.zza.zzg(i10);
            zzadpVar.zzg((zzado) ((zzafx) entryZzg).zza(), entryZzg.getValue());
        }
        for (Map.Entry entry : this.zza.zzd()) {
            zzadpVar.zzg((zzado) entry.getKey(), entry.getValue());
        }
        zzadpVar.zzd = this.zzd;
        return zzadpVar;
    }

    public final boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj instanceof zzadp) {
            return this.zza.equals(((zzadp) obj).zza);
        }
        return false;
    }

    public final int hashCode() {
        return this.zza.hashCode();
    }

    public final int zzc() {
        int iZzc = this.zza.zzc();
        int iZzk = 0;
        for (int i10 = 0; i10 < iZzc; i10++) {
            iZzk += zzk(this.zza.zzg(i10));
        }
        Iterator it = this.zza.zzd().iterator();
        while (it.hasNext()) {
            iZzk += zzk((Map.Entry) it.next());
        }
        return iZzk;
    }

    public final Iterator zze() {
        return this.zza.isEmpty() ? Collections.emptyIterator() : this.zzd ? new zzaek(this.zza.entrySet().iterator()) : this.zza.entrySet().iterator();
    }

    public final void zzf() {
        if (this.zzc) {
            return;
        }
        int iZzc = this.zza.zzc();
        for (int i10 = 0; i10 < iZzc; i10++) {
            Map.Entry entryZzg = this.zza.zzg(i10);
            if (entryZzg.getValue() instanceof zzady) {
                ((zzady) entryZzg.getValue()).zzaK();
            }
        }
        this.zza.zza();
        this.zzc = true;
    }

    public final void zzg(zzado zzadoVar, Object obj) {
        if (!zzadoVar.zze()) {
            zzl(zzadoVar, obj);
        } else {
            if (!(obj instanceof List)) {
                throw new IllegalArgumentException("Wrong object type used with protocol message reflection.");
            }
            List list = (List) obj;
            int size = list.size();
            ArrayList arrayList = new ArrayList(size);
            for (int i10 = 0; i10 < size; i10++) {
                Object obj2 = list.get(i10);
                zzl(zzadoVar, obj2);
                arrayList.add(obj2);
            }
            obj = arrayList;
        }
        if (obj instanceof zzael) {
            this.zzd = true;
        }
        this.zza.put(zzadoVar, obj);
    }

    public final boolean zzh() {
        int iZzc = this.zza.zzc();
        for (int i10 = 0; i10 < iZzc; i10++) {
            if (!zzi(this.zza.zzg(i10))) {
                return false;
            }
        }
        Iterator it = this.zza.zzd().iterator();
        while (it.hasNext()) {
            if (!zzi((Map.Entry) it.next())) {
                return false;
            }
        }
        return true;
    }

    private zzadp(boolean z10) {
        zzf();
        zzf();
    }
}
