package n5; import com.google.android.gms.ads.RequestConfiguration; import com.google.android.gms.common.api.Api; import h5.g0; import h5.o0; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; /* loaded from: classes2.dex */ abstract class k { /* renamed from: a, reason: collision with root package name */ static final c[] f12110a; /* renamed from: b, reason: collision with root package name */ static final Map f12111b; static final class a { /* renamed from: a, reason: collision with root package name */ private final List f12112a; /* renamed from: b, reason: collision with root package name */ private final h5.f f12113b; /* renamed from: c, reason: collision with root package name */ private final int f12114c; /* renamed from: d, reason: collision with root package name */ private int f12115d; /* renamed from: e, reason: collision with root package name */ c[] f12116e; /* renamed from: f, reason: collision with root package name */ int f12117f; /* renamed from: g, reason: collision with root package name */ int f12118g; /* renamed from: h, reason: collision with root package name */ int f12119h; a(int i10, int i11, o0 o0Var) { this.f12112a = new ArrayList(); this.f12116e = new c[8]; this.f12117f = 7; this.f12118g = 0; this.f12119h = 0; this.f12114c = i10; this.f12115d = i11; this.f12113b = g0.f(o0Var); } private int a(int i10) { return this.f12117f + 1 + i10; } private void c() { int i10 = this.f12115d; int i11 = this.f12119h; if (i10 < i11) { if (i10 == 0) { f(); } else { e(i11 - i10); } } } private void d(int i10, c cVar) { this.f12112a.add(cVar); int i11 = cVar.f11994c; if (i10 != -1) { i11 -= this.f12116e[a(i10)].f11994c; } int i12 = this.f12115d; if (i11 > i12) { f(); return; } int e10 = e((this.f12119h + i11) - i12); if (i10 == -1) { int i13 = this.f12118g + 1; c[] cVarArr = this.f12116e; if (i13 > cVarArr.length) { c[] cVarArr2 = new c[cVarArr.length * 2]; System.arraycopy(cVarArr, 0, cVarArr2, cVarArr.length, cVarArr.length); this.f12117f = this.f12116e.length - 1; this.f12116e = cVarArr2; } int i14 = this.f12117f; this.f12117f = i14 - 1; this.f12116e[i14] = cVar; this.f12118g++; } else { this.f12116e[i10 + a(i10) + e10] = cVar; } this.f12119h += i11; } private int e(int i10) { int i11; int i12 = 0; if (i10 > 0) { int length = this.f12116e.length; while (true) { length--; i11 = this.f12117f; if (length < i11 || i10 <= 0) { break; } int i13 = this.f12116e[length].f11994c; i10 -= i13; this.f12119h -= i13; this.f12118g--; i12++; } c[] cVarArr = this.f12116e; int i14 = i11 + 1; System.arraycopy(cVarArr, i14, cVarArr, i14 + i12, this.f12118g); this.f12117f += i12; } return i12; } private void f() { Arrays.fill(this.f12116e, (Object) null); this.f12117f = this.f12116e.length - 1; this.f12118g = 0; this.f12119h = 0; } private h5.g g(int i10) { c cVar; if (!j(i10)) { int a10 = a(i10 - k.f12110a.length); if (a10 >= 0) { c[] cVarArr = this.f12116e; if (a10 < cVarArr.length) { cVar = cVarArr[a10]; } } throw new IOException("Header index too large " + (i10 + 1)); } cVar = k.f12110a[i10]; return cVar.f11992a; } private int i() { return this.f12113b.readByte() & 255; } private boolean j(int i10) { return i10 >= 0 && i10 <= k.f12110a.length - 1; } private void l(int i10) { if (j(i10)) { this.f12112a.add(k.f12110a[i10]); return; } int a10 = a(i10 - k.f12110a.length); if (a10 >= 0) { c[] cVarArr = this.f12116e; if (a10 < cVarArr.length) { this.f12112a.add(cVarArr[a10]); return; } } throw new IOException("Header index too large " + (i10 + 1)); } private void n(int i10) { d(-1, new c(g(i10), k())); } private void o() { d(-1, new c(k.a(k()), k())); } private void p(int i10) { this.f12112a.add(new c(g(i10), k())); } private void q() { this.f12112a.add(new c(k.a(k()), k())); } int b(int i10, int i11) { int i12 = i10 & i11; if (i12 < i11) { return i12; } int i13 = 0; while (true) { int i14 = i(); if ((i14 & 128) == 0) { return i11 + (i14 << i13); } i11 += (i14 & 127) << i13; i13 += 7; } } public List h() { ArrayList arrayList = new ArrayList(this.f12112a); this.f12112a.clear(); return arrayList; } h5.g k() { int i10 = i(); boolean z10 = (i10 & 128) == 128; int b10 = b(i10, 127); return z10 ? h5.g.k(n.f().e(this.f12113b.p(b10))) : this.f12113b.d(b10); } void m() { while (!this.f12113b.g()) { int readByte = this.f12113b.readByte() & 255; if (readByte == 128) { throw new IOException("index == 0"); } if ((readByte & 128) == 128) { l(b(readByte, 127) - 1); } else if (readByte == 64) { o(); } else if ((readByte & 64) == 64) { n(b(readByte, 63) - 1); } else if ((readByte & 32) == 32) { int b10 = b(readByte, 31); this.f12115d = b10; if (b10 < 0 || b10 > this.f12114c) { throw new IOException("Invalid dynamic table size update " + this.f12115d); } c(); } else if (readByte == 16 || readByte == 0) { q(); } else { p(b(readByte, 15) - 1); } } } a(int i10, o0 o0Var) { this(i10, i10, o0Var); } } static final class b { /* renamed from: a, reason: collision with root package name */ private final h5.d f12120a; /* renamed from: b, reason: collision with root package name */ private final boolean f12121b; /* renamed from: c, reason: collision with root package name */ private int f12122c; /* renamed from: d, reason: collision with root package name */ private boolean f12123d; /* renamed from: e, reason: collision with root package name */ int f12124e; /* renamed from: f, reason: collision with root package name */ c[] f12125f; /* renamed from: g, reason: collision with root package name */ int f12126g; /* renamed from: h, reason: collision with root package name */ int f12127h; /* renamed from: i, reason: collision with root package name */ int f12128i; b(int i10, boolean z10, h5.d dVar) { this.f12122c = Api.BaseClientBuilder.API_PRIORITY_OTHER; this.f12125f = new c[8]; this.f12126g = 7; this.f12127h = 0; this.f12128i = 0; this.f12124e = i10; this.f12121b = z10; this.f12120a = dVar; } private int a(int i10) { int i11; int i12 = 0; if (i10 > 0) { int length = this.f12125f.length; while (true) { length--; i11 = this.f12126g; if (length < i11 || i10 <= 0) { break; } int i13 = this.f12125f[length].f11994c; i10 -= i13; this.f12128i -= i13; this.f12127h--; i12++; } c[] cVarArr = this.f12125f; int i14 = i11 + 1; System.arraycopy(cVarArr, i14, cVarArr, i14 + i12, this.f12127h); c[] cVarArr2 = this.f12125f; int i15 = this.f12126g + 1; Arrays.fill(cVarArr2, i15, i15 + i12, (Object) null); this.f12126g += i12; } return i12; } private void b() { int i10 = this.f12124e; int i11 = this.f12128i; if (i10 < i11) { if (i10 == 0) { g(); } else { a(i11 - i10); } } } private void f(c cVar) { int i10 = cVar.f11994c; int i11 = this.f12124e; if (i10 > i11) { g(); return; } a((this.f12128i + i10) - i11); int i12 = this.f12127h + 1; c[] cVarArr = this.f12125f; if (i12 > cVarArr.length) { c[] cVarArr2 = new c[cVarArr.length * 2]; System.arraycopy(cVarArr, 0, cVarArr2, cVarArr.length, cVarArr.length); this.f12126g = this.f12125f.length - 1; this.f12125f = cVarArr2; } int i13 = this.f12126g; this.f12126g = i13 - 1; this.f12125f[i13] = cVar; this.f12127h++; this.f12128i += i10; } private void g() { Arrays.fill(this.f12125f, (Object) null); this.f12126g = this.f12125f.length - 1; this.f12127h = 0; this.f12128i = 0; } void c(int i10, int i11, int i12) { int i13; h5.d dVar; if (i10 < i11) { dVar = this.f12120a; i13 = i10 | i12; } else { this.f12120a.h(i12 | i11); i13 = i10 - i11; while (i13 >= 128) { this.f12120a.h(128 | (i13 & 127)); i13 >>>= 7; } dVar = this.f12120a; } dVar.h(i13); } void d(h5.g gVar) { int o10; int i10; if (!this.f12121b || n.f().a(gVar) >= gVar.o()) { o10 = gVar.o(); i10 = 0; } else { h5.d dVar = new h5.d(); n.f().d(gVar, dVar); gVar = dVar.m0(); o10 = gVar.o(); i10 = 128; } c(o10, 127, i10); this.f12120a.D0(gVar); } void e(List list) { int i10; int i11; if (this.f12123d) { int i12 = this.f12122c; if (i12 < this.f12124e) { c(i12, 31, 32); } this.f12123d = false; this.f12122c = Api.BaseClientBuilder.API_PRIORITY_OTHER; c(this.f12124e, 31, 32); } int size = list.size(); for (int i13 = 0; i13 < size; i13++) { c cVar = (c) list.get(i13); h5.g r10 = cVar.f11992a.r(); h5.g gVar = cVar.f11993b; Integer num = (Integer) k.f12111b.get(r10); if (num != null) { i10 = num.intValue() + 1; if (i10 > 1 && i10 < 8) { c[] cVarArr = k.f12110a; if (i5.c.q(cVarArr[i10 - 1].f11993b, gVar)) { i11 = i10; } else if (i5.c.q(cVarArr[i10].f11993b, gVar)) { i11 = i10; i10++; } } i11 = i10; i10 = -1; } else { i10 = -1; i11 = -1; } if (i10 == -1) { int i14 = this.f12126g + 1; int length = this.f12125f.length; while (true) { if (i14 >= length) { break; } if (i5.c.q(this.f12125f[i14].f11992a, r10)) { if (i5.c.q(this.f12125f[i14].f11993b, gVar)) { i10 = k.f12110a.length + (i14 - this.f12126g); break; } else if (i11 == -1) { i11 = (i14 - this.f12126g) + k.f12110a.length; } } i14++; } } if (i10 != -1) { c(i10, 127, 128); } else { if (i11 == -1) { this.f12120a.h(64); d(r10); } else if (!r10.p(c.f11986d) || c.f11991i.equals(r10)) { c(i11, 63, 64); } else { c(i11, 15, 0); d(gVar); } d(gVar); f(cVar); } } } void h(int i10) { int min = Math.min(i10, 16384); int i11 = this.f12124e; if (i11 == min) { return; } if (min < i11) { this.f12122c = Math.min(this.f12122c, min); } this.f12123d = true; this.f12124e = min; b(); } b(h5.d dVar) { this(4096, true, dVar); } } static { h5.g gVar = c.f11988f; h5.g gVar2 = c.f11989g; h5.g gVar3 = c.f11990h; h5.g gVar4 = c.f11987e; f12110a = new c[]{new c(c.f11991i, RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED), new c(gVar, "GET"), new c(gVar, "POST"), new c(gVar2, "/"), new c(gVar2, "/index.html"), new c(gVar3, "http"), new c(gVar3, "https"), new c(gVar4, "200"), new c(gVar4, "204"), new c(gVar4, "206"), new c(gVar4, "304"), new c(gVar4, "400"), new c(gVar4, "404"), new c(gVar4, "500"), new c("accept-charset", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED), new c("accept-encoding", "gzip, deflate"), new c("accept-language", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED), new c("accept-ranges", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED), new c("accept", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED), new c("access-control-allow-origin", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED), new c("age", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED), new c("allow", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED), new c("authorization", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED), new c("cache-control", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED), new c("content-disposition", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED), new c("content-encoding", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED), new c("content-language", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED), new c("content-length", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED), new c("content-location", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED), new c("content-range", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED), new c("content-type", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED), new c("cookie", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED), new c("date", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED), new c("etag", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED), new c("expect", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED), new c("expires", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED), new c("from", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED), new c("host", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED), new c("if-match", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED), new c("if-modified-since", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED), new c("if-none-match", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED), new c("if-range", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED), new c("if-unmodified-since", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED), new c("last-modified", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED), new c("link", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED), new c("location", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED), new c("max-forwards", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED), new c("proxy-authenticate", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED), new c("proxy-authorization", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED), new c("range", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED), new c("referer", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED), new c("refresh", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED), new c("retry-after", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED), new c("server", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED), new c("set-cookie", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED), new c("strict-transport-security", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED), new c("transfer-encoding", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED), new c("user-agent", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED), new c("vary", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED), new c("via", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED), new c("www-authenticate", RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED)}; f12111b = b(); } static h5.g a(h5.g gVar) { int o10 = gVar.o(); for (int i10 = 0; i10 < o10; i10++) { byte i11 = gVar.i(i10); if (i11 >= 65 && i11 <= 90) { throw new IOException("PROTOCOL_ERROR response malformed: mixed case name: " + gVar.t()); } } return gVar; } private static Map b() { LinkedHashMap linkedHashMap = new LinkedHashMap(f12110a.length); int i10 = 0; while (true) { c[] cVarArr = f12110a; if (i10 >= cVarArr.length) { return Collections.unmodifiableMap(linkedHashMap); } if (!linkedHashMap.containsKey(cVarArr[i10].f11992a)) { linkedHashMap.put(cVarArr[i10].f11992a, Integer.valueOf(i10)); } i10++; } } }