package com.google.crypto.tink.shaded.protobuf;

import com.google.android.gms.internal.ads.ga2;
import com.google.android.gms.measurement.internal.u1;
import com.google.crypto.tink.shaded.protobuf.ByteString;
import java.io.IOException;
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 x extends b {
    private static final int MEMOIZED_SERIALIZED_SIZE_MASK = Integer.MAX_VALUE;
    private static final int MUTABLE_FLAG_MASK = Integer.MIN_VALUE;
    static final int UNINITIALIZED_HASH_CODE = 0;
    static final int UNINITIALIZED_SERIALIZED_SIZE = Integer.MAX_VALUE;
    private static Map<Class<?>, x> defaultInstanceMap = new ConcurrentHashMap();
    private int memoizedSerializedSize;
    protected f1 unknownFields;

    public x() {
        this.memoizedHashCode = 0;
        this.memoizedSerializedSize = -1;
        this.unknownFields = f1.f23897f;
    }

    public static void g(x xVar) throws InvalidProtocolBufferException {
        if (xVar == null || q(xVar, true)) {
            return;
        }
        InvalidProtocolBufferException invalidProtocolBufferException = new InvalidProtocolBufferException(new UninitializedMessageException().getMessage());
        invalidProtocolBufferException.i(xVar);
        throw invalidProtocolBufferException;
    }

    public static x l(Class cls) {
        x xVarA = defaultInstanceMap.get(cls);
        if (xVarA == null) {
            try {
                Class.forName(cls.getName(), true, cls.getClassLoader());
                xVarA = defaultInstanceMap.get(cls);
            } catch (ClassNotFoundException e10) {
                throw new IllegalStateException("Class initialization cannot fail.", e10);
            }
        }
        if (xVarA == null) {
            xVarA = ((x) l1.b(cls)).a();
            if (xVarA == null) {
                throw new IllegalStateException();
            }
            defaultInstanceMap.put(cls, xVarA);
        }
        return xVarA;
    }

    public static Object o(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 final boolean q(x xVar, boolean z10) {
        byte bByteValue = ((Byte) xVar.k(GeneratedMessageLite$MethodToInvoke.f23858a)).byteValue();
        if (bByteValue == 1) {
            return true;
        }
        if (bByteValue == 0) {
            return false;
        }
        w0 w0Var = w0.f23983c;
        w0Var.getClass();
        boolean zC = w0Var.a(xVar.getClass()).c(xVar);
        if (z10) {
            xVar.k(GeneratedMessageLite$MethodToInvoke.f23859b);
        }
        return zC;
    }

    public static x w(x xVar, ByteString byteString, q qVar) throws InvalidProtocolBufferException {
        ByteString.LiteralByteString literalByteString = (ByteString.LiteralByteString) byteString;
        j jVarF = l.f(literalByteString.bytes, literalByteString.l(), literalByteString.size(), true);
        x xVarY = y(xVar, jVarF, qVar);
        try {
            jVarF.a(0);
            g(xVarY);
            return xVarY;
        } catch (InvalidProtocolBufferException e10) {
            e10.i(xVarY);
            throw e10;
        }
    }

    public static x x(x xVar, byte[] bArr, q qVar) throws InvalidProtocolBufferException {
        int length = bArr.length;
        if (length != 0) {
            xVar = xVar.v();
            try {
                w0 w0Var = w0.f23983c;
                w0Var.getClass();
                a1 a1VarA = w0Var.a(xVar.getClass());
                a1VarA.h(xVar, bArr, 0, length, new ga2(qVar));
                a1VarA.b(xVar);
            } catch (InvalidProtocolBufferException e10) {
                e = e10;
                if (e.a()) {
                    e = new InvalidProtocolBufferException(e);
                }
                e.i(xVar);
                throw e;
            } catch (UninitializedMessageException e11) {
                InvalidProtocolBufferException invalidProtocolBufferException = new InvalidProtocolBufferException(e11.getMessage());
                invalidProtocolBufferException.i(xVar);
                throw invalidProtocolBufferException;
            } catch (IOException e12) {
                if (e12.getCause() instanceof InvalidProtocolBufferException) {
                    throw ((InvalidProtocolBufferException) e12.getCause());
                }
                InvalidProtocolBufferException invalidProtocolBufferException2 = new InvalidProtocolBufferException(e12);
                invalidProtocolBufferException2.i(xVar);
                throw invalidProtocolBufferException2;
            } catch (IndexOutOfBoundsException unused) {
                InvalidProtocolBufferException invalidProtocolBufferExceptionJ = InvalidProtocolBufferException.j();
                invalidProtocolBufferExceptionJ.i(xVar);
                throw invalidProtocolBufferExceptionJ;
            }
        }
        g(xVar);
        return xVar;
    }

    public static x y(x xVar, l lVar, q qVar) throws InvalidProtocolBufferException {
        x xVarV = xVar.v();
        try {
            w0 w0Var = w0.f23983c;
            w0Var.getClass();
            a1 a1VarA = w0Var.a(xVarV.getClass());
            m mVar = lVar.f23931d;
            if (mVar == null) {
                mVar = new m(lVar);
            }
            a1VarA.j(xVarV, mVar, qVar);
            a1VarA.b(xVarV);
            return xVarV;
        } catch (InvalidProtocolBufferException e10) {
            e = e10;
            if (e.a()) {
                e = new InvalidProtocolBufferException(e);
            }
            e.i(xVarV);
            throw e;
        } catch (UninitializedMessageException e11) {
            InvalidProtocolBufferException invalidProtocolBufferException = new InvalidProtocolBufferException(e11.getMessage());
            invalidProtocolBufferException.i(xVarV);
            throw invalidProtocolBufferException;
        } catch (IOException e12) {
            if (e12.getCause() instanceof InvalidProtocolBufferException) {
                throw ((InvalidProtocolBufferException) e12.getCause());
            }
            InvalidProtocolBufferException invalidProtocolBufferException2 = new InvalidProtocolBufferException(e12);
            invalidProtocolBufferException2.i(xVarV);
            throw invalidProtocolBufferException2;
        } catch (RuntimeException e13) {
            if (e13.getCause() instanceof InvalidProtocolBufferException) {
                throw ((InvalidProtocolBufferException) e13.getCause());
            }
            throw e13;
        }
    }

    public static void z(Class cls, x xVar) {
        xVar.t();
        defaultInstanceMap.put(cls, xVar);
    }

    public final void A(int i10) {
        if (i10 < 0) {
            throw new IllegalStateException(u1.g("serialized size must be non-negative, was ", i10));
        }
        this.memoizedSerializedSize = (i10 & Integer.MAX_VALUE) | (this.memoizedSerializedSize & Integer.MIN_VALUE);
    }

    public final v B() {
        v vVar = (v) k(GeneratedMessageLite$MethodToInvoke.f23862e);
        vVar.g(this);
        return vVar;
    }

    public final void C(n nVar) {
        w0 w0Var = w0.f23983c;
        w0Var.getClass();
        a1 a1VarA = w0Var.a(getClass());
        xyz.stream.utils.j0 j0Var = nVar.f23946b;
        if (j0Var == null) {
            j0Var = new xyz.stream.utils.j0(nVar);
        }
        a1VarA.i(this, j0Var);
    }

    @Override // com.google.crypto.tink.shaded.protobuf.b
    public final int c(a1 a1Var) {
        int iE;
        int iE2;
        if (r()) {
            if (a1Var == null) {
                w0 w0Var = w0.f23983c;
                w0Var.getClass();
                iE2 = w0Var.a(getClass()).e(this);
            } else {
                iE2 = a1Var.e(this);
            }
            if (iE2 >= 0) {
                return iE2;
            }
            throw new IllegalStateException(u1.g("serialized size must be non-negative, was ", iE2));
        }
        int i10 = this.memoizedSerializedSize;
        if ((i10 & Integer.MAX_VALUE) != Integer.MAX_VALUE) {
            return i10 & Integer.MAX_VALUE;
        }
        if (a1Var == null) {
            w0 w0Var2 = w0.f23983c;
            w0Var2.getClass();
            iE = w0Var2.a(getClass()).e(this);
        } else {
            iE = a1Var.e(this);
        }
        A(iE);
        return iE;
    }

    public final boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null || getClass() != obj.getClass()) {
            return false;
        }
        w0 w0Var = w0.f23983c;
        w0Var.getClass();
        return w0Var.a(getClass()).d(this, (x) obj);
    }

    public final void h() {
        this.memoizedHashCode = 0;
    }

    public final int hashCode() {
        if (r()) {
            w0 w0Var = w0.f23983c;
            w0Var.getClass();
            return w0Var.a(getClass()).g(this);
        }
        if (this.memoizedHashCode == 0) {
            w0 w0Var2 = w0.f23983c;
            w0Var2.getClass();
            this.memoizedHashCode = w0Var2.a(getClass()).g(this);
        }
        return this.memoizedHashCode;
    }

    public final void i() {
        A(Integer.MAX_VALUE);
    }

    public final v j() {
        return (v) k(GeneratedMessageLite$MethodToInvoke.f23862e);
    }

    public abstract Object k(GeneratedMessageLite$MethodToInvoke generatedMessageLite$MethodToInvoke);

    @Override // com.google.crypto.tink.shaded.protobuf.p0
    /* JADX INFO: renamed from: m, reason: merged with bridge method [inline-methods] */
    public final x a() {
        return (x) k(GeneratedMessageLite$MethodToInvoke.f23863f);
    }

    public final v0 n() {
        return (v0) k(GeneratedMessageLite$MethodToInvoke.f23864g);
    }

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

    public final void s() {
        w0 w0Var = w0.f23983c;
        w0Var.getClass();
        w0Var.a(getClass()).b(this);
        t();
    }

    public final void t() {
        this.memoizedSerializedSize &= Integer.MAX_VALUE;
    }

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

    @Override // com.google.crypto.tink.shaded.protobuf.o0
    /* JADX INFO: renamed from: u, reason: merged with bridge method [inline-methods] */
    public final v b() {
        return (v) k(GeneratedMessageLite$MethodToInvoke.f23862e);
    }

    public final x v() {
        return (x) k(GeneratedMessageLite$MethodToInvoke.f23861d);
    }
}
