package okhttp3;

import androidx.media3.container.NalUnitUtil;
import defpackage.bz0;
import defpackage.cr4;
import defpackage.e52;
import defpackage.eu6;
import defpackage.kp6;
import defpackage.pq6;
import defpackage.px8;
import defpackage.r15;
import defpackage.rh0;
import defpackage.s15;
import defpackage.uz1;
import defpackage.x15;
import defpackage.zo0;
import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
import kotlin.Metadata;
import okhttp3.internal.Util;

/* JADX INFO: loaded from: classes3.dex */
@Metadata(d1 = {"\u00002\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\t\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u000b\n\u0002\b\u0005\b&\u0018\u0000 \u00132\u00020\u0001:\u0001\u0013B\u0007¢\u0006\u0004\b\u0002\u0010\u0003J\u0011\u0010\u0005\u001a\u0004\u0018\u00010\u0004H&¢\u0006\u0004\b\u0005\u0010\u0006J\u000f\u0010\b\u001a\u00020\u0007H\u0016¢\u0006\u0004\b\b\u0010\tJ\u0017\u0010\r\u001a\u00020\f2\u0006\u0010\u000b\u001a\u00020\nH&¢\u0006\u0004\b\r\u0010\u000eJ\u000f\u0010\u0010\u001a\u00020\u000fH\u0016¢\u0006\u0004\b\u0010\u0010\u0011J\u000f\u0010\u0012\u001a\u00020\u000fH\u0016¢\u0006\u0004\b\u0012\u0010\u0011¨\u0006\u0014"}, d2 = {"Lokhttp3/RequestBody;", "", "<init>", "()V", "Lokhttp3/MediaType;", "contentType", "()Lokhttp3/MediaType;", "", "contentLength", "()J", "Lrh0;", "sink", "Le6a;", "writeTo", "(Lrh0;)V", "", "isDuplex", "()Z", "isOneShot", "Companion", "okhttp"}, k = 1, mv = {1, 8, 0}, xi = NalUnitUtil.H265_NAL_UNIT_TYPE_UNSPECIFIED)
public abstract class RequestBody {

    /* JADX INFO: renamed from: Companion, reason: from kotlin metadata */
    @kp6
    public static final Companion INSTANCE = new Companion(null);

