package okhttp3.n0.http2;

import io.netty.handler.codec.rtsp.RtspHeaders;
import java.io.Closeable;
import java.io.IOException;
import java.net.Socket;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import kotlin.Metadata;
import kotlin.Unit;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.internal.d0;
import kotlin.jvm.internal.o;
import kotlinx.serialization.json.internal.AbstractJsonLexerKt;
import okhttp3.n0.concurrent.Task;
import okhttp3.n0.concurrent.TaskQueue;
import okhttp3.n0.concurrent.TaskRunner;
import okhttp3.n0.http2.Http2Reader;
import okhttp3.n0.platform.Platform;
import okio.BufferedSink;
import okio.BufferedSource;
import okio.ByteString;

/* JADX INFO: renamed from: y.n0.j.f, reason: from Kotlin metadata */
/* JADX INFO: loaded from: classes2.dex */
@Metadata(d1 = {"\u0000´\u0001\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\t\n\u0002\b\u0002\n\u0002\u0010\u000b\n\u0002\b\u0003\n\u0002\u0010\u000e\n\u0002\b\u0003\n\u0002\u0010#\n\u0002\u0010\b\n\u0002\b\f\n\u0002\u0018\u0002\n\u0002\b\u0006\n\u0002\u0018\u0002\n\u0002\b\u0007\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0007\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010%\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0010\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u000b\n\u0002\u0010 \n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0002\b\u001d\n\u0002\u0018\u0002\n\u0002\b\u0014\u0018\u0000 \u0099\u00012\u00020\u0001:\b\u0098\u0001\u0099\u0001\u009a\u0001\u009b\u0001B\u000f\b\u0000\u0012\u0006\u0010\u0002\u001a\u00020\u0003¢\u0006\u0002\u0010\u0004J\u0006\u0010P\u001a\u00020QJ\b\u0010R\u001a\u00020QH\u0016J'\u0010R\u001a\u00020Q2\u0006\u0010S\u001a\u00020T2\u0006\u0010U\u001a\u00020T2\b\u0010V\u001a\u0004\u0018\u00010WH\u0000¢\u0006\u0002\bXJ\u0012\u0010Y\u001a\u00020Q2\b\u0010Z\u001a\u0004\u0018\u00010WH\u0002J\u0006\u0010[\u001a\u00020QJ\u0010\u0010\\\u001a\u0004\u0018\u00010B2\u0006\u0010]\u001a\u00020\u0012J\u000e\u0010^\u001a\u00020\t2\u0006\u0010_\u001a\u00020\u0006J&\u0010`\u001a\u00020B2\u0006\u0010a\u001a\u00020\u00122\f\u0010b\u001a\b\u0012\u0004\u0012\u00020d0c2\u0006\u0010e\u001a\u00020\tH\u0002J\u001c\u0010`\u001a\u00020B2\f\u0010b\u001a\b\u0012\u0004\u0012\u00020d0c2\u0006\u0010e\u001a\u00020\tJ\u0006\u0010f\u001a\u00020\u0012J-\u0010g\u001a\u00020Q2\u0006\u0010h\u001a\u00020\u00122\u0006\u0010i\u001a\u00020j2\u0006\u0010k\u001a\u00020\u00122\u0006\u0010l\u001a\u00020\tH\u0000¢\u0006\u0002\bmJ+\u0010n\u001a\u00020Q2\u0006\u0010h\u001a\u00020\u00122\f\u0010b\u001a\b\u0012\u0004\u0012\u00020d0c2\u0006\u0010l\u001a\u00020\tH\u0000¢\u0006\u0002\boJ#\u0010p\u001a\u00020Q2\u0006\u0010h\u001a\u00020\u00122\f\u0010b\u001a\b\u0012\u0004\u0012\u00020d0cH\u0000¢\u0006\u0002\bqJ\u001d\u0010r\u001a\u00020Q2\u0006\u0010h\u001a\u00020\u00122\u0006\u0010s\u001a\u00020TH\u0000¢\u0006\u0002\btJ$\u0010u\u001a\u00020B2\u0006\u0010a\u001a\u00020\u00122\f\u0010b\u001a\b\u0012\u0004\u0012\u00020d0c2\u0006\u0010e\u001a\u00020\tJ\u0015\u0010v\u001a\u00020\t2\u0006\u0010h\u001a\u00020\u0012H\u0000¢\u0006\u0002\bwJ\u0017\u0010x\u001a\u0004\u0018\u00010B2\u0006\u0010h\u001a\u00020\u0012H\u0000¢\u0006\u0002\byJ\r\u0010z\u001a\u00020QH\u0000¢\u0006\u0002\b{J\u000e\u0010|\u001a\u00020Q2\u0006\u0010}\u001a\u00020&J\u000e\u0010~\u001a\u00020Q2\u0006\u0010\u007f\u001a\u00020TJ\u001e\u0010\u0080\u0001\u001a\u00020Q2\t\b\u0002\u0010\u0081\u0001\u001a\u00020\t2\b\b\u0002\u0010E\u001a\u00020FH\u0007J\u0018\u0010\u0082\u0001\u001a\u00020Q2\u0007\u0010\u0083\u0001\u001a\u00020\u0006H\u0000¢\u0006\u0003\b\u0084\u0001J,\u0010\u0085\u0001\u001a\u00020Q2\u0006\u0010h\u001a\u00020\u00122\u0007\u0010\u0086\u0001\u001a\u00020\t2\n\u0010\u0087\u0001\u001a\u0005\u0018\u00010\u0088\u00012\u0006\u0010k\u001a\u00020\u0006J/\u0010\u0089\u0001\u001a\u00020Q2\u0006\u0010h\u001a\u00020\u00122\u0007\u0010\u0086\u0001\u001a\u00020\t2\r\u0010\u008a\u0001\u001a\b\u0012\u0004\u0012\u00020d0cH\u0000¢\u0006\u0003\b\u008b\u0001J\u0007\u0010\u008c\u0001\u001a\u00020QJ\"\u0010\u008c\u0001\u001a\u00020Q2\u0007\u0010\u008d\u0001\u001a\u00020\t2\u0007\u0010\u008e\u0001\u001a\u00020\u00122\u0007\u0010\u008f\u0001\u001a\u00020\u0012J\u0007\u0010\u0090\u0001\u001a\u00020QJ\u001f\u0010\u0091\u0001\u001a\u00020Q2\u0006\u0010h\u001a\u00020\u00122\u0006\u0010\u007f\u001a\u00020TH\u0000¢\u0006\u0003\b\u0092\u0001J\u001f\u0010\u0093\u0001\u001a\u00020Q2\u0006\u0010h\u001a\u00020\u00122\u0006\u0010s\u001a\u00020TH\u0000¢\u0006\u0003\b\u0094\u0001J \u0010\u0095\u0001\u001a\u00020Q2\u0006\u0010h\u001a\u00020\u00122\u0007\u0010\u0096\u0001\u001a\u00020\u0006H\u0000¢\u0006\u0003\b\u0097\u0001R\u000e\u0010\u0005\u001a\u00020\u0006X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u0007\u001a\u00020\u0006X\u0082\u000e¢\u0006\u0002\n\u0000R\u0014\u0010\b\u001a\u00020\tX\u0080\u0004¢\u0006\b\n\u0000\u001a\u0004\b\n\u0010\u000bR\u0014\u0010\f\u001a\u00020\rX\u0080\u0004¢\u0006\b\n\u0000\u001a\u0004\b\u000e\u0010\u000fR\u0014\u0010\u0010\u001a\b\u0012\u0004\u0012\u00020\u00120\u0011X\u0082\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\u0013\u001a\u00020\u0006X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u0014\u001a\u00020\u0006X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u0015\u001a\u00020\u0006X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u0016\u001a\u00020\u0006X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u0017\u001a\u00020\u0006X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u0018\u001a\u00020\tX\u0082\u000e¢\u0006\u0002\n\u0000R\u001a\u0010\u0019\u001a\u00020\u0012X\u0080\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\u001a\u0010\u001b\"\u0004\b\u001c\u0010\u001dR\u0014\u0010\u001e\u001a\u00020\u001fX\u0080\u0004¢\u0006\b\n\u0000\u001a\u0004\b \u0010!R\u001a\u0010\"\u001a\u00020\u0012X\u0080\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b#\u0010\u001b\"\u0004\b$\u0010\u001dR\u0011\u0010%\u001a\u00020&¢\u0006\b\n\u0000\u001a\u0004\b'\u0010(R\u001a\u0010)\u001a\u00020&X\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b*\u0010(\"\u0004\b+\u0010,R\u000e\u0010-\u001a\u00020.X\u0082\u0004¢\u0006\u0002\n\u0000R\u000e\u0010/\u001a\u000200X\u0082\u0004¢\u0006\u0002\n\u0000R\u001e\u00102\u001a\u00020\u00062\u0006\u00101\u001a\u00020\u0006@BX\u0086\u000e¢\u0006\b\n\u0000\u001a\u0004\b3\u00104R\u001e\u00105\u001a\u00020\u00062\u0006\u00101\u001a\u00020\u0006@BX\u0086\u000e¢\u0006\b\n\u0000\u001a\u0004\b6\u00104R\u0015\u00107\u001a\u000608R\u00020\u0000¢\u0006\b\n\u0000\u001a\u0004\b9\u0010:R\u000e\u0010;\u001a\u000200X\u0082\u0004¢\u0006\u0002\n\u0000R\u0014\u0010<\u001a\u00020=X\u0080\u0004¢\u0006\b\n\u0000\u001a\u0004\b>\u0010?R \u0010@\u001a\u000e\u0012\u0004\u0012\u00020\u0012\u0012\u0004\u0012\u00020B0AX\u0080\u0004¢\u0006\b\n\u0000\u001a\u0004\bC\u0010DR\u000e\u0010E\u001a\u00020FX\u0082\u0004¢\u0006\u0002\n\u0000R\u001e\u0010G\u001a\u00020\u00062\u0006\u00101\u001a\u00020\u0006@BX\u0086\u000e¢\u0006\b\n\u0000\u001a\u0004\bH\u00104R\u001e\u0010I\u001a\u00020\u00062\u0006\u00101\u001a\u00020\u0006@BX\u0086\u000e¢\u0006\b\n\u0000\u001a\u0004\bJ\u00104R\u0011\u0010K\u001a\u00020L¢\u0006\b\n\u0000\u001a\u0004\bM\u0010NR\u000e\u0010O\u001a\u000200X\u0082\u0004¢\u0006\u0002\n\u0000¨\u0006\u009c\u0001"}, d2 = {"Lokhttp3/internal/http2/Http2Connection;", "Ljava/io/Closeable;", "builder", "Lokhttp3/internal/http2/Http2Connection$Builder;", "(Lokhttp3/internal/http2/Http2Connection$Builder;)V", "awaitPingsSent", "", "awaitPongsReceived", "client", "", "getClient$okhttp", "()Z", "connectionName", "", "getConnectionName$okhttp", "()Ljava/lang/String;", "currentPushRequests", "", "", "degradedPingsSent", "degradedPongDeadlineNs", "degradedPongsReceived", "intervalPingsSent", "intervalPongsReceived", "isShutdown", "lastGoodStreamId", "getLastGoodStreamId$okhttp", "()I", "setLastGoodStreamId$okhttp", "(I)V", "listener", "Lokhttp3/internal/http2/Http2Connection$Listener;", "getListener$okhttp", "()Lokhttp3/internal/http2/Http2Connection$Listener;", "nextStreamId", "getNextStreamId$okhttp", "setNextStreamId$okhttp", "okHttpSettings", "Lokhttp3/internal/http2/Settings;", "getOkHttpSettings", "()Lokhttp3/internal/http2/Settings;", "peerSettings", "getPeerSettings", "setPeerSettings", "(Lokhttp3/internal/http2/Settings;)V", "pushObserver", "Lokhttp3/internal/http2/PushObserver;", "pushQueue", "Lokhttp3/internal/concurrent/TaskQueue;", "<set-?>", "readBytesAcknowledged", "getReadBytesAcknowledged", "()J", "readBytesTotal", "getReadBytesTotal", "readerRunnable", "Lokhttp3/internal/http2/Http2Connection$ReaderRunnable;", "getReaderRunnable", "()Lokhttp3/internal/http2/Http2Connection$ReaderRunnable;", "settingsListenerQueue", "socket", "Ljava/net/Socket;", "getSocket$okhttp", "()Ljava/net/Socket;", "streams", "", "Lokhttp3/internal/http2/Http2Stream;", "getStreams$okhttp", "()Ljava/util/Map;", "taskRunner", "Lokhttp3/internal/concurrent/TaskRunner;", "writeBytesMaximum", "getWriteBytesMaximum", "writeBytesTotal", "getWriteBytesTotal", "writer", "Lokhttp3/internal/http2/Http2Writer;", "getWriter", "()Lokhttp3/internal/http2/Http2Writer;", "writerQueue", "awaitPong", "", "close", "connectionCode", "Lokhttp3/internal/http2/ErrorCode;", "streamCode", "cause", "Ljava/io/IOException;", "close$okhttp", "failConnection", "e", "flush", "getStream", "id", "isHealthy", "nowNs", "newStream", "associatedStreamId", "requestHeaders", "", "Lokhttp3/internal/http2/Header;", "out", "openStreamCount", "pushDataLater", "streamId", "source", "Lokio/BufferedSource;", "byteCount", "inFinished", "pushDataLater$okhttp", "pushHeadersLater", "pushHeadersLater$okhttp", "pushRequestLater", "pushRequestLater$okhttp", "pushResetLater", "errorCode", "pushResetLater$okhttp", "pushStream", "pushedStream", "pushedStream$okhttp", "removeStream", "removeStream$okhttp", "sendDegradedPingLater", "sendDegradedPingLater$okhttp", "setSettings", "settings", "shutdown", "statusCode", "start", "sendConnectionPreface", "updateConnectionFlowControl", "read", "updateConnectionFlowControl$okhttp", "writeData", "outFinished", "buffer", "Lokio/Buffer;", "writeHeaders", "alternating", "writeHeaders$okhttp", "writePing", "reply", "payload1", "payload2", "writePingAndAwaitPong", "writeSynReset", "writeSynReset$okhttp", "writeSynResetLater", "writeSynResetLater$okhttp", "writeWindowUpdateLater", "unacknowledgedBytesRead", "writeWindowUpdateLater$okhttp", "Builder", "Companion", "Listener", "ReaderRunnable", "okhttp"}, k = 1, mv = {1, 6, 0}, xi = 48)
public final class Http2Connection implements Closeable {

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public static final Http2Connection f9907f = null;

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    public static final Settings f9908m;
    public long A;
    public long B;
    public long C;
    public long D;
    public long E;
    public final Settings F;
    public Settings G;
    public long H;
    public long I;
    public long J;
    public long K;
    public final Socket L;
    public final Http2Writer M;
    public final c N;
    public final Set<Integer> O;

