content: package okhttp3.internal.http2;
  
  import java.io.Closeable;
  import java.io.EOFException;
  import java.io.IOException;
  import java.util.List;
  import java.util.logging.Level;
  import java.util.logging.Logger;
  import kotlin.Metadata;
  import kotlin.jvm.internal.DefaultConstructorMarker;
  import kotlin.jvm.internal.Intrinsics;
  import mt.Log1F380D;
  import okhttp3.internal.Util;
  import okhttp3.internal.http2.Hpack;
  import okio.Buffer;
  import okio.BufferedSource;
  import okio.ByteString;
  import okio.Source;
  import okio.Timeout;
  
  @Metadata(bv = {1, 0, 3}, d1 = {"\u0000H\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000b\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010\b\n\u0002\b\u0004\n\u0002\u0010 \n\u0002\u0018\u0002\n\u0002\b\f\u0018\u0000 #2\u00020\u0001:\u0003#$%B\u0015\u0012\u0006\u0010\u0002\u001a\u00020\u0003\u0012\u0006\u0010\u0004\u001a\u00020\u0005¢\u0006\u0002\u0010\u0006J\b\u0010\u000b\u001a\u00020\fH\u0016J\u0016\u0010\r\u001a\u00020\u00052\u0006\u0010\u000e\u001a\u00020\u00052\u0006\u0010\u000f\u001a\u00020\u0010J\u000e\u0010\u0011\u001a\u00020\f2\u0006\u0010\u000f\u001a\u00020\u0010J(\u0010\u0012\u001a\u00020\f2\u0006\u0010\u000f\u001a\u00020\u00102\u0006\u0010\u0013\u001a\u00020\u00142\u0006\u0010\u0015\u001a\u00020\u00142\u0006\u0010\u0016\u001a\u00020\u0014H\u0002J(\u0010\u0017\u001a\u00020\f2\u0006\u0010\u000f\u001a\u00020\u00102\u0006\u0010\u0013\u001a\u00020\u00142\u0006\u0010\u0015\u001a\u00020\u00142\u0006\u0010\u0016\u001a\u00020\u0014H\u0002J.\u0010\u0018\u001a\b\u0012\u0004\u0012\u00020\u001a0\u00192\u0006\u0010\u0013\u001a\u00020\u00142\u0006\u0010\u001b\u001a\u00020\u00142\u0006\u0010\u0015\u001a\u00020\u00142\u0006\u0010\u0016\u001a\u00020\u0014H\u0002J(\u0010\u001c\u001a\u00020\f2\u0006\u0010\u000f\u001a\u00020\u00102\u0006\u0010\u0013\u001a\u00020\u00142\u0006\u0010\u0015\u001a\u00020\u00142\u0006\u0010\u0016\u001a\u00020\u0014H\u0002J(\u0010\u001d\u001a\u00020\f2\u0006\u0010\u000f\u001a\u00020\u00102\u0006\u0010\u0013\u001a\u00020\u00142\u0006\u0010\u0015\u001a\u00020\u00142\u0006\u0010\u0016\u001a\u00020\u0014H\u0002J\u0018\u0010\u001e\u001a\u00020\f2\u0006\u0010\u000f\u001a\u00020\u00102\u0006\u0010\u0016\u001a\u00020\u0014H\u0002J(\u0010\u001e\u001a\u00020\f2\u0006\u0010\u000f\u001a\u00020\u00102\u0006\u0010\u0013\u001a\u00020\u00142\u0006\u0010\u0015\u001a\u00020\u00142\u0006\u0010\u0016\u001a\u00020\u0014H\u0002J(\u0010\u001f\u001a\u00020\f2\u0006\u0010\u000f\u001a\u00020\u00102\u0006\u0010\u0013\u001a\u00020\u00142\u0006\u0010\u0015\u001a\u00020\u00142\u0006\u0010\u0016\u001a\u00020\u0014H\u0002J(\u0010 \u001a\u00020\f2\u0006\u0010\u000f\u001a\u00020\u00102\u0006\u0010\u0013\u001a\u00020\u00142\u0006\u0010\u0015\u001a\u00020\u00142\u0006\u0010\u0016\u001a\u00020\u0014H\u0002J(\u0010!\u001a\u00020\f2\u0006\u0010\u000f\u001a\u00020\u00102\u0006\u0010\u0013\u001a\u00020\u00142\u0006\u0010\u0015\u001a\u00020\u00142\u0006\u0010\u0016\u001a\u00020\u0014H\u0002J(\u0010\"\u001a\u00020\f2\u0006\u0010\u000f\u001a\u00020\u00102\u0006\u0010\u0013\u001a\u00020\u00142\u0006\u0010\u0015\u001a\u00020\u00142\u0006\u0010\u0016\u001a\u00020\u0014H\u0002R\u000e\u0010\u0004\u001a\u00020\u0005X\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\u0007\u001a\u00020\bX\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\t\u001a\u00020\nX\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\u0002\u001a\u00020\u0003X\u0004¢\u0006\u0002\n\u0000¨\u0006&"}, d2 = {"Lokhttp3/internal/http2/Http2Reader;", "Ljava/io/Closeable;", "source", "Lokio/BufferedSource;", "client", "", "(Lokio/BufferedSource;Z)V", "continuation", "Lokhttp3/internal/http2/Http2Reader$ContinuationSource;", "hpackReader", "Lokhttp3/internal/http2/Hpack$Reader;", "close", "", "nextFrame", "requireSettings", "handler", "Lokhttp3/internal/http2/Http2Reader$Handler;", "readConnectionPreface", "readData", "length", "", "flags", "streamId", "readGoAway", "readHeaderBlock", "", "Lokhttp3/internal/http2/Header;", "padding", "readHeaders", "readPing", "readPriority", "readPushPromise", "readRstStream", "readSettings", "readWindowUpdate", "Companion", "ContinuationSource", "Handler", "okhttp"}, k = 1, mv = {1, 4, 0})
  /* compiled from: 01D5 */
  public final class Http2Reader implements Closeable {
      public static final Companion Companion = new Companion((DefaultConstructorMarker) null);
      /* access modifiers changed from: private */
      public static final Logger logger;
      private final boolean client;
      private final ContinuationSource continuation;
      private final Hpack.Reader hpackReader;
      private final BufferedSource source;
  
      @Metadata(bv = {1, 0, 3}, d1 = {"\u0000\u001c\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010\b\n\u0002\b\u0004\b\u0003\u0018\u00002\u00020\u0001B\u0007\b\u0002¢\u0006\u0002\u0010\u0002J\u001e\u0010\u0007\u001a\u00020\b2\u0006\u0010\t\u001a\u00020\b2\u0006\u0010\n\u001a\u00020\b2\u0006\u0010\u000b\u001a\u00020\bR\u0011\u0010\u0003\u001a\u00020\u0004¢\u0006\b\n\u0000\u001a\u0004\b\u0005\u0010\u0006¨\u0006\f"}, d2 = {"Lokhttp3/internal/http2/Http2Reader$Companion;", "", "()V", "logger", "Ljava/util/logging/Logger;", "getLogger", "()Ljava/util/logging/Logger;", "lengthWithoutPadding", "", "length", "flags", "padding", "okhttp"}, k = 1, mv = {1, 4, 0})
      /* compiled from: Http2Reader.kt */
      public static final class Companion {
          private Companion() {
          }
  
          public /* synthetic */ Companion(DefaultConstructorMarker $constructor_marker) {
              this();
          }
  
          public final Logger getLogger() {
              return Http2Reader.logger;
          }
  
          public final int lengthWithoutPadding(int length, int flags, int padding) throws IOException {
              int i = length;
              if ((flags & 8) != 0) {
                  i--;
              }
              if (padding <= i) {
                  return i - padding;
              }
              throw new IOException("PROTOCOL_ERROR padding " + padding + " > remaining length " + i);
          }
      }
  
      @Metadata(bv = {1, 0, 3}, d1 = {"\u00004\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\b\n\u0002\b\u0011\n\u0002\u0010\u0002\n\u0000\n\u0002\u0010\t\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0000\b\u0000\u0018\u00002\u00020\u0001B\r\u0012\u0006\u0010\u0002\u001a\u00020\u0003¢\u0006\u0002\u0010\u0004J\b\u0010\u0017\u001a\u00020\u0018H\u0016J\u0018\u0010\u0019\u001a\u00020\u001a2\u0006\u0010\u001b\u001a\u00020\u001c2\u0006\u0010\u001d\u001a\u00020\u001aH\u0016J\b\u0010\u001e\u001a\u00020\u0018H\u0002J\b\u0010\u001f\u001a\u00020 H\u0016R\u001a\u0010\u0005\u001a\u00020\u0006X\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\u0007\u0010\b\"\u0004\b\t\u0010\nR\u001a\u0010\u000b\u001a\u00020\u0006X\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\f\u0010\b\"\u0004\b\r\u0010\nR\u001a\u0010\u000e\u001a\u00020\u0006X\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\u000f\u0010\b\"\u0004\b\u0010\u0010\nR\u001a\u0010\u0011\u001a\u00020\u0006X\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\u0012\u0010\b\"\u0004\b\u0013\u0010\nR\u000e\u0010\u0002\u001a\u00020\u0003X\u0004¢\u0006\u0002\n\u0000R\u001a\u0010\u0014\u001a\u00020\u0006X\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\u0015\u0010\b\"\u0004\b\u0016\u0010\n¨\u0006!"}, d2 = {"Lokhttp3/internal/http2/Http2Reader$ContinuationSource;", "Lokio/Source;", "source", "Lokio/BufferedSource;", "(Lokio/BufferedSource;)V", "flags", "", "getFlags", "()I", "setFlags", "(I)V", "left", "getLeft", "setLeft", "length", "getLength", "setLength", "padding", "getPadding", "setPadding", "streamId", "getStreamId", "setStreamId", "close", "", "read", "", "sink", "Lokio/Buffer;", "byteCount", "readContinuationHeader", "timeout", "Lokio/Timeout;", "okhttp"}, k = 1, mv = {1, 4, 0})
      /* compiled from: Http2Reader.kt */
      public static final class ContinuationSource implements Source {
          private int flags;
          private int left;
          private int length;
          private int padding;
          private final BufferedSource source;
          private int streamId;
  
          public ContinuationSource(BufferedSource source2) {
              Intrinsics.checkNotNullParameter(source2, "source");
              this.source = source2;
          }
  
          private final void readContinuationHeader() throws IOException {
              int i = this.streamId;
              int readMedium = Util.readMedium(this.source);
              this.left = readMedium;
              this.length = readMedium;
              int and = Util.and(this.source.readByte(), 255);
              this.flags = Util.and(this.source.readByte(), 255);
              if (Http2Reader.Companion.getLogger().isLoggable(Level.FINE)) {
                  Http2Reader.Companion.getLogger().fine(Http2.INSTANCE.frameLog(true, this.streamId, this.length, and, this.flags));
              }
              int readInt = this.source.readInt() & Integer.MAX_VALUE;
              this.streamId = readInt;
              if (and != 9) {
                  throw new IOException(and + " != TYPE_CONTINUATION");
              } else if (readInt != i) {
                  throw new IOException("TYPE_CONTINUATION streamId changed");
              }
          }
  
          public void close() throws IOException {
          }
  
          public final int getFlags() {
              return this.flags;
          }
  
          public final int getLeft() {
              return this.left;
          }
  
          public final int getLength() {
              return this.length;
          }
  
          public final int getPadding() {
              return this.padding;
          }
  
          public final int getStreamId() {
              return this.streamId;
          }
  
          public long read(Buffer sink, long byteCount) throws IOException {
              Intrinsics.checkNotNullParameter(sink, "sink");
              while (true) {
                  int i = this.left;
                  if (i == 0) {
                      this.source.skip((long) this.padding);
                      this.padding = 0;
                      if ((this.flags & 4) != 0) {
                          return -1;
                      }
                      readContinuationHeader();
                  } else {
                      long read = this.source.read(sink, Math.min(byteCount, (long) i));
                      if (read == -1) {
                          return -1;
                      }
                      this.left -= (int) read;
                      return read;
                  }
              }
          }
  
          public final void setFlags(int i) {
              this.flags = i;
          }
  
          public final void setLeft(int i) {
              this.left = i;
          }
  
          public final void setLength(int i) {
              this.length = i;
          }
  
          public final void setPadding(int i) {
              this.padding = i;
          }
  
          public final void setStreamId(int i) {
              this.streamId = i;
          }
  
          public Timeout timeout() {
              return this.source.timeout();
          }
      }
  
      @Metadata(bv = {1, 0, 3}, d1 = {"\u0000X\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0000\n\u0002\u0010\u0002\n\u0002\b\u0002\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\u0004\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0010 \n\u0002\u0018\u0002\n\u0002\b\u000e\n\u0002\u0018\u0002\n\u0002\b\u0003\bf\u0018\u00002\u00020\u0001J\b\u0010\u0002\u001a\u00020\u0003H&J8\u0010\u0004\u001a\u00020\u00032\u0006\u0010\u0005\u001a\u00020\u00062\u0006\u0010\u0007\u001a\u00020\b2\u0006\u0010\t\u001a\u00020\n2\u0006\u0010\u000b\u001a\u00020\b2\u0006\u0010\f\u001a\u00020\u00062\u0006\u0010\r\u001a\u00020\u000eH&J(\u0010\u000f\u001a\u00020\u00032\u0006\u0010\u0010\u001a\u00020\u00112\u0006\u0010\u0005\u001a\u00020\u00062\u0006\u0010\u0012\u001a\u00020\u00132\u0006\u0010\u0014\u001a\u00020\u0006H&J \u0010\u0015\u001a\u00020\u00032\u0006\u0010\u0016\u001a\u00020\u00062\u0006\u0010\u0017\u001a\u00020\u00182\u0006\u0010\u0019\u001a\u00020\nH&J.\u0010\u001a\u001a\u00020\u00032\u0006\u0010\u0010\u001a\u00020\u00112\u0006\u0010\u0005\u001a\u00020\u00062\u0006\u0010\u001b\u001a\u00020\u00062\f\u0010\u001c\u001a\b\u0012\u0004\u0012\u00020\u001e0\u001dH&J \u0010\u001f\u001a\u00020\u00032\u0006\u0010 \u001a\u00020\u00112\u0006\u0010!\u001a\u00020\u00062\u0006\u0010\"\u001a\u00020\u0006H&J(\u0010#\u001a\u00020\u00032\u0006\u0010\u0005\u001a\u00020\u00062\u0006\u0010$\u001a\u00020\u00062\u0006\u0010%\u001a\u00020\u00062\u0006\u0010&\u001a\u00020\u0011H&J&\u0010'\u001a\u00020\u00032\u0006\u0010\u0005\u001a\u00020\u00062\u0006\u0010(\u001a\u00020\u00062\f\u0010)\u001a\b\u0012\u0004\u0012\u00020\u001e0\u001dH&J\u0018\u0010*\u001a\u00020\u00032\u0006\u0010\u0005\u001a\u00020\u00062\u0006\u0010\u0017\u001a\u00020\u0018H&J\u0018\u0010+\u001a\u00020\u00032\u0006\u0010,\u001a\u00020\u00112\u0006\u0010+\u001a\u00020-H&J\u0018\u0010.\u001a\u00020\u00032\u0006\u0010\u0005\u001a\u00020\u00062\u0006\u0010/\u001a\u00020\u000eH&¨\u00060"}, d2 = {"Lokhttp3/internal/http2/Http2Reader$Handler;", "", "ackSettings", "", "alternateService", "streamId", "", "origin", "", "protocol", "Lokio/ByteString;", "host", "port", "maxAge", "", "data", "inFinished", "", "source", "Lokio/BufferedSource;", "length", "goAway", "lastGoodStreamId", "errorCode", "Lokhttp3/internal/http2/ErrorCode;", "debugData", "headers", "associatedStreamId", "headerBlock", "", "Lokhttp3/internal/http2/Header;", "ping", "ack", "payload1", "payload2", "priority", "streamDependency", "weight", "exclusive", "pushPromise", "promisedStreamId", "requestHeaders", "rstStream", "settings", "clearPrevious", "Lokhttp3/internal/http2/Settings;", "windowUpdate", "windowSizeIncrement", "okhttp"}, k = 1, mv = {1, 4, 0})
      /* compiled from: Http2Reader.kt */
      public interface Handler {
          void ackSettings();
  
          void alternateService(int i, String str, ByteString byteString, String str2, int i2, long j);
  
          void data(boolean z, int i, BufferedSource bufferedSource, int i2) throws IOException;
  
          void goAway(int i, ErrorCode errorCode, ByteString byteString);
  
          void headers(boolean z, int i, int i2, List<Header> list);
  
          void ping(boolean z, int i, int i2);
  
          void priority(int i, int i2, int i3, boolean z);
  
          void pushPromise(int i, int i2, List<Header> list) throws IOException;
  
          void rstStream(int i, ErrorCode errorCode);
  
          void settings(boolean z, Settings settings);
  
          void windowUpdate(int i, long j);
      }
  
      static {
          Logger logger2 = Logger.getLogger(Http2.class.getName());
          Intrinsics.checkNotNullExpressionValue(logger2, "Logger.getLogger(Http2::class.java.name)");
          logger = logger2;
      }
  
      public Http2Reader(BufferedSource source2, boolean client2) {
          Intrinsics.checkNotNullParameter(source2, "source");
          this.source = source2;
          this.client = client2;
          ContinuationSource continuationSource = new ContinuationSource(source2);
          this.continuation = continuationSource;
          this.hpackReader = new Hpack.Reader(continuationSource, 4096, 0, 4, (DefaultConstructorMarker) null);
      }
  
      private final void readData(Handler handler, int length, int flags, int streamId) throws IOException {
          if (streamId != 0) {
              int i = 0;
              boolean z = true;
              boolean z2 = (flags & 1) != 0;
              if ((flags & 32) == 0) {
                  z = false;
              }
              if (!z) {
                  if ((flags & 8) != 0) {
                      i = Util.and(this.source.readByte(), 255);
                  }
                  handler.data(z2, streamId, this.source, Companion.lengthWithoutPadding(length, flags, i));
                  this.source.skip((long) i);
                  return;
              }
              throw new IOException("PROTOCOL_ERROR: FLAG_COMPRESSED without SETTINGS_COMPRESS_DATA");
          }
          throw new IOException("PROTOCOL_ERROR: TYPE_DATA streamId == 0");
      }
  
      private final void readGoAway(Handler handler, int length, int flags, int streamId) throws IOException {
          if (length < 8) {
              throw new IOException("TYPE_GOAWAY length < 8: " + length);
          } else if (streamId == 0) {
              int readInt = this.source.readInt();
              int readInt2 = this.source.readInt();
              int i = length - 8;
              ErrorCode fromHttp2 = ErrorCode.Companion.fromHttp2(readInt2);
              if (fromHttp2 != null) {
                  ByteString byteString = ByteString.EMPTY;
                  if (i > 0) {
                      byteString = this.source.readByteString((long) i);
                  }
                  handler.goAway(readInt, fromHttp2, byteString);
                  return;
              }
              throw new IOException("TYPE_GOAWAY unexpected error code: " + readInt2);
          } else {
              throw new IOException("TYPE_GOAWAY streamId != 0");
          }
      }
  
      private final List<Header> readHeaderBlock(int length, int padding, int flags, int streamId) throws IOException {
          this.continuation.setLeft(length);
          ContinuationSource continuationSource = this.continuation;
          continuationSource.setLength(continuationSource.getLeft());
          this.continuation.setPadding(padding);
          this.continuation.setFlags(flags);
          this.continuation.setStreamId(streamId);
          this.hpackReader.readHeaders();
          return this.hpackReader.getAndResetHeaderList();
      }
  
      private final void readHeaders(Handler handler, int length, int flags, int streamId) throws IOException {
          if (streamId != 0) {
              int i = 0;
              boolean z = (flags & 1) != 0;
              if ((flags & 8) != 0) {
                  i = Util.and(this.source.readByte(), 255);
              }
              int i2 = length;
              if ((flags & 32) != 0) {
                  readPriority(handler, streamId);
                  i2 -= 5;
              }
              handler.headers(z, streamId, -1, readHeaderBlock(Companion.lengthWithoutPadding(i2, flags, i), i, flags, streamId));
              return;
          }
          throw new IOException("PROTOCOL_ERROR: TYPE_HEADERS streamId == 0");
      }
  
      private final void readPing(Handler handler, int length, int flags, int streamId) throws IOException {
          if (length != 8) {
              throw new IOException("TYPE_PING length != 8: " + length);
          } else if (streamId == 0) {
              handler.ping((flags & 1) != 0, this.source.readInt(), this.source.readInt());
          } else {
              throw new IOException("TYPE_PING streamId != 0");
          }
      }
  
      private final void readPriority(Handler handler, int streamId) throws IOException {
          int readInt = this.source.readInt();
          handler.priority(streamId, Integer.MAX_VALUE & readInt, Util.and(this.source.readByte(), 255) + 1, (((int) 2147483648L) & readInt) != 0);
      }
  
      private final void readPriority(Handler handler, int length, int flags, int streamId) throws IOException {
          if (length != 5) {
              throw new IOException("TYPE_PRIORITY length: " + length + " != 5");
          } else if (streamId != 0) {
              readPriority(handler, streamId);
          } else {
              throw new IOException("TYPE_PRIORITY streamId == 0");
          }
      }
  
      private final void readPushPromise(Handler handler, int length, int flags, int streamId) throws IOException {
          if (streamId != 0) {
              int and = (flags & 8) != 0 ? Util.and(this.source.readByte(), 255) : 0;
              handler.pushPromise(streamId, this.source.readInt() & Integer.MAX_VALUE, readHeaderBlock(Companion.lengthWithoutPadding(length - 4, flags, and), and, flags, streamId));
              return;
          }
          throw new IOException("PROTOCOL_ERROR: TYPE_PUSH_PROMISE streamId == 0");
      }
  
      private final void readRstStream(Handler handler, int length, int flags, int streamId) throws IOException {
          if (length != 4) {
              throw new IOException("TYPE_RST_STREAM length: " + length + " != 4");
          } else if (streamId != 0) {
              int readInt = this.source.readInt();
              ErrorCode fromHttp2 = ErrorCode.Companion.fromHttp2(readInt);
              if (fromHttp2 != null) {
                  handler.rstStream(streamId, fromHttp2);
                  return;
              }
              throw new IOException("TYPE_RST_STREAM unexpected error code: " + readInt);
          } else {
              throw new IOException("TYPE_RST_STREAM streamId == 0");
          }
      }
  
      /* JADX WARNING: Code restructure failed: missing block: B:21:0x007a, code lost:
          throw new java.io.IOException("PROTOCOL_ERROR SETTINGS_MAX_FRAME_SIZE: " + r6);
       */
      /* Code decompiled incorrectly, please refer to instructions dump. */
      private final void readSettings(okhttp3.internal.http2.Http2Reader.Handler r9, int r10, int r11, int r12) throws java.io.IOException {
          /*
              r8 = this;
              if (r12 != 0) goto L_0x00c4
              r0 = r11 & 1
              if (r0 == 0) goto L_0x0016
              if (r10 != 0) goto L_0x000c
              r9.ackSettings()
              return
          L_0x000c:
              java.io.IOException r0 = new java.io.IOException
              java.lang.String r1 = "FRAME_SIZE_ERROR ack frame should be empty!"
              r0.<init>(r1)
              java.lang.Throwable r0 = (java.lang.Throwable) r0
              throw r0
          L_0x0016:
              int r0 = r10 % 6
              if (r0 != 0) goto L_0x00a9
              okhttp3.internal.http2.Settings r0 = new okhttp3.internal.http2.Settings
              r0.<init>()
              r1 = 0
              kotlin.ranges.IntRange r2 = kotlin.ranges.RangesKt.until((int) r1, (int) r10)
              kotlin.ranges.IntProgression r2 = (kotlin.ranges.IntProgression) r2
              r3 = 6
              kotlin.ranges.IntProgression r2 = kotlin.ranges.RangesKt.step((kotlin.ranges.IntProgression) r2, (int) r3)
              int r3 = r2.getFirst()
              int r4 = r2.getLast()
              int r2 = r2.getStep()
              if (r2 < 0) goto L_0x003c
              if (r3 > r4) goto L_0x00a5
              goto L_0x003e
          L_0x003c:
              if (r3 < r4) goto L_0x00a5
          L_0x003e:
              okio.BufferedSource r5 = r8.source
              short r5 = r5.readShort()
              r6 = 65535(0xffff, float:9.1834E-41)
              int r5 = okhttp3.internal.Util.and((short) r5, (int) r6)
              okio.BufferedSource r6 = r8.source
              int r6 = r6.readInt()
              switch(r5) {
                  case 1: goto L_0x0054;
                  case 2: goto L_0x008b;
                  case 3: goto L_0x0089;
                  case 4: goto L_0x007b;
                  case 5: goto L_0x0056;
                  case 6: goto L_0x0055;
                  default: goto L_0x0054;
              }
          L_0x0054:
              goto L_0x009b
          L_0x0055:
              goto L_0x009b
          L_0x0056:
              r7 = 16384(0x4000, float:2.2959E-41)
              if (r6 < r7) goto L_0x0060
              r7 = 16777215(0xffffff, float:2.3509886E-38)
              if (r6 > r7) goto L_0x0060
              goto L_0x009b
          L_0x0060:
              java.io.IOException r1 = new java.io.IOException
              java.lang.StringBuilder r2 = new java.lang.StringBuilder
              r2.<init>()
              java.lang.String r4 = "PROTOCOL_ERROR SETTINGS_MAX_FRAME_SIZE: "
              java.lang.StringBuilder r2 = r2.append(r4)
              java.lang.StringBuilder r2 = r2.append(r6)
              java.lang.String r2 = r2.toString()
              r1.<init>(r2)
              java.lang.Throwable r1 = (java.lang.Throwable) r1
              throw r1
          L_0x007b:
              r5 = 7
              if (r6 < 0) goto L_0x007f
              goto L_0x009b
          L_0x007f:
              java.io.IOException r1 = new java.io.IOException
              java.lang.String r2 = "PROTOCOL_ERROR SETTINGS_INITIAL_WINDOW_SIZE > 2^31 - 1"
              r1.<init>(r2)
              java.lang.Throwable r1 = (java.lang.Throwable) r1
              throw r1
          L_0x0089:
              r5 = 4
              goto L_0x009b
          L_0x008b:
              if (r6 == 0) goto L_0x009b
              r7 = 1
              if (r6 != r7) goto L_0x0091
              goto L_0x009b
          L_0x0091:
              java.io.IOException r1 = new java.io.IOException
              java.lang.String r2 = "PROTOCOL_ERROR SETTINGS_ENABLE_PUSH != 0 or 1"
              r1.<init>(r2)
              java.lang.Throwable r1 = (java.lang.Throwable) r1
              throw r1
          L_0x009b:
              r0.set(r5, r6)
              if (r3 == r4) goto L_0x00a5
              int r5 = r3 + r2
              r3 = r5
              goto L_0x003e
          L_0x00a5:
              r9.settings(r1, r0)
              return
          L_0x00a9:
              java.io.IOException r0 = new java.io.IOException
              java.lang.StringBuilder r1 = new java.lang.StringBuilder
              r1.<init>()
              java.lang.String r2 = "TYPE_SETTINGS length % 6 != 0: "
              java.lang.StringBuilder r1 = r1.append(r2)
              java.lang.StringBuilder r1 = r1.append(r10)
              java.lang.String r1 = r1.toString()
              r0.<init>(r1)
              java.lang.Throwable r0 = (java.lang.Throwable) r0
              throw r0
          L_0x00c4:
              java.io.IOException r0 = new java.io.IOException
              java.lang.String r1 = "TYPE_SETTINGS streamId != 0"
              r0.<init>(r1)
              java.lang.Throwable r0 = (java.lang.Throwable) r0
              throw r0
          */
          throw new UnsupportedOperationException("Method not decompiled: okhttp3.internal.http2.Http2Reader.readSettings(okhttp3.internal.http2.Http2Reader$Handler, int, int, int):void");
      }
  
      private final void readWindowUpdate(Handler handler, int length, int flags, int streamId) throws IOException {
          if (length == 4) {
              long and = Util.and(this.source.readInt(), 2147483647L);
              if (and != 0) {
                  handler.windowUpdate(streamId, and);
                  return;
              }
              throw new IOException("windowSizeIncrement was 0");
          }
          throw new IOException("TYPE_WINDOW_UPDATE length !=4: " + length);
      }
  
      public void close() throws IOException {
          this.source.close();
      }
  
      public final boolean nextFrame(boolean requireSettings, Handler handler) throws IOException {
          Intrinsics.checkNotNullParameter(handler, "handler");
          try {
              this.source.require(9);
              int readMedium = Util.readMedium(this.source);
              if (readMedium <= 16384) {
                  int and = Util.and(this.source.readByte(), 255);
                  int and2 = Util.and(this.source.readByte(), 255);
                  int readInt = this.source.readInt() & Integer.MAX_VALUE;
                  Logger logger2 = logger;
                  if (logger2.isLoggable(Level.FINE)) {
                      logger2.fine(Http2.INSTANCE.frameLog(true, readInt, readMedium, and, and2));
                  }
                  if (!requireSettings || and == 4) {
                      switch (and) {
                          case 0:
                              readData(handler, readMedium, and2, readInt);
                              return true;
                          case 1:
                              readHeaders(handler, readMedium, and2, readInt);
                              return true;
                          case 2:
                              readPriority(handler, readMedium, and2, readInt);
                              return true;
                          case 3:
                              readRstStream(handler, readMedium, and2, readInt);
                              return true;
                          case 4:
                              readSettings(handler, readMedium, and2, readInt);
                              return true;
                          case 5:
                              readPushPromise(handler, readMedium, and2, readInt);
                              return true;
                          case 6:
                              readPing(handler, readMedium, and2, readInt);
                              return true;
                          case 7:
                              readGoAway(handler, readMedium, and2, readInt);
                              return true;
                          case 8:
                              readWindowUpdate(handler, readMedium, and2, readInt);
                              return true;
                          default:
                              this.source.skip((long) readMedium);
                              return true;
                      }
                  } else {
                      throw new IOException("Expected a SETTINGS frame but was " + Http2.INSTANCE.formattedType$okhttp(and));
                  }
              } else {
                  throw new IOException("FRAME_SIZE_ERROR: " + readMedium);
              }
          } catch (EOFException e) {
              return false;
          }
      }
  
      public final void readConnectionPreface(Handler handler) throws IOException {
          Intrinsics.checkNotNullParameter(handler, "handler");
          if (!this.client) {
              ByteString readByteString = this.source.readByteString((long) Http2.CONNECTION_PREFACE.size());
              Logger logger2 = logger;
              if (logger2.isLoggable(Level.FINE)) {
                  String format = Util.format("<< CONNECTION " + readByteString.hex(), new Object[0]);
                  Log1F380D.a((Object) format);
                  logger2.fine(format);
              }
              if (true ^ Intrinsics.areEqual((Object) Http2.CONNECTION_PREFACE, (Object) readByteString)) {
                  throw new IOException("Expected a connection header but was " + readByteString.utf8());
              }
          } else if (!nextFrame(true, handler)) {
              throw new IOException("Required SETTINGS preface not received");
          }
      }
  }
  