package o; import com.airbnb.deeplinkdispatch.UrlTreeKt; import com.google.common.primitives.UnsignedBytes; import java.lang.reflect.Array; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import java.util.ArrayList; import org.bouncycastle.crypto.tls.CipherSuite; /* loaded from: classes2.dex */ public final class wqv { private static char[] a = {'!', '\"', '#', '$', '%', '&', '\'', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', UrlTreeKt.configurablePathSegmentPrefixChar, '=', UrlTreeKt.configurablePathSegmentSuffixChar, '?', '@', '[', '\\', ']', '^', '_'}; /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes2.dex */ public enum IeS { ASCII, C40, TEXT, X12, EDF, B256 } static /* synthetic */ boolean a(char c) { return c <= 31; } static /* synthetic */ boolean c(char c) { return c <= 31; } static boolean c(char c, int i) { return c != i && c >= 128 && c <= 255; } /* JADX INFO: Access modifiers changed from: private */ public static boolean d(char c, int i) { for (char c2 : a) { if (c2 == c) { return true; } } return c == i; } public static String c(String str, Charset charset, int i, xHt xht) { int i2; if (str.startsWith("[)>\u001e05\u001d") && str.endsWith("\u001e\u0004")) { str = str.substring(7, str.length() - 2); i2 = 5; } else if (str.startsWith("[)>\u001e06\u001d") && str.endsWith("\u001e\u0004")) { str = str.substring(7, str.length() - 2); i2 = 6; } else { i2 = 0; } return new String(c(str, charset, i, xht, i2), StandardCharsets.ISO_8859_1); } private static byte[] c(String str, Charset charset, int i, xHt xht, int i2) { LWm lWm = new LWm(str, charset, i, xht, i2, (byte) 0); int length = lWm.e.length; HBt[][] hBtArr = (HBt[][]) Array.newInstance((Class) HBt.class, length + 1, 6); int i3 = 0; b(lWm, hBtArr, 0, null); for (int i4 = 1; i4 <= length; i4++) { for (int i5 = 0; i5 < 6; i5++) { HBt hBt = hBtArr[i4][i5]; if (hBt != null && i4 < length) { b(lWm, hBtArr, i4, hBt); } } for (int i6 = 0; i6 < 6; i6++) { hBtArr[i4 - 1][i6] = null; } } int i7 = -1; int i8 = Integer.MAX_VALUE; while (i3 < 6) { HBt hBt2 = hBtArr[length][i3]; if (hBt2 != null) { int i9 = (i3 <= 0 || i3 > 3) ? hBt2.i : hBt2.i + 1; if (i9 < i8) { i7 = i3; i8 = i9; } } i3++; } if (i7 < 0) { StringBuilder sb = new StringBuilder("Failed to encode \""); sb.append(lWm); sb.append("\""); throw new IllegalStateException(sb.toString()); } return new RVV(hBtArr[length][i7]).d; } private static void e(HBt[][] hBtArr, HBt hBt) { int i = hBt.c + hBt.e; if (hBtArr[i][hBt.c().ordinal()] == null || hBtArr[i][hBt.c().ordinal()].i > hBt.i) { hBtArr[i][hBt.c().ordinal()] = hBt; } } static int e(LWm lWm, int i, boolean z, int[] iArr) { int i2 = 0; for (int i3 = i; i3 < lWm.e.length; i3++) { if (lWm.d(i3)) { iArr[0] = 0; return 0; } char c = lWm.c(i3); if ((z && GpJ.e(c)) || (!z && GpJ.d(c))) { i2++; } else if (c == lWm.d || c < 128 || c > 255) { i2 += 2; } else { int i4 = c & 255; i2 = (i4 < 128 || (!(z && GpJ.e((char) (i4 + (-128)))) && (z || !GpJ.d((char) (i4 + (-128)))))) ? i2 + 4 : i2 + 3; } if (i2 % 3 == 0 || ((i2 - 2) % 3 == 0 && i3 + 1 == lWm.e.length)) { iArr[0] = (i3 - i) + 1; return (int) Math.ceil(i2 / 3.0d); } } iArr[0] = 0; return 0; } /* JADX WARN: Code restructure failed: missing block: B:22:0x0129, code lost: if (r17.e(r19, 4) == false) goto L66; */ /* JADX WARN: Code restructure failed: missing block: B:23:0x012b, code lost: r2 = r17.c(r19 + 3); */ /* JADX WARN: Code restructure failed: missing block: B:24:0x0131, code lost: if (r2 < ' ') goto L67; */ /* JADX WARN: Code restructure failed: missing block: B:25:0x0133, code lost: if (r2 > '^') goto L68; */ /* JADX WARN: Code restructure failed: missing block: B:26:0x0135, code lost: e(r18, new o.wqv.HBt(r17, o.wqv.IeS.EDF, r19, 4, r20, 0)); */ /* JADX WARN: Code restructure failed: missing block: B:27:0x0148, code lost: return; */ /* JADX WARN: Code restructure failed: missing block: B:28:?, code lost: return; */ /* JADX WARN: Code restructure failed: missing block: B:29:?, code lost: return; */ /* JADX WARN: Code restructure failed: missing block: B:30:?, code lost: return; */ /* JADX WARN: Multi-variable type inference failed */ /* JADX WARN: Type inference failed for: r11v0 */ /* JADX WARN: Type inference failed for: r11v1 */ /* JADX WARN: Type inference failed for: r11v4 */ /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct add '--show-bad-code' argument */ private static void b(o.wqv.LWm r17, o.wqv.HBt[][] r18, int r19, o.wqv.HBt r20) { /* Method dump skipped, instructions count: 329 To view this dump add '--comments-level debug' option */ throw new UnsupportedOperationException("Method not decompiled: o.wqv.b(o.wqv$LWm, o.wqv$HBt[][], int, o.wqv$HBt):void"); } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes2.dex */ public static final class HBt { final LWm a; final IeS b; final int c; final HBt d; final int e; private final int i; private static final int[] j = {3, 5, 8, 10, 12, 16, 18, 22, 30, 32, 36, 44, 49, 62, 86, 114, CipherSuite.TLS_DHE_PSK_WITH_AES_128_CBC_SHA, CipherSuite.TLS_PSK_WITH_AES_128_CBC_SHA256, 204, 280, 368, 456, 576, 696, 816, 1050, 1304, 1558}; private static final int[] g = {3, 5, 8, 12, 18, 22, 30, 36, 44, 62, 86, 114, CipherSuite.TLS_DHE_PSK_WITH_AES_128_CBC_SHA, CipherSuite.TLS_PSK_WITH_AES_128_CBC_SHA256, 204, 280, 368, 456, 576, 696, 816, 1050, 1304, 1558}; private static final int[] h = {5, 10, 16, 33, 32, 49}; static int a(char c) { if (c == '\r') { return 0; } if (c == '*') { return 1; } if (c == '>') { return 2; } if (c == ' ') { return 3; } return (c < '0' || c > '9') ? (c < 'A' || c > 'Z') ? c : c - '3' : c - ','; } private static int a(boolean z, int i, char c, int i2) { if (c == i2) { return 27; } if (z) { if (c <= 31) { return c; } if (c == ' ') { return 3; } return c <= '/' ? c - '!' : c <= '9' ? c - ',' : c <= '@' ? c - '+' : c <= 'Z' ? c - '3' : c <= '_' ? c - 'E' : c <= 127 ? c - '`' : c; } if (c != 0) { if (i == 0 && c <= 3) { return c - 1; } if (i == 1 && c <= 31) { return c; } if (c == ' ') { return 3; } if (c >= '!' && c <= '/') { return c - '!'; } if (c >= '0' && c <= '9') { return c - ','; } if (c >= ':' && c <= '@') { return c - '+'; } if (c >= 'A' && c <= 'Z') { return c - '@'; } if (c >= '[' && c <= '_') { return c - 'E'; } if (c != '`') { return (c < 'a' || c > 'z') ? (c < '{' || c > 127) ? c : c - '`' : c - 'S'; } } return 0; } /* synthetic */ HBt(LWm lWm, IeS ieS, int i, int i2, HBt hBt, byte b) { this(lWm, ieS, i, i2, hBt); } /* JADX WARN: Code restructure failed: missing block: B:34:0x0075, code lost: if (r9 == o.wqv.IeS.X12) goto L67; */ /* JADX WARN: Code restructure failed: missing block: B:52:0x0091, code lost: r0 = r0 + 1; */ /* JADX WARN: Code restructure failed: missing block: B:60:0x00a5, code lost: if (r9 != o.wqv.IeS.X12) goto L81; */ /* JADX WARN: Code restructure failed: missing block: B:74:0x00cb, code lost: if (r9 != o.wqv.IeS.X12) goto L81; */ /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct add '--show-bad-code' argument */ private HBt(o.wqv.LWm r5, o.wqv.IeS r6, int r7, int r8, o.wqv.HBt r9) { /* Method dump skipped, instructions count: 226 To view this dump add '--comments-level debug' option */ throw new UnsupportedOperationException("Method not decompiled: o.wqv.HBt.(o.wqv$LWm, o.wqv$IeS, int, int, o.wqv$HBt):void"); } final IeS c() { if (this.b == IeS.EDF) { if (this.e < 4) { return IeS.ASCII; } int d = d(); if (d > 0) { int i = this.i + d; if (b(i) - i <= 2 - d) { return IeS.ASCII; } } } if (this.b == IeS.C40 || this.b == IeS.TEXT || this.b == IeS.X12) { if (this.c + this.e >= this.a.e.length) { int i2 = this.i; if (b(i2) - i2 == 0) { return IeS.ASCII; } } if (d() == 1) { int i3 = this.i + 1; if (b(i3) - i3 == 0) { return IeS.ASCII; } } } return this.b; } private int d() { char c; char c2; char c3; char c4; char c5; char c6; int length = this.a.e.length; int i = this.c + this.e; int i2 = length - i; if (i2 <= 4 && i < length) { if (i2 == 1) { return wqv.c(this.a.c(i), this.a.d) ? 0 : 1; } if (i2 == 2) { if (!wqv.c(this.a.c(i), this.a.d)) { int i3 = i + 1; if (!wqv.c(this.a.c(i3), this.a.d)) { char c7 = this.a.c(i); return (c7 < '0' || c7 > '9' || (c6 = this.a.c(i3)) < '0' || c6 > '9') ? 2 : 1; } } return 0; } if (i2 == 3) { char c8 = this.a.c(i); if (c8 >= '0' && c8 <= '9' && (c5 = this.a.c(i + 1)) >= '0' && c5 <= '9' && !wqv.c(this.a.c(i + 2), this.a.d)) { return 2; } char c9 = this.a.c(i + 1); return (c9 < '0' || c9 > '9' || (c4 = this.a.c(i + 2)) < '0' || c4 > '9' || wqv.c(this.a.c(i), this.a.d)) ? 0 : 2; } char c10 = this.a.c(i); if (c10 >= '0' && c10 <= '9' && (c = this.a.c(i + 1)) >= '0' && c <= '9' && (c2 = this.a.c(i + 2)) >= '0' && c2 <= '9' && (c3 = this.a.c(i + 3)) >= '0' && c3 <= '9') { return 2; } } return 0; } final int b(int i) { int i2 = AnonymousClass1.b[this.a.b.ordinal()]; if (i2 == 1) { for (int i3 : g) { if (i3 >= i) { return i3; } } } else if (i2 == 2) { for (int i4 : h) { if (i4 >= i) { return i4; } } } for (int i5 : j) { if (i5 >= i) { return i5; } } int[] iArr = j; return iArr[iArr.length - 1]; } static void b(byte[] bArr, int i, int i2, int i3, int i4) { int i5 = ((i2 & 255) * 1600) + ((i3 & 255) * 40) + (i4 & 255) + 1; bArr[i] = (byte) (i5 / 256); bArr[i + 1] = (byte) (i5 % 256); } private static int d(char c, boolean z, int i) { if (!(z && wqv.c(c)) && (z || !wqv.a(c))) { return (!(z && wqv.d(c, i)) && (z || !wqv.d(c, i))) ? 2 : 1; } return 0; } final byte[] a(boolean z, int i) { ArrayList arrayList = new ArrayList(); for (int i2 = 0; i2 < this.e; i2++) { char c = this.a.c(this.c + i2); if ((z && GpJ.e(c)) || (!z && GpJ.d(c))) { arrayList.add(Byte.valueOf((byte) a(z, 0, c, i))); } else if (!wqv.c(c, i)) { int d = d(c, z, i); arrayList.add(Byte.valueOf((byte) d)); arrayList.add(Byte.valueOf((byte) a(z, d, c, i))); } else { char c2 = (char) ((c & 255) - 128); if ((z && GpJ.e(c2)) || (!z && GpJ.d(c2))) { arrayList.add((byte) 1); arrayList.add((byte) 30); arrayList.add(Byte.valueOf((byte) a(z, 0, c2, i))); } else { arrayList.add((byte) 1); arrayList.add((byte) 30); int d2 = d(c2, z, i); arrayList.add(Byte.valueOf((byte) d2)); arrayList.add(Byte.valueOf((byte) a(z, d2, c2, i))); } } } if (arrayList.size() % 3 != 0) { arrayList.add((byte) 0); } byte[] bArr = new byte[(arrayList.size() / 3) << 1]; int i3 = 0; for (int i4 = 0; i4 < arrayList.size(); i4 += 3) { b(bArr, i3, ((Byte) arrayList.get(i4)).byteValue() & UnsignedBytes.MAX_VALUE, ((Byte) arrayList.get(i4 + 1)).byteValue() & UnsignedBytes.MAX_VALUE, ((Byte) arrayList.get(i4 + 2)).byteValue() & UnsignedBytes.MAX_VALUE); i3 += 2; } return bArr; } static byte[] b(int i, int i2) { return new byte[]{(byte) i, (byte) i2}; } static byte[] e(int i) { return new byte[]{(byte) i}; } } /* JADX INFO: Access modifiers changed from: package-private */ /* renamed from: o.wqv$1, reason: invalid class name */ /* loaded from: classes2.dex */ public static /* synthetic */ class AnonymousClass1 { static final int[] b; static final int[] c; static { int[] iArr = new int[xHt.values().length]; b = iArr; try { iArr[xHt.FORCE_SQUARE.ordinal()] = 1; } catch (NoSuchFieldError unused) { } try { b[xHt.FORCE_RECTANGLE.ordinal()] = 2; } catch (NoSuchFieldError unused2) { } int[] iArr2 = new int[IeS.values().length]; c = iArr2; try { iArr2[IeS.ASCII.ordinal()] = 1; } catch (NoSuchFieldError unused3) { } try { c[IeS.B256.ordinal()] = 2; } catch (NoSuchFieldError unused4) { } try { c[IeS.C40.ordinal()] = 3; } catch (NoSuchFieldError unused5) { } try { c[IeS.TEXT.ordinal()] = 4; } catch (NoSuchFieldError unused6) { } try { c[IeS.X12.ordinal()] = 5; } catch (NoSuchFieldError unused7) { } try { c[IeS.EDF.ordinal()] = 6; } catch (NoSuchFieldError unused8) { } } } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes2.dex */ public static final class RVV { final byte[] d; /* JADX WARN: Removed duplicated region for block: B:51:0x02d7 A[LOOP:2: B:50:0x02d5->B:51:0x02d7, LOOP_END] */ /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct add '--show-bad-code' argument */ RVV(o.wqv.HBt r20) { /* Method dump skipped, instructions count: 1026 To view this dump add '--comments-level debug' option */ throw new UnsupportedOperationException("Method not decompiled: o.wqv.RVV.(o.wqv$HBt):void"); } } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes2.dex */ public static final class LWm extends C16224mUD { final int a; final xHt b; /* synthetic */ LWm(String str, Charset charset, int i, xHt xht, int i2, byte b) { this(str, charset, i, xht, i2); } private LWm(String str, Charset charset, int i, xHt xht, int i2) { super(str, charset, i); this.b = xht; this.a = i2; } } }