    /* JADX INFO: renamed from: n, reason: collision with root package name */
    public final boolean f9909n;

    /* JADX INFO: renamed from: o, reason: collision with root package name */
    public final b f9910o;

    /* JADX INFO: renamed from: p, reason: collision with root package name */
    public final Map<Integer, Http2Stream> f9911p;

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

    /* JADX INFO: renamed from: r, reason: collision with root package name */
    public int f9913r;

    /* JADX INFO: renamed from: s, reason: collision with root package name */
    public int f9914s;

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

    /* JADX INFO: renamed from: u, reason: collision with root package name */
    public final TaskRunner f9916u;

    /* JADX INFO: renamed from: v, reason: collision with root package name */
    public final TaskQueue f9917v;

    /* JADX INFO: renamed from: w, reason: collision with root package name */
    public final TaskQueue f9918w;

    /* JADX INFO: renamed from: x, reason: collision with root package name */
    public final TaskQueue f9919x;

    /* JADX INFO: renamed from: y, reason: collision with root package name */
    public final PushObserver f9920y;

    /* JADX INFO: renamed from: z, reason: collision with root package name */
    public long f9921z;

    /* JADX INFO: renamed from: y.n0.j.f$a */
    @Metadata(d1 = {"\u0000X\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0000\n\u0002\u0010\u000b\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0006\n\u0002\u0010\u000e\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0010\b\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0002\b\u0007\n\u0002\u0018\u0002\n\u0002\b\u0002\u0018\u00002\u00020\u0001B\u0015\u0012\u0006\u0010\u0002\u001a\u00020\u0003\u0012\u0006\u0010\u0004\u001a\u00020\u0005¢\u0006\u0002\u0010\u0006J\u0006\u00107\u001a\u000208J\u000e\u0010\u0011\u001a\u00020\u00002\u0006\u0010\u0011\u001a\u00020\u0012J\u000e\u0010\u0017\u001a\u00020\u00002\u0006\u0010\u0017\u001a\u00020\u0018J\u000e\u0010\u001d\u001a\u00020\u00002\u0006\u0010\u001d\u001a\u00020\u001eJ.\u0010)\u001a\u00020\u00002\u0006\u0010)\u001a\u00020*2\b\b\u0002\u00109\u001a\u00020\f2\b\b\u0002\u0010/\u001a\u0002002\b\b\u0002\u0010#\u001a\u00020$H\u0007R\u001a\u0010\u0002\u001a\u00020\u0003X\u0080\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\u0007\u0010\b\"\u0004\b\t\u0010\nR\u001a\u0010\u000b\u001a\u00020\fX\u0080.¢\u0006\u000e\n\u0000\u001a\u0004\b\r\u0010\u000e\"\u0004\b\u000f\u0010\u0010R\u001a\u0010\u0011\u001a\u00020\u0012X\u0080\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\u0013\u0010\u0014\"\u0004\b\u0015\u0010\u0016R\u001a\u0010\u0017\u001a\u00020\u0018X\u0080\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\u0019\u0010\u001a\"\u0004\b\u001b\u0010\u001cR\u001a\u0010\u001d\u001a\u00020\u001eX\u0080\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\u001f\u0010 \"\u0004\b!\u0010\"R\u001a\u0010#\u001a\u00020$X\u0080.¢\u0006\u000e\n\u0000\u001a\u0004\b%\u0010&\"\u0004\b'\u0010(R\u001a\u0010)\u001a\u00020*X\u0080.¢\u0006\u000e\n\u0000\u001a\u0004\b+\u0010,\"\u0004\b-\u0010.R\u001a\u0010/\u001a\u000200X\u0080.¢\u0006\u000e\n\u0000\u001a\u0004\b1\u00102\"\u0004\b3\u00104R\u0014\u0010\u0004\u001a\u00020\u0005X\u0080\u0004¢\u0006\b\n\u0000\u001a\u0004\b5\u00106¨\u0006:"}, d2 = {"Lokhttp3/internal/http2/Http2Connection$Builder;", "", "client", "", "taskRunner", "Lokhttp3/internal/concurrent/TaskRunner;", "(ZLokhttp3/internal/concurrent/TaskRunner;)V", "getClient$okhttp", "()Z", "setClient$okhttp", "(Z)V", "connectionName", "", "getConnectionName$okhttp", "()Ljava/lang/String;", "setConnectionName$okhttp", "(Ljava/lang/String;)V", "listener", "Lokhttp3/internal/http2/Http2Connection$Listener;", "getListener$okhttp", "()Lokhttp3/internal/http2/Http2Connection$Listener;", "setListener$okhttp", "(Lokhttp3/internal/http2/Http2Connection$Listener;)V", "pingIntervalMillis", "", "getPingIntervalMillis$okhttp", "()I", "setPingIntervalMillis$okhttp", "(I)V", "pushObserver", "Lokhttp3/internal/http2/PushObserver;", "getPushObserver$okhttp", "()Lokhttp3/internal/http2/PushObserver;", "setPushObserver$okhttp", "(Lokhttp3/internal/http2/PushObserver;)V", "sink", "Lokio/BufferedSink;", "getSink$okhttp", "()Lokio/BufferedSink;", "setSink$okhttp", "(Lokio/BufferedSink;)V", "socket", "Ljava/net/Socket;", "getSocket$okhttp", "()Ljava/net/Socket;", "setSocket$okhttp", "(Ljava/net/Socket;)V", "source", "Lokio/BufferedSource;", "getSource$okhttp", "()Lokio/BufferedSource;", "setSource$okhttp", "(Lokio/BufferedSource;)V", "getTaskRunner$okhttp", "()Lokhttp3/internal/concurrent/TaskRunner;", "build", "Lokhttp3/internal/http2/Http2Connection;", "peerName", "okhttp"}, k = 1, mv = {1, 6, 0}, xi = 48)
    public static final class a {
        public boolean a;

