package okhttp3;

import S4.a;
import java.nio.charset.Charset;
import kotlin.jvm.internal.o;
import okhttp3.MediaType;
import okhttp3.internal.Util;
import p5.InterfaceC2741k;

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

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public static final Companion f22136a = new Companion(0);

    public static final class Companion {
        public /* synthetic */ Companion(int i6) {
            this();
        }

        public static RequestBody$Companion$toRequestBody$2 a(String str, MediaType mediaType) {
            o.h(str, "<this>");
            Charset charset = a.f6257a;
            if (mediaType != null) {
                MediaType.Companion companion = MediaType.f22043d;
                Charset charsetA = mediaType.a(null);
                if (charsetA == null) {
                    MediaType.f22043d.getClass();
                    mediaType = MediaType.Companion.b(mediaType + "; charset=utf-8");
                } else {
                    charset = charsetA;
                }
            }
            byte[] bytes = str.getBytes(charset);
            o.g(bytes, "this as java.lang.String).getBytes(charset)");
            int length = bytes.length;
            long length2 = bytes.length;
            long j4 = 0;
            long j6 = length;
            byte[] bArr = Util.f22179a;
            if ((j4 | j6) < 0 || j4 > length2 || length2 - j4 < j6) {
                throw new ArrayIndexOutOfBoundsException();
            }
            return new RequestBody$Companion$toRequestBody$2(mediaType, length, bytes);
        }

        public static RequestBody$Companion$toRequestBody$2 b(Companion companion, byte[] bArr, MediaType mediaType, int i6) {
            if ((i6 & 1) != 0) {
                mediaType = null;
            }
            int length = bArr.length;
            companion.getClass();
            o.h(bArr, "<this>");
            long length2 = bArr.length;
            long j4 = 0;
            long j6 = length;
            byte[] bArr2 = Util.f22179a;
            if ((j4 | j6) < 0 || j4 > length2 || length2 - j4 < j6) {
                throw new ArrayIndexOutOfBoundsException();
            }
            return new RequestBody$Companion$toRequestBody$2(mediaType, length, bArr);
        }

        private Companion() {
        }
    }

    public long a() {
        return -1L;
    }

    public abstract MediaType b();

    public abstract void c(InterfaceC2741k interfaceC2741k);
}
