package com.google.android.gms.internal.atv_ads_framework;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/* JADX INFO: loaded from: classes2.dex */
public abstract class a0 extends p {
    private static final Map zzb = new ConcurrentHashMap();
    protected f1 zzc;
    private int zzd;

    public a0() {
        this.zza = 0;
        this.zzd = -1;
        this.zzc = f1.f19922e;
    }

    public static a0 g(Class cls) {
        Map map = zzb;
        a0 a0Var = (a0) map.get(cls);
        if (a0Var == null) {
            try {
                Class.forName(cls.getName(), true, cls.getClassLoader());
                a0Var = (a0) map.get(cls);
            } catch (ClassNotFoundException e10) {
                throw new IllegalStateException("Class initialization cannot fail.", e10);
            }
        }
        if (a0Var == null) {
            a0Var = (a0) ((a0) n1.h(cls)).d(6);
            if (a0Var == null) {
                throw new IllegalStateException();
            }
            map.put(cls, a0Var);
        }
        return a0Var;
    }

    public static Object i(Method method, Object obj, Object... objArr) {
        try {
            return method.invoke(obj, objArr);
        } catch (IllegalAccessException e10) {
            throw new RuntimeException("Couldn't use Java reflection to implement protocol message reflection.", e10);
        } catch (InvocationTargetException e11) {
            Throwable cause = e11.getCause();
            if (cause instanceof RuntimeException) {
                throw ((RuntimeException) cause);
            }
            if (cause instanceof Error) {
                throw ((Error) cause);
            }
            throw new RuntimeException("Unexpected exception thrown by generated accessor method.", cause);
        }
    }

    public static void k(Class cls, a0 a0Var) {
        a0Var.j();
        zzb.put(cls, a0Var);
    }

    @Override // com.google.android.gms.internal.atv_ads_framework.p
    public final int a(c1 c1Var) {
        if (b()) {
            int iC = c(c1Var);
            if (iC >= 0) {
                return iC;
            }
            throw new IllegalStateException(com.google.android.gms.measurement.internal.u1.g("serialized size must be non-negative, was ", iC));
        }
        int i10 = this.zzd & Integer.MAX_VALUE;
        if (i10 != Integer.MAX_VALUE) {
            return i10;
        }
        int iC2 = c(c1Var);
        if (iC2 < 0) {
            throw new IllegalStateException(com.google.android.gms.measurement.internal.u1.g("serialized size must be non-negative, was ", iC2));
        }
        this.zzd = (this.zzd & Integer.MIN_VALUE) | iC2;
        return iC2;
    }

    public final boolean b() {
        return (this.zzd & Integer.MIN_VALUE) != 0;
    }

    public final int c(c1 c1Var) {
        if (c1Var != null) {
            return c1Var.zza(this);
        }
        return a1.f19902c.a(getClass()).zza(this);
    }

    public abstract Object d(int i10);

    public final int e() {
        int iC;
        if (b()) {
            iC = c(null);
            if (iC < 0) {
                throw new IllegalStateException(com.google.android.gms.measurement.internal.u1.g("serialized size must be non-negative, was ", iC));
            }
        } else {
            iC = this.zzd & Integer.MAX_VALUE;
            if (iC == Integer.MAX_VALUE) {
                iC = c(null);
                if (iC < 0) {
                    throw new IllegalStateException(com.google.android.gms.measurement.internal.u1.g("serialized size must be non-negative, was ", iC));
                }
                this.zzd = (this.zzd & Integer.MIN_VALUE) | iC;
            }
        }
        return iC;
    }

    public final boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null || getClass() != obj.getClass()) {
            return false;
        }
        return a1.f19902c.a(getClass()).zzg(this, (a0) obj);
    }

    public final z f() {
        return (z) d(5);
    }

    public final a0 h() {
        return (a0) d(4);
    }

    public final int hashCode() {
        if (b()) {
            return a1.f19902c.a(getClass()).zzb(this);
        }
        int i10 = this.zza;
        if (i10 != 0) {
            return i10;
        }
        int iZzb = a1.f19902c.a(getClass()).zzb(this);
        this.zza = iZzb;
        return iZzb;
    }

    public final void j() {
        this.zzd &= Integer.MAX_VALUE;
    }

    public final void l() {
        this.zzd = (this.zzd & Integer.MIN_VALUE) | Integer.MAX_VALUE;
    }

    public final String toString() {
        String string = super.toString();
        char[] cArr = u0.f19984a;
        StringBuilder sb = new StringBuilder();
        sb.append("# ");
        sb.append(string);
        u0.c(this, sb, 0);
        return sb.toString();
    }
}