    @Metadata(d1 = {"\u00008\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0010\u000e\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u0012\n\u0002\u0010\b\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\t\b\u0086\u0003\u0018\u00002\u00020\u0001B\t\b\u0002¢\u0006\u0004\b\u0002\u0010\u0003J\u001f\u0010\n\u001a\u00020\u0007*\u00020\u00042\n\b\u0002\u0010\u0006\u001a\u0004\u0018\u00010\u0005H\u0007¢\u0006\u0004\b\b\u0010\tJ\u001f\u0010\n\u001a\u00020\u0007*\u00020\u000b2\n\b\u0002\u0010\u0006\u001a\u0004\u0018\u00010\u0005H\u0007¢\u0006\u0004\b\b\u0010\fJ3\u0010\n\u001a\u00020\u0007*\u00020\r2\n\b\u0002\u0010\u0006\u001a\u0004\u0018\u00010\u00052\b\b\u0002\u0010\u000f\u001a\u00020\u000e2\b\b\u0002\u0010\u0010\u001a\u00020\u000eH\u0007¢\u0006\u0004\b\b\u0010\u0011J\u001f\u0010\u0014\u001a\u00020\u0007*\u00020\u00122\n\b\u0002\u0010\u0006\u001a\u0004\u0018\u00010\u0005H\u0007¢\u0006\u0004\b\b\u0010\u0013J!\u0010\b\u001a\u00020\u00072\b\u0010\u0006\u001a\u0004\u0018\u00010\u00052\u0006\u0010\u0015\u001a\u00020\u0004H\u0007¢\u0006\u0004\b\b\u0010\u0016J!\u0010\b\u001a\u00020\u00072\b\u0010\u0006\u001a\u0004\u0018\u00010\u00052\u0006\u0010\u0015\u001a\u00020\u000bH\u0007¢\u0006\u0004\b\b\u0010\u0017J5\u0010\b\u001a\u00020\u00072\b\u0010\u0006\u001a\u0004\u0018\u00010\u00052\u0006\u0010\u0015\u001a\u00020\r2\b\b\u0002\u0010\u000f\u001a\u00020\u000e2\b\b\u0002\u0010\u0010\u001a\u00020\u000eH\u0007¢\u0006\u0004\b\b\u0010\u0018J!\u0010\b\u001a\u00020\u00072\b\u0010\u0006\u001a\u0004\u0018\u00010\u00052\u0006\u0010\u0019\u001a\u00020\u0012H\u0007¢\u0006\u0004\b\b\u0010\u001a¨\u0006\u001b"}, d2 = {"Lokhttp3/RequestBody$Companion;", "", "<init>", "()V", "", "Lokhttp3/MediaType;", "contentType", "Lokhttp3/RequestBody;", "create", "(Ljava/lang/String;Lokhttp3/MediaType;)Lokhttp3/RequestBody;", "toRequestBody", "Lzo0;", "(Lzo0;Lokhttp3/MediaType;)Lokhttp3/RequestBody;", "", "", "offset", "byteCount", "([BLokhttp3/MediaType;II)Lokhttp3/RequestBody;", "Ljava/io/File;", "(Ljava/io/File;Lokhttp3/MediaType;)Lokhttp3/RequestBody;", "asRequestBody", "content", "(Lokhttp3/MediaType;Ljava/lang/String;)Lokhttp3/RequestBody;", "(Lokhttp3/MediaType;Lzo0;)Lokhttp3/RequestBody;", "(Lokhttp3/MediaType;[BII)Lokhttp3/RequestBody;", "file", "(Lokhttp3/MediaType;Ljava/io/File;)Lokhttp3/RequestBody;", "okhttp"}, k = 1, mv = {1, 8, 0}, xi = NalUnitUtil.H265_NAL_UNIT_TYPE_UNSPECIFIED)
    public static final class Companion {
        public /* synthetic */ Companion(uz1 uz1Var) {
            this();
        }

        public static /* synthetic */ RequestBody create$default(Companion companion, String str, MediaType mediaType, int i, Object obj) {
            if ((i & 1) != 0) {
                mediaType = null;
            }
            return companion.create(str, mediaType);
        }

        @e52
        @s15
        @x15
        @kp6
        public final RequestBody create(@pq6 MediaType mediaType, @kp6 byte[] bArr) {
            cr4.g(bArr, "content");
            return create$default(this, mediaType, bArr, 0, 0, 12, (Object) null);
        }

        private Companion() {
        }

        public static /* synthetic */ RequestBody create$default(Companion companion, zo0 zo0Var, MediaType mediaType, int i, Object obj) {
            if ((i & 1) != 0) {
                mediaType = null;
            }
            return companion.create(zo0Var, mediaType);
        }

        @e52
        @s15
        @x15
        @kp6
        public final RequestBody create(@pq6 MediaType mediaType, @kp6 byte[] bArr, int i) {
            cr4.g(bArr, "content");
            return create$default(this, mediaType, bArr, i, 0, 8, (Object) null);
        }

        public static /* synthetic */ RequestBody create$default(Companion companion, byte[] bArr, MediaType mediaType, int i, int i2, int i3, Object obj) {
            if ((i3 & 1) != 0) {
                mediaType = null;
            }
            if ((i3 & 2) != 0) {
                i = 0;
            }
            if ((i3 & 4) != 0) {
                i2 = bArr.length;
            }
            return companion.create(bArr, mediaType, i, i2);
        }

        @r15
        @s15
        @x15
        @kp6
        public final RequestBody create(@kp6 byte[] bArr) {
            cr4.g(bArr, "<this>");
            return create$default(this, bArr, (MediaType) null, 0, 0, 7, (Object) null);
        }

        @r15
        @s15
        @x15
        @kp6
        public final RequestBody create(@kp6 byte[] bArr, @pq6 MediaType mediaType) {
            cr4.g(bArr, "<this>");
            return create$default(this, bArr, mediaType, 0, 0, 6, (Object) null);
        }

