package androidx.datastore.preferences.protobuf;

import androidx.datastore.preferences.protobuf.q1;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

/* loaded from: classes.dex */
final class s {

    /* renamed from: d, reason: collision with root package name */
    private static final s f4198d = new s(true);

    /* renamed from: a, reason: collision with root package name */
    private final g1 f4199a;

    /* renamed from: b, reason: collision with root package name */
    private boolean f4200b;

    /* renamed from: c, reason: collision with root package name */
    private boolean f4201c;

    /* JADX INFO: Access modifiers changed from: package-private */
    /* loaded from: classes.dex */
    public static /* synthetic */ class a {

        /* renamed from: a, reason: collision with root package name */
        static final /* synthetic */ int[] f4202a;

        /* renamed from: b, reason: collision with root package name */
        static final /* synthetic */ int[] f4203b;

        static {
            int[] iArr = new int[q1.b.values().length];
            f4203b = iArr;
            try {
                iArr[q1.b.DOUBLE.ordinal()] = 1;
            } catch (NoSuchFieldError unused) {
            }
            try {
                f4203b[q1.b.FLOAT.ordinal()] = 2;
            } catch (NoSuchFieldError unused2) {
            }
            try {
                f4203b[q1.b.INT64.ordinal()] = 3;
            } catch (NoSuchFieldError unused3) {
            }
            try {
                f4203b[q1.b.UINT64.ordinal()] = 4;
            } catch (NoSuchFieldError unused4) {
            }
            try {
                f4203b[q1.b.INT32.ordinal()] = 5;
            } catch (NoSuchFieldError unused5) {
            }
            try {
                f4203b[q1.b.FIXED64.ordinal()] = 6;
            } catch (NoSuchFieldError unused6) {
            }
            try {
                f4203b[q1.b.FIXED32.ordinal()] = 7;
            } catch (NoSuchFieldError unused7) {
            }
            try {
                f4203b[q1.b.BOOL.ordinal()] = 8;
            } catch (NoSuchFieldError unused8) {
            }
            try {
                f4203b[q1.b.GROUP.ordinal()] = 9;
            } catch (NoSuchFieldError unused9) {
            }
            try {
                f4203b[q1.b.MESSAGE.ordinal()] = 10;
            } catch (NoSuchFieldError unused10) {
            }
            try {
                f4203b[q1.b.STRING.ordinal()] = 11;
            } catch (NoSuchFieldError unused11) {
            }
            try {
                f4203b[q1.b.BYTES.ordinal()] = 12;
            } catch (NoSuchFieldError unused12) {
            }
            try {
                f4203b[q1.b.UINT32.ordinal()] = 13;
            } catch (NoSuchFieldError unused13) {
            }
            try {
                f4203b[q1.b.SFIXED32.ordinal()] = 14;
            } catch (NoSuchFieldError unused14) {
            }
            try {
                f4203b[q1.b.SFIXED64.ordinal()] = 15;
            } catch (NoSuchFieldError unused15) {
            }
            try {
                f4203b[q1.b.SINT32.ordinal()] = 16;
            } catch (NoSuchFieldError unused16) {
            }
            try {
                f4203b[q1.b.SINT64.ordinal()] = 17;
            } catch (NoSuchFieldError unused17) {
            }
            try {
                f4203b[q1.b.ENUM.ordinal()] = 18;
            } catch (NoSuchFieldError unused18) {
            }
            int[] iArr2 = new int[q1.c.values().length];
            f4202a = iArr2;
            try {
                iArr2[q1.c.INT.ordinal()] = 1;
            } catch (NoSuchFieldError unused19) {
            }
            try {
                f4202a[q1.c.LONG.ordinal()] = 2;
            } catch (NoSuchFieldError unused20) {
            }
            try {
                f4202a[q1.c.FLOAT.ordinal()] = 3;
            } catch (NoSuchFieldError unused21) {
            }
            try {
                f4202a[q1.c.DOUBLE.ordinal()] = 4;
            } catch (NoSuchFieldError unused22) {
            }
            try {
                f4202a[q1.c.BOOLEAN.ordinal()] = 5;
            } catch (NoSuchFieldError unused23) {
            }
            try {
                f4202a[q1.c.STRING.ordinal()] = 6;
            } catch (NoSuchFieldError unused24) {
            }
            try {
                f4202a[q1.c.BYTE_STRING.ordinal()] = 7;
            } catch (NoSuchFieldError unused25) {
            }
            try {
                f4202a[q1.c.ENUM.ordinal()] = 8;
            } catch (NoSuchFieldError unused26) {
            }
            try {
                f4202a[q1.c.MESSAGE.ordinal()] = 9;
            } catch (NoSuchFieldError unused27) {
            }
        }
    }

