package k4;

import com.revenuecat.purchases.common.diagnostics.DiagnosticsEntry;
import java.util.BitSet;
import java.util.Locale;
import java.util.logging.Level;

/* JADX INFO: loaded from: classes3.dex */
public abstract class d0 {

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public static final BitSet f19844d;

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final String f19845a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final byte[] f19846b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final Object f19847c;

    static {
        BitSet bitSet = new BitSet(127);
        bitSet.set(45);
        bitSet.set(95);
        bitSet.set(46);
        for (char c6 = '0'; c6 <= '9'; c6 = (char) (c6 + 1)) {
            bitSet.set(c6);
        }
        for (char c7 = 'a'; c7 <= 'z'; c7 = (char) (c7 + 1)) {
            bitSet.set(c7);
        }
        f19844d = bitSet;
    }

    public d0(Object obj, String str, boolean z6) {
        String lowerCase = str.toLowerCase(Locale.ROOT);
        A4.g.o(lowerCase, DiagnosticsEntry.NAME_KEY);
        A4.g.l(!lowerCase.isEmpty(), "token must have at least 1 tchar");
        if (lowerCase.equals("connection")) {
            g0.f19866c.log(Level.WARNING, "Metadata key is 'Connection', which should not be used. That is used by HTTP/1 for connection-specific headers which are not to be forwarded. There is probably an HTTP/1 conversion bug. Simply removing the Connection header is not enough; you should remove all headers it references as well. See RFC 7230 section 6.1", (Throwable) new RuntimeException("exception to show backtrace"));
        }
        for (int i6 = 0; i6 < lowerCase.length(); i6++) {
            char cCharAt = lowerCase.charAt(i6);
            if ((!z6 || cCharAt != ':' || i6 != 0) && !f19844d.get(cCharAt)) {
                throw new IllegalArgumentException(L4.a.X("Invalid character '%s' in key name '%s'", Character.valueOf(cCharAt), lowerCase));
            }
        }
        this.f19845a = lowerCase;
        this.f19846b = lowerCase.getBytes(E3.f.f1143a);
        this.f19847c = obj;
    }

    public abstract Object a(byte[] bArr);

    public abstract byte[] b(Object obj);

    public final boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null || getClass() != obj.getClass()) {
            return false;
        }
        return this.f19845a.equals(((d0) obj).f19845a);
    }

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

    public final String toString() {
        return com.google.android.recaptcha.internal.a.n(new StringBuilder("Key{name='"), this.f19845a, "'}");
    }
}