        public static /* synthetic */ RequestBody create$default(Companion companion, File file, MediaType mediaType, int i, Object obj) {
            if ((i & 1) != 0) {
                mediaType = null;
            }
            return companion.create(file, mediaType);
        }

        @r15
        @s15
        @x15
        @kp6
        public final RequestBody create(@kp6 byte[] bArr, @pq6 MediaType mediaType, int i) {
            cr4.g(bArr, "<this>");
            return create$default(this, bArr, mediaType, i, 0, 4, (Object) null);
        }

        public static /* synthetic */ RequestBody create$default(Companion companion, MediaType mediaType, byte[] bArr, int i, int i2, int i3, Object obj) {
            if ((i3 & 4) != 0) {
                i = 0;
            }
            if ((i3 & 8) != 0) {
                i2 = bArr.length;
            }
            return companion.create(mediaType, bArr, i, i2);
        }

        @x15
        @r15
        @kp6
        public final RequestBody create(@kp6 String str, @pq6 MediaType mediaType) {
            cr4.g(str, "<this>");
            Charset charset = bz0.a;
            if (mediaType != null) {
                Charset charsetCharset$default = MediaType.charset$default(mediaType, null, 1, null);
                if (charsetCharset$default == null) {
                    mediaType = MediaType.INSTANCE.parse(mediaType + "; charset=utf-8");
                } else {
                    charset = charsetCharset$default;
                }
            }
            byte[] bytes = str.getBytes(charset);
            cr4.f(bytes, "this as java.lang.String).getBytes(charset)");
            return create(bytes, mediaType, 0, bytes.length);
        }

        @x15
        @r15
        @kp6
        public final RequestBody create(@kp6 final zo0 zo0Var, @pq6 final MediaType mediaType) {
            cr4.g(zo0Var, "<this>");
            return new RequestBody() { // from class: okhttp3.RequestBody$Companion$toRequestBody$1
                @Override // okhttp3.RequestBody
                public long contentLength() {
                    return zo0Var.e();
                }

                @Override // okhttp3.RequestBody
                @pq6
                /* JADX INFO: renamed from: contentType, reason: from getter */
                public MediaType get$contentType() {
                    return mediaType;
                }

                @Override // okhttp3.RequestBody
                public void writeTo(@kp6 rh0 sink) {
                    cr4.g(sink, "sink");
                    sink.au(zo0Var);
                }
            };
        }

        @r15
        @s15
        @x15
        @kp6
        public final RequestBody create(@kp6 final byte[] bArr, @pq6 final MediaType mediaType, final int i, final int i2) {
            cr4.g(bArr, "<this>");
            Util.checkOffsetAndCount(bArr.length, i, i2);
            return new RequestBody() { // from class: okhttp3.RequestBody$Companion$toRequestBody$2
                @Override // okhttp3.RequestBody
                public long contentLength() {
                    return i2;
                }

                @Override // okhttp3.RequestBody
                @pq6
                /* JADX INFO: renamed from: contentType, reason: from getter */
                public MediaType get$contentType() {
                    return mediaType;
                }

                @Override // okhttp3.RequestBody
                public void writeTo(@kp6 rh0 sink) {
                    cr4.g(sink, "sink");
                    sink.write(bArr, i, i2);
                }
            };
        }

        @x15
        @r15
        @kp6
        public final RequestBody create(@kp6 final File file, @pq6 final MediaType mediaType) {
            cr4.g(file, "<this>");
            return new RequestBody() { // from class: okhttp3.RequestBody$Companion$asRequestBody$1
                @Override // okhttp3.RequestBody
                public long contentLength() {
                    return file.length();
                }

                @Override // okhttp3.RequestBody
                @pq6
                /* JADX INFO: renamed from: contentType, reason: from getter */
                public MediaType get$contentType() {
                    return mediaType;
                }

                @Override // okhttp3.RequestBody
                public void writeTo(@kp6 rh0 sink) throws IOException {
                    cr4.g(sink, "sink");
                    px8 px8VarH = eu6.h(file);
                    try {
                        sink.r(px8VarH);
                        px8VarH.close();
                    } finally {
                    }
                }
            };
        }