    /* loaded from: classes.dex */
    public interface b extends Comparable {
        boolean b();

        q1.b c();

        int getNumber();

        boolean isPacked();
    }

    private s() {
        this.f4199a = g1.A(16);
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public static int b(q1.b bVar, int i10, Object obj) {
        int P = j.P(i10);
        if (bVar == q1.b.GROUP) {
            P *= 2;
        }
        return P + c(bVar, obj);
    }

    static int c(q1.b bVar, Object obj) {
        switch (a.f4203b[bVar.ordinal()]) {
            case 1:
                return j.i(((Double) obj).doubleValue());
            case 2:
                return j.q(((Float) obj).floatValue());
            case 3:
                return j.x(((Long) obj).longValue());
            case 4:
                return j.T(((Long) obj).longValue());
            case 5:
                return j.v(((Integer) obj).intValue());
            case 6:
                return j.o(((Long) obj).longValue());
            case 7:
                return j.m(((Integer) obj).intValue());
            case 8:
                return j.d(((Boolean) obj).booleanValue());
            case 9:
                return j.s((o0) obj);
            case 10:
                return j.A((o0) obj);
            case 11:
                return obj instanceof g ? j.g((g) obj) : j.O((String) obj);
            case 12:
                return obj instanceof g ? j.g((g) obj) : j.e((byte[]) obj);
            case 13:
                return j.R(((Integer) obj).intValue());
            case 14:
                return j.G(((Integer) obj).intValue());
            case 15:
                return j.I(((Long) obj).longValue());
            case 16:
                return j.K(((Integer) obj).intValue());
            case 17:
                return j.M(((Long) obj).longValue());
            case 18:
                return j.k(((Integer) obj).intValue());
            default:
                throw new RuntimeException("There is no way to get here, but the compiler thinks otherwise.");
        }
    }

    public static int d(b bVar, Object obj) {
        q1.b c10 = bVar.c();
        int number = bVar.getNumber();
        if (!bVar.b()) {
            return b(c10, number, obj);
        }
        int i10 = 0;
        if (bVar.isPacked()) {
            Iterator it = ((List) obj).iterator();
            while (it.hasNext()) {
                i10 += c(c10, it.next());
            }
            return j.P(number) + i10 + j.E(i10);
        }
        Iterator it2 = ((List) obj).iterator();
        while (it2.hasNext()) {
            i10 += b(c10, number, it2.next());
        }
        return i10;
    }

    private int g(Map.Entry entry) {
        android.support.v4.media.session.b.a(entry.getKey());
        entry.getValue();
        throw null;
    }

    static int i(q1.b bVar, boolean z10) {
        if (z10) {
            return 2;
        }
        return bVar.getWireType();
    }

    private static boolean l(Map.Entry entry) {
        android.support.v4.media.session.b.a(entry.getKey());
        throw null;
    }

    private static boolean m(q1.b bVar, Object obj) {
        y.a(obj);
        switch (a.f4202a[bVar.getJavaType().ordinal()]) {
            case 1:
                return obj instanceof Integer;
            case 2:
                return obj instanceof Long;
            case 3:
                return obj instanceof Float;
            case 4:
                return obj instanceof Double;
            case 5:
                return obj instanceof Boolean;
            case 6:
                return obj instanceof String;
            case 7:
                return (obj instanceof g) || (obj instanceof byte[]);
            case 8:
                return obj instanceof Integer;
            case 9:
                return obj instanceof o0;
            default:
                return false;
        }
    }

    private void q(Map.Entry entry) {
        android.support.v4.media.session.b.a(entry.getKey());
        entry.getValue();
        throw null;
    }

    public static s r() {
        return new s();
    }

    private void t(q1.b bVar, Object obj) {
        if (!m(bVar, obj)) {
            throw new IllegalArgumentException("Wrong object type used with protocol message reflection.");
        }
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public static void u(j jVar, q1.b bVar, int i10, Object obj) {
        if (bVar == q1.b.GROUP) {
            jVar.r0(i10, (o0) obj);
        } else {
            jVar.N0(i10, i(bVar, false));
            v(jVar, bVar, obj);
        }
    }

    static void v(j jVar, q1.b bVar, Object obj) {
        switch (a.f4203b[bVar.ordinal()]) {
            case 1:
                jVar.i0(((Double) obj).doubleValue());
                return;
            case 2:
                jVar.q0(((Float) obj).floatValue());
                return;
            case 3:
                jVar.y0(((Long) obj).longValue());
                return;
            case 4:
                jVar.R0(((Long) obj).longValue());
                return;
            case 5:
                jVar.w0(((Integer) obj).intValue());
                return;
            case 6:
                jVar.o0(((Long) obj).longValue());
                return;
            case 7:
                jVar.m0(((Integer) obj).intValue());
                return;
            case 8:
                jVar.c0(((Boolean) obj).booleanValue());
                return;
            case 9:
                jVar.t0((o0) obj);
                return;
            case 10:
                jVar.A0((o0) obj);
                return;
            case 11:
                if (obj instanceof g) {
                    jVar.g0((g) obj);
                    return;
                } else {
                    jVar.M0((String) obj);
                    return;
                }
            case 12:
                if (obj instanceof g) {
                    jVar.g0((g) obj);
                    return;
                } else {
                    jVar.d0((byte[]) obj);
                    return;
                }
            case 13:
                jVar.P0(((Integer) obj).intValue());
                return;
            case 14:
                jVar.E0(((Integer) obj).intValue());
                return;
            case 15:
                jVar.G0(((Long) obj).longValue());
                return;
            case 16:
                jVar.I0(((Integer) obj).intValue());
                return;
            case 17:
                jVar.K0(((Long) obj).longValue());
                return;
            case 18:
                jVar.k0(((Integer) obj).intValue());
                return;
            default:
                return;
        }
    }

    /* renamed from: a, reason: merged with bridge method [inline-methods] */
    public s clone() {
        s r10 = r();
        for (int i10 = 0; i10 < this.f4199a.p(); i10++) {
            Map.Entry m10 = this.f4199a.m(i10);
            android.support.v4.media.session.b.a(m10.getKey());
            r10.s(null, m10.getValue());
        }
        for (Map.Entry entry : this.f4199a.t()) {
            android.support.v4.media.session.b.a(entry.getKey());
            r10.s(null, entry.getValue());
        }
        r10.f4201c = this.f4201c;
        return r10;
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public Iterator e() {
        return this.f4201c ? new b0(this.f4199a.h().iterator()) : this.f4199a.h().iterator();
    }

    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj instanceof s) {
            return this.f4199a.equals(((s) obj).f4199a);
        }
        return false;
    }

    public int f() {
        int i10 = 0;
        for (int i11 = 0; i11 < this.f4199a.p(); i11++) {
            i10 += g(this.f4199a.m(i11));
        }
        Iterator it = this.f4199a.t().iterator();
        while (it.hasNext()) {
            i10 += g((Map.Entry) it.next());
        }
        return i10;
    }

    public int h() {
        int i10 = 0;
        for (int i11 = 0; i11 < this.f4199a.p(); i11++) {
            Map.Entry m10 = this.f4199a.m(i11);
            android.support.v4.media.session.b.a(m10.getKey());
            i10 += d(null, m10.getValue());
        }
        for (Map.Entry entry : this.f4199a.t()) {
            android.support.v4.media.session.b.a(entry.getKey());
            i10 += d(null, entry.getValue());
        }
        return i10;
    }

    public int hashCode() {
        return this.f4199a.hashCode();
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public boolean j() {
        return this.f4199a.isEmpty();
    }

    public boolean k() {
        for (int i10 = 0; i10 < this.f4199a.p(); i10++) {
            if (!l(this.f4199a.m(i10))) {
                return false;
            }
        }
        Iterator it = this.f4199a.t().iterator();
        while (it.hasNext()) {
            if (!l((Map.Entry) it.next())) {
                return false;
            }
        }
        return true;
    }

    public Iterator n() {
        return this.f4201c ? new b0(this.f4199a.entrySet().iterator()) : this.f4199a.entrySet().iterator();
    }

    public void o() {
        if (this.f4200b) {
            return;
        }
        this.f4199a.z();
        this.f4200b = true;
    }

    public void p(s sVar) {
        for (int i10 = 0; i10 < sVar.f4199a.p(); i10++) {
            q(sVar.f4199a.m(i10));
        }
        Iterator it = sVar.f4199a.t().iterator();
        while (it.hasNext()) {
            q((Map.Entry) it.next());
        }
    }

    public void s(b bVar, Object obj) {
        if (!bVar.b()) {
            t(bVar.c(), obj);
        } else {
            if (!(obj instanceof List)) {
                throw new IllegalArgumentException("Wrong object type used with protocol message reflection.");
            }
            ArrayList arrayList = new ArrayList();
            arrayList.addAll((List) obj);
            Iterator it = arrayList.iterator();
            while (it.hasNext()) {
                t(bVar.c(), it.next());
            }
            obj = arrayList;
        }
        this.f4199a.B(bVar, obj);
    }

    private s(boolean z10) {
        this(g1.A(0));
        o();
    }

    private s(g1 g1Var) {
        this.f4199a = g1Var;
        o();
    }
}