        /* JADX INFO: renamed from: b, reason: collision with root package name */
        public final TaskRunner f9922b;

        /* JADX INFO: renamed from: c, reason: collision with root package name */
        public Socket f9923c;

        /* JADX INFO: renamed from: d, reason: collision with root package name */
        public String f9924d;

        /* JADX INFO: renamed from: e, reason: collision with root package name */
        public BufferedSource f9925e;

        /* JADX INFO: renamed from: f, reason: collision with root package name */
        public BufferedSink f9926f;

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

        /* JADX INFO: renamed from: h, reason: collision with root package name */
        public PushObserver f9928h;

        /* JADX INFO: renamed from: i, reason: collision with root package name */
        public int f9929i;

        public a(boolean z2, TaskRunner taskRunner) {
            o.f(taskRunner, "taskRunner");
            this.a = z2;
            this.f9922b = taskRunner;
            this.f9927g = b.a;
            this.f9928h = PushObserver.a;
        }
    }

    /* JADX INFO: renamed from: y.n0.j.f$b */
    @Metadata(d1 = {"\u0000(\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0010\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\b&\u0018\u0000 \f2\u00020\u0001:\u0001\fB\u0005¢\u0006\u0002\u0010\u0002J\u0018\u0010\u0003\u001a\u00020\u00042\u0006\u0010\u0005\u001a\u00020\u00062\u0006\u0010\u0007\u001a\u00020\bH\u0016J\u0010\u0010\t\u001a\u00020\u00042\u0006\u0010\n\u001a\u00020\u000bH&¨\u0006\r"}, d2 = {"Lokhttp3/internal/http2/Http2Connection$Listener;", "", "()V", "onSettings", "", "connection", "Lokhttp3/internal/http2/Http2Connection;", "settings", "Lokhttp3/internal/http2/Settings;", "onStream", "stream", "Lokhttp3/internal/http2/Http2Stream;", "Companion", "okhttp"}, k = 1, mv = {1, 6, 0}, xi = 48)
    public static abstract class b {
        public static final b a = new a();

