package defpackage;

import androidx.media3.container.NalUnitUtil;
import java.io.IOException;
import java.net.SocketTimeoutException;
import kotlin.Metadata;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.Response;

/* JADX INFO: loaded from: classes3.dex */
@Metadata(d1 = {"\u0000\n\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\b\u0002\u0018\u00002\u00020\u0001¨\u0006\u0002"}, d2 = {"Ljt6;", "Lokhttp3/Callback;", "ktor-client-okhttp"}, k = 1, mv = {2, 0, 0}, xi = NalUnitUtil.H265_NAL_UNIT_TYPE_UNSPECIFIED)
final class jt6 implements Callback {
    public final gd4 a;
    public final ts0 b;

    public jt6(gd4 gd4Var, ts0 ts0Var) {
        cr4.g(gd4Var, "requestData");
        this.a = gd4Var;
        this.b = ts0Var;
    }

    @Override // okhttp3.Callback
    public final void onFailure(Call call, IOException iOException) {
        cr4.g(call, "call");
        cr4.g(iOException, "e");
        ts0 ts0Var = this.b;
        ts0Var.getClass();
        if (ts0.i.get(ts0Var) instanceof dt0) {
            return;
        }
        if (iOException instanceof p59) {
            Throwable cause = iOException.getCause();
            if (cause != null) {
                iOException = cause;
            }
        } else if (iOException instanceof SocketTimeoutException) {
            String message = iOException.getMessage();
            gd4 gd4Var = this.a;
            iOException = (message == null || !n89.l(message, "connect", true)) ? te4.b(gd4Var, iOException) : te4.a(gd4Var, iOException);
        }
        ts0Var.resumeWith(s38.a(iOException));
    }

    @Override // okhttp3.Callback
    public final void onResponse(Call call, Response response) {
        cr4.g(call, "call");
        cr4.g(response, "response");
        if (call.getCanceled()) {
            return;
        }
        this.b.resumeWith(response);
    }
}
