package androidx.datastore.preferences.protobuf;

import java.io.IOException;
import java.util.Collections;
import java.util.Iterator;
import java.util.Map;
import n4.u0;

/* JADX INFO: renamed from: androidx.datastore.preferences.protobuf.p, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes.dex */
public final class C0438p {

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

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final W f8113a = W.f();

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public boolean f8114b;

    static {
        new C0438p(0);
    }

    public C0438p() {
    }

    public static void b(C0433k c0433k, p0 p0Var, int i, Object obj) throws IOException {
        if (p0Var == p0.f8116t) {
            c0433k.k0(i, 3);
            ((AbstractC0423a) obj).b(c0433k);
            c0433k.k0(i, 4);
        }
        c0433k.k0(i, p0Var.f8120r);
        switch (p0Var.ordinal()) {
            case u0.f15495q /* 0 */:
                c0433k.e0(Double.doubleToRawLongBits(((Double) obj).doubleValue()));
                break;
            case 1:
                c0433k.c0(Float.floatToRawIntBits(((Float) obj).floatValue()));
                break;
            case 2:
                c0433k.o0(((Long) obj).longValue());
                break;
            case 3:
                c0433k.o0(((Long) obj).longValue());
                break;
            case 4:
                c0433k.g0(((Integer) obj).intValue());
                break;
            case 5:
                c0433k.e0(((Long) obj).longValue());
                break;
            case Z.g.STRING_SET_FIELD_NUMBER /* 6 */:
                c0433k.c0(((Integer) obj).intValue());
                break;
            case Z.g.DOUBLE_FIELD_NUMBER /* 7 */:
                c0433k.W(((Boolean) obj).booleanValue() ? (byte) 1 : (byte) 0);
                break;
            case Z.g.BYTES_FIELD_NUMBER /* 8 */:
                if (!(obj instanceof C0429g)) {
                    c0433k.j0((String) obj);
                } else {
                    c0433k.a0((C0429g) obj);
                }
                break;
            case 9:
                ((AbstractC0423a) obj).b(c0433k);
                break;
            case 10:
                AbstractC0423a abstractC0423a = (AbstractC0423a) obj;
                c0433k.getClass();
                c0433k.m0(((AbstractC0442u) abstractC0423a).a(null));
                abstractC0423a.b(c0433k);
                break;
            case 11:
                if (!(obj instanceof C0429g)) {
                    byte[] bArr = (byte[]) obj;
                    int length = bArr.length;
                    c0433k.m0(length);
                    c0433k.X(bArr, 0, length);
                } else {
                    c0433k.a0((C0429g) obj);
                }
                break;
            case 12:
                c0433k.m0(((Integer) obj).intValue());
                break;
            case 13:
                c0433k.g0(((Integer) obj).intValue());
                break;
            case 14:
                c0433k.c0(((Integer) obj).intValue());
                break;
            case 15:
                c0433k.e0(((Long) obj).longValue());
                break;
            case 16:
                int iIntValue = ((Integer) obj).intValue();
                c0433k.m0((iIntValue >> 31) ^ (iIntValue << 1));
                break;
            case 17:
                long jLongValue = ((Long) obj).longValue();
                c0433k.o0((jLongValue >> 63) ^ (jLongValue << 1));
                break;
        }
    }

    public final void a() {
        if (this.f8114b) {
            return;
        }
        W w4 = this.f8113a;
        int size = w4.f8038q.size();
        for (int i = 0; i < size; i++) {
            Map.Entry entryC = w4.c(i);
            if (entryC.getValue() instanceof AbstractC0442u) {
                AbstractC0442u abstractC0442u = (AbstractC0442u) entryC.getValue();
                abstractC0442u.getClass();
                Q q8 = Q.f8024c;
                q8.getClass();
                q8.a(abstractC0442u.getClass()).d(abstractC0442u);
                abstractC0442u.h();
            }
        }
        if (!w4.f8040s) {
            if (w4.f8038q.size() > 0) {
                w4.c(0).getKey().getClass();
                throw new ClassCastException();
            }
            Iterator it = w4.d().iterator();
            if (it.hasNext()) {
                ((Map.Entry) it.next()).getKey().getClass();
                throw new ClassCastException();
            }
        }
        if (!w4.f8040s) {
            w4.f8039r = w4.f8039r.isEmpty() ? Collections.EMPTY_MAP : Collections.unmodifiableMap(w4.f8039r);
            w4.f8042u = w4.f8042u.isEmpty() ? Collections.EMPTY_MAP : Collections.unmodifiableMap(w4.f8042u);
            w4.f8040s = true;
        }
        this.f8114b = true;
    }

    public final Object clone() {
        C0438p c0438p = new C0438p();
        W w4 = this.f8113a;
        if (w4.f8038q.size() > 0) {
            Map.Entry entryC = w4.c(0);
            if (entryC.getKey() != null) {
                throw new ClassCastException();
            }
            entryC.getValue();
            throw null;
        }
        Iterator it = w4.d().iterator();
        if (!it.hasNext()) {
            return c0438p;
        }
        Map.Entry entry = (Map.Entry) it.next();
        if (entry.getKey() != null) {
            throw new ClassCastException();
        }
        entry.getValue();
        throw null;
    }

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

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

    public C0438p(int i) {
        a();
        a();
    }
}