        /* JADX INFO: renamed from: y.n0.j.f$b$a */
        @Metadata(d1 = {"\u0000\u0017\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000*\u0001\u0000\b\n\u0018\u00002\u00020\u0001J\u0010\u0010\u0002\u001a\u00020\u00032\u0006\u0010\u0004\u001a\u00020\u0005H\u0016¨\u0006\u0006"}, d2 = {"okhttp3/internal/http2/Http2Connection$Listener$Companion$REFUSE_INCOMING_STREAMS$1", "Lokhttp3/internal/http2/Http2Connection$Listener;", "onStream", "", "stream", "Lokhttp3/internal/http2/Http2Stream;", "okhttp"}, k = 1, mv = {1, 6, 0}, xi = 48)
        public static final class a extends b {
            @Override // okhttp3.n0.http2.Http2Connection.b
            public void b(Http2Stream http2Stream) {
                o.f(http2Stream, "stream");
                http2Stream.c(ErrorCode.REFUSED_STREAM, null);
            }
        }

        public void a(Http2Connection http2Connection, Settings settings) {
            o.f(http2Connection, "connection");
            o.f(settings, "settings");
        }

        public abstract void b(Http2Stream http2Stream);
    }

    /* JADX INFO: renamed from: y.n0.j.f$c */
    @Metadata(d1 = {"\u0000`\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0010\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0006\n\u0002\u0010\b\n\u0000\n\u0002\u0010\u000e\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010\t\n\u0002\b\u0002\n\u0002\u0010\u000b\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0010 \n\u0002\u0018\u0002\n\u0002\b\u0010\b\u0086\u0004\u0018\u00002\u00020\u00012\b\u0012\u0004\u0012\u00020\u00030\u0002B\u000f\b\u0000\u0012\u0006\u0010\u0004\u001a\u00020\u0005¢\u0006\u0002\u0010\u0006J\b\u0010\t\u001a\u00020\u0003H\u0016J8\u0010\n\u001a\u00020\u00032\u0006\u0010\u000b\u001a\u00020\f2\u0006\u0010\r\u001a\u00020\u000e2\u0006\u0010\u000f\u001a\u00020\u00102\u0006\u0010\u0011\u001a\u00020\u000e2\u0006\u0010\u0012\u001a\u00020\f2\u0006\u0010\u0013\u001a\u00020\u0014H\u0016J\u0016\u0010\u0015\u001a\u00020\u00032\u0006\u0010\u0016\u001a\u00020\u00172\u0006\u0010\u0018\u001a\u00020\u0019J(\u0010\u001a\u001a\u00020\u00032\u0006\u0010\u001b\u001a\u00020\u00172\u0006\u0010\u000b\u001a\u00020\f2\u0006\u0010\u001c\u001a\u00020\u001d2\u0006\u0010\u001e\u001a\u00020\fH\u0016J \u0010\u001f\u001a\u00020\u00032\u0006\u0010 \u001a\u00020\f2\u0006\u0010!\u001a\u00020\"2\u0006\u0010#\u001a\u00020\u0010H\u0016J.\u0010$\u001a\u00020\u00032\u0006\u0010\u001b\u001a\u00020\u00172\u0006\u0010\u000b\u001a\u00020\f2\u0006\u0010%\u001a\u00020\f2\f\u0010&\u001a\b\u0012\u0004\u0012\u00020(0'H\u0016J\t\u0010)\u001a\u00020\u0003H\u0096\u0002J \u0010*\u001a\u00020\u00032\u0006\u0010+\u001a\u00020\u00172\u0006\u0010,\u001a\u00020\f2\u0006\u0010-\u001a\u00020\fH\u0016J(\u0010.\u001a\u00020\u00032\u0006\u0010\u000b\u001a\u00020\f2\u0006\u0010/\u001a\u00020\f2\u0006\u00100\u001a\u00020\f2\u0006\u00101\u001a\u00020\u0017H\u0016J&\u00102\u001a\u00020\u00032\u0006\u0010\u000b\u001a\u00020\f2\u0006\u00103\u001a\u00020\f2\f\u00104\u001a\b\u0012\u0004\u0012\u00020(0'H\u0016J\u0018\u00105\u001a\u00020\u00032\u0006\u0010\u000b\u001a\u00020\f2\u0006\u0010!\u001a\u00020\"H\u0016J\u0018\u0010\u0018\u001a\u00020\u00032\u0006\u0010\u0016\u001a\u00020\u00172\u0006\u0010\u0018\u001a\u00020\u0019H\u0016J\u0018\u00106\u001a\u00020\u00032\u0006\u0010\u000b\u001a\u00020\f2\u0006\u00107\u001a\u00020\u0014H\u0016R\u0014\u0010\u0004\u001a\u00020\u0005X\u0080\u0004¢\u0006\b\n\u0000\u001a\u0004\b\u0007\u0010\b¨\u00068"}, d2 = {"Lokhttp3/internal/http2/Http2Connection$ReaderRunnable;", "Lokhttp3/internal/http2/Http2Reader$Handler;", "Lkotlin/Function0;", "", "reader", "Lokhttp3/internal/http2/Http2Reader;", "(Lokhttp3/internal/http2/Http2Connection;Lokhttp3/internal/http2/Http2Reader;)V", "getReader$okhttp", "()Lokhttp3/internal/http2/Http2Reader;", "ackSettings", "alternateService", "streamId", "", "origin", "", "protocol", "Lokio/ByteString;", "host", RtspHeaders.Values.PORT, "maxAge", "", "applyAndAckSettings", "clearPrevious", "", "settings", "Lokhttp3/internal/http2/Settings;", "data", "inFinished", "source", "Lokio/BufferedSource;", "length", "goAway", "lastGoodStreamId", "errorCode", "Lokhttp3/internal/http2/ErrorCode;", "debugData", "headers", "associatedStreamId", "headerBlock", "", "Lokhttp3/internal/http2/Header;", "invoke", "ping", "ack", "payload1", "payload2", "priority", "streamDependency", "weight", "exclusive", "pushPromise", "promisedStreamId", "requestHeaders", "rstStream", "windowUpdate", "windowSizeIncrement", "okhttp"}, k = 1, mv = {1, 6, 0}, xi = 48)
    public final class c implements Http2Reader.b, Function0<Unit> {

        /* JADX INFO: renamed from: f, reason: collision with root package name */
        public final Http2Reader f9930f;

        /* JADX INFO: renamed from: m, reason: collision with root package name */
        public final /* synthetic */ Http2Connection f9931m;

        /* JADX INFO: renamed from: y.n0.j.f$c$a */
        @Metadata(d1 = {"\u0000\u0011\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\t\n\u0000*\u0001\u0000\b\n\u0018\u00002\u00020\u0001J\b\u0010\u0002\u001a\u00020\u0003H\u0016¨\u0006\u0004¸\u0006\u0000"}, d2 = {"okhttp3/internal/concurrent/TaskQueue$execute$1", "Lokhttp3/internal/concurrent/Task;", "runOnce", "", "okhttp"}, k = 1, mv = {1, 6, 0}, xi = 48)
        public static final class a extends Task {

            /* JADX INFO: renamed from: e, reason: collision with root package name */
            public final /* synthetic */ Http2Connection f9932e;

            /* JADX INFO: renamed from: f, reason: collision with root package name */
            public final /* synthetic */ Http2Stream f9933f;

            /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
            public a(String str, boolean z2, Http2Connection http2Connection, Http2Stream http2Stream) {
                super(str, z2);
                this.f9932e = http2Connection;
                this.f9933f = http2Stream;
            }