        @e52
        @x15
        @kp6
        public final RequestBody create(@pq6 MediaType contentType, @kp6 String content) {
            cr4.g(content, "content");
            return create(content, contentType);
        }

        @e52
        @x15
        @kp6
        public final RequestBody create(@pq6 MediaType contentType, @kp6 zo0 content) {
            cr4.g(content, "content");
            return create(content, contentType);
        }

        @e52
        @s15
        @x15
        @kp6
        public final RequestBody create(@pq6 MediaType contentType, @kp6 byte[] content, int offset, int byteCount) {
            cr4.g(content, "content");
            return create(content, contentType, offset, byteCount);
        }

        @e52
        @x15
        @kp6
        public final RequestBody create(@pq6 MediaType contentType, @kp6 File file) {
            cr4.g(file, "file");
            return create(file, contentType);
        }
    }

    @x15
    @r15
    @kp6
    public static final RequestBody create(@kp6 zo0 zo0Var, @pq6 MediaType mediaType) {
        return INSTANCE.create(zo0Var, mediaType);
    }

    public long contentLength() throws IOException {
        return -1L;
    }

    @pq6
    /* JADX INFO: renamed from: contentType */
    public abstract MediaType get$contentType();

    public boolean isDuplex() {
        return false;
    }

    public boolean isOneShot() {
        return false;
    }

    public abstract void writeTo(@kp6 rh0 sink) throws IOException;

    @x15
    @r15
    @kp6
    public static final RequestBody create(@kp6 File file, @pq6 MediaType mediaType) {
        return INSTANCE.create(file, mediaType);
    }

    @x15
    @r15
    @kp6
    public static final RequestBody create(@kp6 String str, @pq6 MediaType mediaType) {
        return INSTANCE.create(str, mediaType);
    }

    @e52
    @x15
    @kp6
    public static final RequestBody create(@pq6 MediaType mediaType, @kp6 zo0 zo0Var) {
        return INSTANCE.create(mediaType, zo0Var);
    }

    @e52
    @x15
    @kp6
    public static final RequestBody create(@pq6 MediaType mediaType, @kp6 File file) {
        return INSTANCE.create(mediaType, file);
    }

    @e52
    @x15
    @kp6
    public static final RequestBody create(@pq6 MediaType mediaType, @kp6 String str) {
        return INSTANCE.create(mediaType, str);
    }

    @e52
    @s15
    @x15
    @kp6
    public static final RequestBody create(@pq6 MediaType mediaType, @kp6 byte[] bArr) {
        return INSTANCE.create(mediaType, bArr);
    }

    @e52
    @s15
    @x15
    @kp6
    public static final RequestBody create(@pq6 MediaType mediaType, @kp6 byte[] bArr, int i) {
        return INSTANCE.create(mediaType, bArr, i);
    }

    @e52
    @s15
    @x15
    @kp6
    public static final RequestBody create(@pq6 MediaType mediaType, @kp6 byte[] bArr, int i, int i2) {
        return INSTANCE.create(mediaType, bArr, i, i2);
    }

    @r15
    @s15
    @x15
    @kp6
    public static final RequestBody create(@kp6 byte[] bArr) {
        return INSTANCE.create(bArr);
    }

    @r15
    @s15
    @x15
    @kp6
    public static final RequestBody create(@kp6 byte[] bArr, @pq6 MediaType mediaType) {
        return INSTANCE.create(bArr, mediaType);
    }

    @r15
    @s15
    @x15
    @kp6
    public static final RequestBody create(@kp6 byte[] bArr, @pq6 MediaType mediaType, int i) {
        return INSTANCE.create(bArr, mediaType, i);
    }

    @r15
    @s15
    @x15
    @kp6
    public static final RequestBody create(@kp6 byte[] bArr, @pq6 MediaType mediaType, int i, int i2) {
        return INSTANCE.create(bArr, mediaType, i, i2);
    }
}