            @Override // okhttp3.n0.concurrent.Task
            public long a() {
                try {
                    this.f9932e.f9910o.b(this.f9933f);
                    return -1L;
                } catch (IOException e2) {
                    Platform.a aVar = Platform.a;
                    Platform.f10049b.i(o.l("Http2Connection.Listener failure for ", this.f9932e.f9912q), 4, e2);
                    try {
                        this.f9933f.c(ErrorCode.PROTOCOL_ERROR, e2);
                        return -1L;
                    } catch (IOException unused) {
                        return -1L;
                    }
                }
            }
        }

        /* JADX INFO: renamed from: y.n0.j.f$c$b */
        @Metadata(d1 = {"\u0000\u0011\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\t\n\u0000*\u0001\u0000\b\n\u0018\u00002\u00020\u0001J\b\u0010\u0002\u001a\u00020\u0003H\u0016¨\u0006\u0004¸\u0006\u0000"}, d2 = {"okhttp3/internal/concurrent/TaskQueue$execute$1", "Lokhttp3/internal/concurrent/Task;", "runOnce", "", "okhttp"}, k = 1, mv = {1, 6, 0}, xi = 48)
        public static final class b extends Task {

            /* JADX INFO: renamed from: e, reason: collision with root package name */
            public final /* synthetic */ Http2Connection f9934e;

            /* JADX INFO: renamed from: f, reason: collision with root package name */
            public final /* synthetic */ int f9935f;

            /* JADX INFO: renamed from: g, reason: collision with root package name */
            public final /* synthetic */ int f9936g;

            /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
            public b(String str, boolean z2, Http2Connection http2Connection, int i2, int i3) {
                super(str, z2);
                this.f9934e = http2Connection;
                this.f9935f = i2;
                this.f9936g = i3;
            }

            @Override // okhttp3.n0.concurrent.Task
            public long a() {
                this.f9934e.l(true, this.f9935f, this.f9936g);
                return -1L;
            }
        }

        /* JADX INFO: renamed from: y.n0.j.f$c$c, reason: collision with other inner class name */
        @Metadata(d1 = {"\u0000\u0011\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\t\n\u0000*\u0001\u0000\b\n\u0018\u00002\u00020\u0001J\b\u0010\u0002\u001a\u00020\u0003H\u0016¨\u0006\u0004¸\u0006\u0000"}, d2 = {"okhttp3/internal/concurrent/TaskQueue$execute$1", "Lokhttp3/internal/concurrent/Task;", "runOnce", "", "okhttp"}, k = 1, mv = {1, 6, 0}, xi = 48)
        public static final class C0184c extends Task {

            /* JADX INFO: renamed from: e, reason: collision with root package name */
            public final /* synthetic */ c f9937e;

            /* JADX INFO: renamed from: f, reason: collision with root package name */
            public final /* synthetic */ boolean f9938f;

            /* JADX INFO: renamed from: g, reason: collision with root package name */
            public final /* synthetic */ Settings f9939g;

            /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
            public C0184c(String str, boolean z2, c cVar, boolean z3, Settings settings) {
                super(str, z2);
                this.f9937e = cVar;
                this.f9938f = z3;
                this.f9939g = settings;
            }

            /* JADX WARN: Multi-variable type inference failed */
            /* JADX WARN: Type inference failed for: r2v1 */
            /* JADX WARN: Type inference failed for: r2v2, types: [T, y.n0.j.t] */
            /* JADX WARN: Type inference failed for: r2v3 */
            @Override // okhttp3.n0.concurrent.Task
            public long a() {
                ?? r2;
                long jA;
                int i2;
                Http2Stream[] http2StreamArr;
                c cVar = this.f9937e;
                boolean z2 = this.f9938f;
                Settings settings = this.f9939g;
                Objects.requireNonNull(cVar);
                o.f(settings, "settings");
                d0 d0Var = new d0();
                Http2Connection http2Connection = cVar.f9931m;
                synchronized (http2Connection.M) {
                    synchronized (http2Connection) {
                        Settings settings2 = http2Connection.G;
                        if (z2) {
                            r2 = settings;
                        } else {
                            Settings settings3 = new Settings();
                            settings3.b(settings2);
                            settings3.b(settings);
                            r2 = settings3;
                        }
                        d0Var.f6165f = r2;
                        jA = ((long) r2.a()) - ((long) settings2.a());
                        i2 = 0;
                        if (jA == 0 || http2Connection.f9911p.isEmpty()) {
                            http2StreamArr = null;
                        } else {
                            Object[] array = http2Connection.f9911p.values().toArray(new Http2Stream[0]);
                            if (array == null) {
                                throw new NullPointerException("null cannot be cast to non-null type kotlin.Array<T of kotlin.collections.ArraysKt__ArraysJVMKt.toTypedArray>");
                            }
                            http2StreamArr = (Http2Stream[]) array;
                        }
                        Settings settings4 = (Settings) d0Var.f6165f;
                        o.f(settings4, "<set-?>");
                        http2Connection.G = settings4;
                        http2Connection.f9919x.c(new g(o.l(http2Connection.f9912q, " onSettings"), true, http2Connection, d0Var), 0L);
                    }
                    try {
                        http2Connection.M.a((Settings) d0Var.f6165f);
                    } catch (IOException e2) {
                        ErrorCode errorCode = ErrorCode.PROTOCOL_ERROR;
                        http2Connection.a(errorCode, errorCode, e2);
                    }
                }
                if (http2StreamArr == null) {
                    return -1L;
                }
                int length = http2StreamArr.length;
                while (i2 < length) {
                    Http2Stream http2Stream = http2StreamArr[i2];
                    i2++;
                    synchronized (http2Stream) {
                        http2Stream.f9989f += jA;
                        if (jA > 0) {
                            http2Stream.notifyAll();
                        }
                    }
                }
                return -1L;
            }
        }

        public c(Http2Connection http2Connection, Http2Reader http2Reader) {
            o.f(http2Connection, "this$0");
            o.f(http2Reader, "reader");
            this.f9931m = http2Connection;
            this.f9930f = http2Reader;
        }

        @Override // okhttp3.n0.http2.Http2Reader.b
        public void a() {
        }

        @Override // okhttp3.n0.http2.Http2Reader.b
        public void b(boolean z2, Settings settings) {
            o.f(settings, "settings");
            Http2Connection http2Connection = this.f9931m;
            http2Connection.f9917v.c(new C0184c(o.l(http2Connection.f9912q, " applyAndAckSettings"), true, this, z2, settings), 0L);
        }

        @Override // okhttp3.n0.http2.Http2Reader.b
        public void c(boolean z2, int i2, int i3, List<Header> list) {
            o.f(list, "headerBlock");
            if (this.f9931m.d(i2)) {
                Http2Connection http2Connection = this.f9931m;
                Objects.requireNonNull(http2Connection);
                o.f(list, "requestHeaders");
                http2Connection.f9918w.c(new i(http2Connection.f9912q + AbstractJsonLexerKt.BEGIN_LIST + i2 + "] onHeaders", true, http2Connection, i2, list, z2), 0L);
                return;
            }
            Http2Connection http2Connection2 = this.f9931m;
            synchronized (http2Connection2) {
                Http2Stream http2StreamC = http2Connection2.c(i2);
                if (http2StreamC != null) {
                    http2StreamC.j(okhttp3.n0.c.x(list), z2);
                    return;
                }
                if (http2Connection2.f9915t) {
                    return;
                }
                if (i2 <= http2Connection2.f9913r) {
                    return;
                }
                if (i2 % 2 == http2Connection2.f9914s % 2) {
                    return;
                }
                Http2Stream http2Stream = new Http2Stream(i2, http2Connection2, false, z2, okhttp3.n0.c.x(list));
                http2Connection2.f9913r = i2;
                http2Connection2.f9911p.put(Integer.valueOf(i2), http2Stream);
                http2Connection2.f9916u.f().c(new a(http2Connection2.f9912q + AbstractJsonLexerKt.BEGIN_LIST + i2 + "] onStream", true, http2Connection2, http2Stream), 0L);
            }
        }

        @Override // okhttp3.n0.http2.Http2Reader.b
        public void d(int i2, long j2) {
            Object obj;
            if (i2 == 0) {
                Http2Connection http2Connection = this.f9931m;
                synchronized (http2Connection) {
                    http2Connection.K += j2;
                    http2Connection.notifyAll();
                    obj = http2Connection;
                }
            } else {
                Http2Stream http2StreamC = this.f9931m.c(i2);
                if (http2StreamC == null) {
                    return;
                }
                synchronized (http2StreamC) {
                    http2StreamC.f9989f += j2;
                    obj = http2StreamC;
                    if (j2 > 0) {
                        http2StreamC.notifyAll();
                        obj = http2StreamC;
                    }
                }
            }
        }

        /* JADX WARN: Code restructure failed: missing block: B:52:0x00ee, code lost:
        
            if (r12 == false) goto L67;
         */
        /* JADX WARN: Code restructure failed: missing block: B:53:0x00f0, code lost:
        
            r0.j(okhttp3.n0.c.f9712b, true);
         */
        /* JADX WARN: Code restructure failed: missing block: B:54:0x00f5, code lost:
        
            return;
         */
        /* JADX WARN: Code restructure failed: missing block: B:67:?, code lost:
        
            return;
         */
        @Override // okhttp3.n0.http2.Http2Reader.b
        /*
            Code decompiled incorrectly, please refer to instructions dump.
            To view partially-correct add '--show-bad-code' argument
        */
        public void e(boolean r12, int r13, okio.BufferedSource r14, int r15) throws java.io.EOFException {
            /*
                Method dump skipped, instruction units count: 246
                To view this dump add '--comments-level debug' option
            */
            throw new UnsupportedOperationException("Method not decompiled: okhttp3.n0.http2.Http2Connection.c.e(boolean, int, z.f, int):void");
        }

        @Override // okhttp3.n0.http2.Http2Reader.b
        public void h(boolean z2, int i2, int i3) {
            if (!z2) {
                Http2Connection http2Connection = this.f9931m;
                http2Connection.f9917v.c(new b(o.l(http2Connection.f9912q, " ping"), true, this.f9931m, i2, i3), 0L);
                return;
            }
            Http2Connection http2Connection2 = this.f9931m;
            synchronized (http2Connection2) {
                if (i2 == 1) {
                    http2Connection2.A++;
                } else if (i2 == 2) {
                    http2Connection2.C++;
                } else if (i2 == 3) {
                    http2Connection2.D++;
                    http2Connection2.notifyAll();
                }
            }
        }

        @Override // okhttp3.n0.http2.Http2Reader.b
        public void i(int i2, int i3, int i4, boolean z2) {
        }

        /* JADX WARN: Multi-variable type inference failed */
        /* JADX WARN: Type inference failed for: r0v0, types: [y.n0.j.b] */
        /* JADX WARN: Type inference failed for: r0v3 */
        /* JADX WARN: Type inference failed for: r0v6, types: [kotlin.Unit] */
        /* JADX WARN: Type inference fix 'apply assigned field type' failed
        java.lang.UnsupportedOperationException: ArgType.getObject(), call class: class jadx.core.dex.instructions.args.ArgType$UnknownArg
        	at jadx.core.dex.instructions.args.ArgType.getObject(ArgType.java:593)
        	at jadx.core.dex.attributes.nodes.ClassTypeVarsAttr.getTypeVarsMapFor(ClassTypeVarsAttr.java:35)
        	at jadx.core.dex.nodes.utils.TypeUtils.replaceClassGenerics(TypeUtils.java:177)
        	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.insertExplicitUseCast(FixTypesVisitor.java:397)
        	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.tryFieldTypeWithNewCasts(FixTypesVisitor.java:359)
        	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.applyFieldType(FixTypesVisitor.java:309)
        	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.visit(FixTypesVisitor.java:94)
         */
        @Override // kotlin.jvm.functions.Function0
        public Unit invoke() throws Throwable {
            Throwable th;
            ErrorCode errorCode;
            ErrorCode errorCode2 = ErrorCode.INTERNAL_ERROR;
            IOException e2 = null;
            try {
                try {
                    this.f9930f.c(this);
                    while (this.f9930f.a(false, this)) {
                    }
                    ErrorCode errorCode3 = ErrorCode.NO_ERROR;
                    try {
                        this.f9931m.a(errorCode3, ErrorCode.CANCEL, null);
                        errorCode = errorCode3;
                    } catch (IOException e3) {
                        e2 = e3;
                        ErrorCode errorCode4 = ErrorCode.PROTOCOL_ERROR;
                        Http2Connection http2Connection = this.f9931m;
                        http2Connection.a(errorCode4, errorCode4, e2);
                        errorCode = http2Connection;
                    }
                } catch (Throwable th2) {
                    th = th2;
                    this.f9931m.a(errorCode, errorCode2, e2);
                    okhttp3.n0.c.e(this.f9930f);
                    throw th;
                }
            } catch (IOException e4) {
                e2 = e4;
            } catch (Throwable th3) {
                th = th3;
                errorCode = errorCode2;
                this.f9931m.a(errorCode, errorCode2, e2);
                okhttp3.n0.c.e(this.f9930f);
                throw th;
            }
            okhttp3.n0.c.e(this.f9930f);
            errorCode2 = Unit.a;
            return errorCode2;
        }

        @Override // okhttp3.n0.http2.Http2Reader.b
        public void j(int i2, ErrorCode errorCode) {
            o.f(errorCode, "errorCode");
            if (!this.f9931m.d(i2)) {
                Http2Stream http2StreamE = this.f9931m.e(i2);
                if (http2StreamE == null) {
                    return;
                }
                http2StreamE.k(errorCode);
                return;
            }
            Http2Connection http2Connection = this.f9931m;
            Objects.requireNonNull(http2Connection);
            o.f(errorCode, "errorCode");
            http2Connection.f9918w.c(new k(http2Connection.f9912q + AbstractJsonLexerKt.BEGIN_LIST + i2 + "] onReset", true, http2Connection, i2, errorCode), 0L);
        }

        @Override // okhttp3.n0.http2.Http2Reader.b
        public void k(int i2, int i3, List<Header> list) {
            o.f(list, "requestHeaders");
            Http2Connection http2Connection = this.f9931m;
            Objects.requireNonNull(http2Connection);
            o.f(list, "requestHeaders");
            synchronized (http2Connection) {
                if (http2Connection.O.contains(Integer.valueOf(i3))) {
                    http2Connection.m(i3, ErrorCode.PROTOCOL_ERROR);
                    return;
                }
                http2Connection.O.add(Integer.valueOf(i3));
                http2Connection.f9918w.c(new j(http2Connection.f9912q + AbstractJsonLexerKt.BEGIN_LIST + i3 + "] onRequest", true, http2Connection, i3, list), 0L);
            }
        }

        @Override // okhttp3.n0.http2.Http2Reader.b
        public void l(int i2, ErrorCode errorCode, ByteString byteString) {
            int i3;
            Object[] array;
            o.f(errorCode, "errorCode");
            o.f(byteString, "debugData");
            byteString.g();
            Http2Connection http2Connection = this.f9931m;
            synchronized (http2Connection) {
                i3 = 0;
                array = http2Connection.f9911p.values().toArray(new Http2Stream[0]);
                if (array == null) {
                    throw new NullPointerException("null cannot be cast to non-null type kotlin.Array<T of kotlin.collections.ArraysKt__ArraysJVMKt.toTypedArray>");
                }
                http2Connection.f9915t = true;
            }
            Http2Stream[] http2StreamArr = (Http2Stream[]) array;
            int length = http2StreamArr.length;
            while (i3 < length) {
                Http2Stream http2Stream = http2StreamArr[i3];
                i3++;
                if (http2Stream.a > i2 && http2Stream.h()) {
                    http2Stream.k(ErrorCode.REFUSED_STREAM);
                    this.f9931m.e(http2Stream.a);
                }
            }
        }
    }

    /* JADX INFO: renamed from: y.n0.j.f$d */
    @Metadata(d1 = {"\u0000\u0011\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\t\n\u0000*\u0001\u0000\b\n\u0018\u00002\u00020\u0001J\b\u0010\u0002\u001a\u00020\u0003H\u0016¨\u0006\u0004¸\u0006\u0000"}, d2 = {"okhttp3/internal/concurrent/TaskQueue$schedule$2", "Lokhttp3/internal/concurrent/Task;", "runOnce", "", "okhttp"}, k = 1, mv = {1, 6, 0}, xi = 48)
    public static final class d extends Task {

        /* JADX INFO: renamed from: e, reason: collision with root package name */
        public final /* synthetic */ Http2Connection f9940e;

        /* JADX INFO: renamed from: f, reason: collision with root package name */
        public final /* synthetic */ long f9941f;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        public d(String str, Http2Connection http2Connection, long j2) {
            super(str, true);
            this.f9940e = http2Connection;
            this.f9941f = j2;
        }

        @Override // okhttp3.n0.concurrent.Task
        public long a() {
            Http2Connection http2Connection;
            boolean z2;
            synchronized (this.f9940e) {
                http2Connection = this.f9940e;
                long j2 = http2Connection.A;
                long j3 = http2Connection.f9921z;
                if (j2 < j3) {
                    z2 = true;
                } else {
                    http2Connection.f9921z = j3 + 1;
                    z2 = false;
                }
            }
            if (!z2) {
                http2Connection.l(false, 1, 0);
                return this.f9941f;
            }
            ErrorCode errorCode = ErrorCode.PROTOCOL_ERROR;
            http2Connection.a(errorCode, errorCode, null);
            return -1L;
        }
    }

    /* JADX INFO: renamed from: y.n0.j.f$e */
    @Metadata(d1 = {"\u0000\u0011\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\t\n\u0000*\u0001\u0000\b\n\u0018\u00002\u00020\u0001J\b\u0010\u0002\u001a\u00020\u0003H\u0016¨\u0006\u0004¸\u0006\u0000"}, d2 = {"okhttp3/internal/concurrent/TaskQueue$execute$1", "Lokhttp3/internal/concurrent/Task;", "runOnce", "", "okhttp"}, k = 1, mv = {1, 6, 0}, xi = 48)
    public static final class e extends Task {

        /* JADX INFO: renamed from: e, reason: collision with root package name */
        public final /* synthetic */ Http2Connection f9942e;

        /* JADX INFO: renamed from: f, reason: collision with root package name */
        public final /* synthetic */ int f9943f;

        /* JADX INFO: renamed from: g, reason: collision with root package name */
        public final /* synthetic */ ErrorCode f9944g;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        public e(String str, boolean z2, Http2Connection http2Connection, int i2, ErrorCode errorCode) {
            super(str, z2);
            this.f9942e = http2Connection;
            this.f9943f = i2;
            this.f9944g = errorCode;
        }

        @Override // okhttp3.n0.concurrent.Task
        public long a() {
            try {
                Http2Connection http2Connection = this.f9942e;
                int i2 = this.f9943f;
                ErrorCode errorCode = this.f9944g;
                Objects.requireNonNull(http2Connection);
                o.f(errorCode, "statusCode");
                http2Connection.M.j(i2, errorCode);
                return -1L;
            } catch (IOException e2) {
                Http2Connection http2Connection2 = this.f9942e;
                ErrorCode errorCode2 = ErrorCode.PROTOCOL_ERROR;
                http2Connection2.a(errorCode2, errorCode2, e2);
                return -1L;
            }
        }
    }

    /* JADX INFO: renamed from: y.n0.j.f$f */
    @Metadata(d1 = {"\u0000\u0011\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\t\n\u0000*\u0001\u0000\b\n\u0018\u00002\u00020\u0001J\b\u0010\u0002\u001a\u00020\u0003H\u0016¨\u0006\u0004¸\u0006\u0000"}, d2 = {"okhttp3/internal/concurrent/TaskQueue$execute$1", "Lokhttp3/internal/concurrent/Task;", "runOnce", "", "okhttp"}, k = 1, mv = {1, 6, 0}, xi = 48)
    public static final class f extends Task {

        /* JADX INFO: renamed from: e, reason: collision with root package name */
        public final /* synthetic */ Http2Connection f9945e;

        /* JADX INFO: renamed from: f, reason: collision with root package name */
        public final /* synthetic */ int f9946f;

        /* JADX INFO: renamed from: g, reason: collision with root package name */
        public final /* synthetic */ long f9947g;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        public f(String str, boolean z2, Http2Connection http2Connection, int i2, long j2) {
            super(str, z2);
            this.f9945e = http2Connection;
            this.f9946f = i2;
            this.f9947g = j2;
        }

        @Override // okhttp3.n0.concurrent.Task
        public long a() {
            try {
                this.f9945e.M.l(this.f9946f, this.f9947g);
                return -1L;
            } catch (IOException e2) {
                Http2Connection http2Connection = this.f9945e;
                ErrorCode errorCode = ErrorCode.PROTOCOL_ERROR;
                http2Connection.a(errorCode, errorCode, e2);
                return -1L;
            }
        }
    }

    static {
        Settings settings = new Settings();
        settings.c(7, 65535);
        settings.c(5, 16384);
        f9908m = settings;
    }

    public Http2Connection(a aVar) {
        o.f(aVar, "builder");
        boolean z2 = aVar.a;
        this.f9909n = z2;
        this.f9910o = aVar.f9927g;
        this.f9911p = new LinkedHashMap();
        String str = aVar.f9924d;
        if (str == null) {
            o.n("connectionName");
            throw null;
        }
        this.f9912q = str;
        this.f9914s = aVar.a ? 3 : 2;
        TaskRunner taskRunner = aVar.f9922b;
        this.f9916u = taskRunner;
        TaskQueue taskQueueF = taskRunner.f();
        this.f9917v = taskQueueF;
        this.f9918w = taskRunner.f();
        this.f9919x = taskRunner.f();
        this.f9920y = aVar.f9928h;
        Settings settings = new Settings();
        if (aVar.a) {
            settings.c(7, 16777216);
        }
        this.F = settings;
        this.G = f9908m;
        this.K = r3.a();
        Socket socket = aVar.f9923c;
        if (socket == null) {
            o.n("socket");
            throw null;
        }
        this.L = socket;
        BufferedSink bufferedSink = aVar.f9926f;
        if (bufferedSink == null) {
            o.n("sink");
            throw null;
        }
        this.M = new Http2Writer(bufferedSink, z2);
        BufferedSource bufferedSource = aVar.f9925e;
        if (bufferedSource == null) {
            o.n("source");
            throw null;
        }
        this.N = new c(this, new Http2Reader(bufferedSource, z2));
        this.O = new LinkedHashSet();
        int i2 = aVar.f9929i;
        if (i2 != 0) {
            long nanos = TimeUnit.MILLISECONDS.toNanos(i2);
            taskQueueF.c(new d(o.l(str, " ping"), this, nanos), nanos);
        }
    }

    public final void a(ErrorCode errorCode, ErrorCode errorCode2, IOException iOException) {
        int i2;
        o.f(errorCode, "connectionCode");
        o.f(errorCode2, "streamCode");
        byte[] bArr = okhttp3.n0.c.a;
        try {
            g(errorCode);
        } catch (IOException unused) {
        }
        Object[] array = null;
        synchronized (this) {
            if (!this.f9911p.isEmpty()) {
                array = this.f9911p.values().toArray(new Http2Stream[0]);
                if (array == null) {
                    throw new NullPointerException("null cannot be cast to non-null type kotlin.Array<T of kotlin.collections.ArraysKt__ArraysJVMKt.toTypedArray>");
                }
                this.f9911p.clear();
            }
        }
        Http2Stream[] http2StreamArr = (Http2Stream[]) array;
        if (http2StreamArr != null) {
            for (Http2Stream http2Stream : http2StreamArr) {
                try {
                    http2Stream.c(errorCode2, iOException);
                } catch (IOException unused2) {
                }
            }
        }
        try {
            this.M.close();
        } catch (IOException unused3) {
        }
        try {
            this.L.close();
        } catch (IOException unused4) {
        }
        this.f9917v.e();
        this.f9918w.e();
        this.f9919x.e();
    }

    public final synchronized Http2Stream c(int i2) {
        return this.f9911p.get(Integer.valueOf(i2));
    }

    @Override // java.io.Closeable, java.lang.AutoCloseable
    public void close() {
        a(ErrorCode.NO_ERROR, ErrorCode.CANCEL, null);
    }

    public final boolean d(int i2) {
        return i2 != 0 && (i2 & 1) == 0;
    }

    public final synchronized Http2Stream e(int i2) {
        Http2Stream http2StreamRemove;
        http2StreamRemove = this.f9911p.remove(Integer.valueOf(i2));
        notifyAll();
        return http2StreamRemove;
    }

    public final void g(ErrorCode errorCode) {
        o.f(errorCode, "statusCode");
        synchronized (this.M) {
            synchronized (this) {
                if (this.f9915t) {
                    return;
                }
                this.f9915t = true;
                this.M.e(this.f9913r, errorCode, okhttp3.n0.c.a);
            }
        }
    }

    public final synchronized void h(long j2) {
        long j3 = this.H + j2;
        this.H = j3;
        long j4 = j3 - this.I;
        if (j4 >= this.F.a() / 2) {
            o(0, j4);
            this.I += j4;
        }
    }

    /* JADX WARN: Code restructure failed: missing block: B:17:0x0033, code lost:
    
        r2 = java.lang.Math.min((int) java.lang.Math.min(r12, r6 - r4), r8.M.f10013p);
        r6 = r2;
        r8.J += r6;
     */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public final void j(int r9, boolean r10, okio.Buffer r11, long r12) {
        /*
            r8 = this;
            r0 = 0
            int r2 = (r12 > r0 ? 1 : (r12 == r0 ? 0 : -1))
            r3 = 0
            if (r2 != 0) goto Ld
            y.n0.j.p r12 = r8.M
            r12.c(r10, r9, r11, r3)
            return
        Ld:
            int r2 = (r12 > r0 ? 1 : (r12 == r0 ? 0 : -1))
            if (r2 <= 0) goto L67
            monitor-enter(r8)
        L12:
            long r4 = r8.J     // Catch: java.lang.InterruptedException -> L57 java.lang.Throwable -> L64
            long r6 = r8.K     // Catch: java.lang.InterruptedException -> L57 java.lang.Throwable -> L64
            int r2 = (r4 > r6 ? 1 : (r4 == r6 ? 0 : -1))
            if (r2 < 0) goto L32
            java.util.Map<java.lang.Integer, y.n0.j.o> r2 = r8.f9911p     // Catch: java.lang.InterruptedException -> L57 java.lang.Throwable -> L64
            java.lang.Integer r4 = java.lang.Integer.valueOf(r9)     // Catch: java.lang.InterruptedException -> L57 java.lang.Throwable -> L64
            boolean r2 = r2.containsKey(r4)     // Catch: java.lang.InterruptedException -> L57 java.lang.Throwable -> L64
            if (r2 == 0) goto L2a
            r8.wait()     // Catch: java.lang.InterruptedException -> L57 java.lang.Throwable -> L64
            goto L12
        L2a:
            java.io.IOException r9 = new java.io.IOException     // Catch: java.lang.InterruptedException -> L57 java.lang.Throwable -> L64
            java.lang.String r10 = "stream closed"
            r9.<init>(r10)     // Catch: java.lang.InterruptedException -> L57 java.lang.Throwable -> L64
            throw r9     // Catch: java.lang.InterruptedException -> L57 java.lang.Throwable -> L64
        L32:
            long r6 = r6 - r4
            long r4 = java.lang.Math.min(r12, r6)     // Catch: java.lang.Throwable -> L64
            int r2 = (int) r4     // Catch: java.lang.Throwable -> L64
            y.n0.j.p r4 = r8.M     // Catch: java.lang.Throwable -> L64
            int r4 = r4.f10013p     // Catch: java.lang.Throwable -> L64
            int r2 = java.lang.Math.min(r2, r4)     // Catch: java.lang.Throwable -> L64
            long r4 = r8.J     // Catch: java.lang.Throwable -> L64
            long r6 = (long) r2     // Catch: java.lang.Throwable -> L64
            long r4 = r4 + r6
            r8.J = r4     // Catch: java.lang.Throwable -> L64
            monitor-exit(r8)
            long r12 = r12 - r6
            y.n0.j.p r4 = r8.M
            if (r10 == 0) goto L52
            int r5 = (r12 > r0 ? 1 : (r12 == r0 ? 0 : -1))
            if (r5 != 0) goto L52
            r5 = 1
            goto L53
        L52:
            r5 = r3
        L53:
            r4.c(r5, r9, r11, r2)
            goto Ld
        L57:
            java.lang.Thread r9 = java.lang.Thread.currentThread()     // Catch: java.lang.Throwable -> L64
            r9.interrupt()     // Catch: java.lang.Throwable -> L64
            java.io.InterruptedIOException r9 = new java.io.InterruptedIOException     // Catch: java.lang.Throwable -> L64
            r9.<init>()     // Catch: java.lang.Throwable -> L64
            throw r9     // Catch: java.lang.Throwable -> L64
        L64:
            r9 = move-exception
            monitor-exit(r8)
            throw r9
        L67:
            return
        */
        throw new UnsupportedOperationException("Method not decompiled: okhttp3.n0.http2.Http2Connection.j(int, boolean, z.d, long):void");
    }

    public final void l(boolean z2, int i2, int i3) {
        try {
            this.M.h(z2, i2, i3);
        } catch (IOException e2) {
            ErrorCode errorCode = ErrorCode.PROTOCOL_ERROR;
            a(errorCode, errorCode, e2);
        }
    }

    public final void m(int i2, ErrorCode errorCode) {
        o.f(errorCode, "errorCode");
        this.f9917v.c(new e(this.f9912q + AbstractJsonLexerKt.BEGIN_LIST + i2 + "] writeSynReset", true, this, i2, errorCode), 0L);
    }

    public final void o(int i2, long j2) {
        this.f9917v.c(new f(this.f9912q + AbstractJsonLexerKt.BEGIN_LIST + i2 + "] windowUpdate", true, this, i2, j2), 0L);
    }
}
