package p447;

import java.net.URI;
import java.net.URISyntaxException;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import kotlin.TypeCastException;
import kotlin.jvm.internal.DefaultConstructorMarker;
import p138.p139.p143.p144.C2803;
import p138.p176.p177.p242.p246.p251.C4303;
import p402.InterfaceC6540;
import p402.p411.p413.C6635;
import p402.p417.C6659;
import p402.p417.C6664;
import p402.p420.C6689;
import p402.p420.C6695;
import p402.p420.C6703;
import p447.p448.C6943;
import p461.C7103;

/* JADX INFO: renamed from: ސ.ޔ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes.dex */
@InterfaceC6540
public final class C6908 {

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final boolean f20013;

    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
    public final String f20014;

    /* JADX INFO: renamed from: ހ, reason: contains not printable characters */
    public final String f20015;

    /* JADX INFO: renamed from: ށ, reason: contains not printable characters */
    public final String f20016;

    /* JADX INFO: renamed from: ނ, reason: contains not printable characters */
    public final String f20017;

    /* JADX INFO: renamed from: ރ, reason: contains not printable characters */
    public final int f20018;

    /* JADX INFO: renamed from: ބ, reason: contains not printable characters */
    public final List<String> f20019;

    /* JADX INFO: renamed from: ޅ, reason: contains not printable characters */
    public final List<String> f20020;

    /* JADX INFO: renamed from: ކ, reason: contains not printable characters */
    public final String f20021;

    /* JADX INFO: renamed from: އ, reason: contains not printable characters */
    public final String f20022;

    /* JADX INFO: renamed from: މ, reason: contains not printable characters */
    public static final C6911 f20012 = new C6911(null);

    /* JADX INFO: renamed from: ވ, reason: contains not printable characters */
    public static final char[] f20011 = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};

    /* JADX INFO: renamed from: ސ.ޔ$֏, reason: contains not printable characters */
    @InterfaceC6540
    public static final class C6909 {

        /* JADX INFO: renamed from: ކ, reason: contains not printable characters */
        public static final C6910 f20023 = new C6910(null);

        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public String f20024;

        /* JADX INFO: renamed from: ށ, reason: contains not printable characters */
        public String f20027;

        /* JADX INFO: renamed from: ރ, reason: contains not printable characters */
        public final List<String> f20029;

        /* JADX INFO: renamed from: ބ, reason: contains not printable characters */
        public List<String> f20030;

        /* JADX INFO: renamed from: ޅ, reason: contains not printable characters */
        public String f20031;

        /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
        public String f20025 = "";

        /* JADX INFO: renamed from: ހ, reason: contains not printable characters */
        public String f20026 = "";

        /* JADX INFO: renamed from: ނ, reason: contains not printable characters */
        public int f20028 = -1;

        /* JADX INFO: renamed from: ސ.ޔ$֏$֏, reason: contains not printable characters */
        public static final class C6910 {
            public C6910() {
            }

            public /* synthetic */ C6910(DefaultConstructorMarker defaultConstructorMarker) {
            }
        }

        public C6909() {
            ArrayList arrayList = new ArrayList();
            this.f20029 = arrayList;
            arrayList.add("");
        }

        /* JADX WARN: Removed duplicated region for block: B:17:0x0035  */
        /* JADX WARN: Removed duplicated region for block: B:46:0x009b  */
        /*
            Code decompiled incorrectly, please refer to instructions dump.
        */
        public String toString() {
            StringBuilder sb = new StringBuilder();
            String str = this.f20024;
            if (str != null) {
                sb.append(str);
                sb.append("://");
            } else {
                sb.append("//");
            }
            if (this.f20025.length() > 0) {
                sb.append(this.f20025);
                if (this.f20026.length() > 0) {
                    sb.append(':');
                    sb.append(this.f20026);
                }
                sb.append('@');
            } else if (this.f20026.length() > 0) {
            }
            String str2 = this.f20027;
            if (str2 != null) {
                if (str2 == null) {
                    C6635.m9822();
                    throw null;
                }
                if (C6703.m9878((CharSequence) str2, ':', false, 2)) {
                    sb.append('[');
                    sb.append(this.f20027);
                    sb.append(']');
                } else {
                    sb.append(this.f20027);
                }
            }
            if (this.f20028 != -1 || this.f20024 != null) {
                int iM10093 = m10093();
                String str3 = this.f20024;
                if (str3 != null) {
                    C6911 c6911 = C6908.f20012;
                    if (str3 == null) {
                        C6635.m9822();
                        throw null;
                    }
                    if (iM10093 != c6911.m10096(str3)) {
                        sb.append(':');
                        sb.append(iM10093);
                    }
                }
            }
            C6911 c69112 = C6908.f20012;
            List<String> list = this.f20029;
            if (c69112 == null) {
                throw null;
            }
            if (list == null) {
                C6635.m9824("$this$toPathString");
                throw null;
            }
            int size = list.size();
            for (int i = 0; i < size; i++) {
                sb.append('/');
                sb.append(list.get(i));
            }
            if (this.f20030 != null) {
                sb.append('?');
                C6911 c69113 = C6908.f20012;
                List<String> list2 = this.f20030;
                if (list2 == null) {
                    C6635.m9822();
                    throw null;
                }
                c69113.m10097(list2, sb);
            }
            if (this.f20031 != null) {
                sb.append('#');
                sb.append(this.f20031);
            }
            String string = sb.toString();
            C6635.m9823((Object) string, "StringBuilder().apply(builderAction).toString()");
            return string;
        }

        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public final C6909 m10089(String str) {
            String strM10094;
            this.f20030 = (str == null || (strM10094 = C6911.m10094(C6908.f20012, str, 0, 0, " \"'<>#", true, false, true, false, null, 211)) == null) ? null : C6908.f20012.m10100(strM10094);
            return this;
        }

        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public final C6909 m10090(String str, String str2) {
            if (str == null) {
                C6635.m9824("encodedName");
                throw null;
            }
            if (this.f20030 == null) {
                this.f20030 = new ArrayList();
            }
            List<String> list = this.f20030;
            if (list == null) {
                C6635.m9822();
                throw null;
            }
            list.add(C6911.m10094(C6908.f20012, str, 0, 0, " \"'<>#&=", true, false, true, false, null, 211));
            List<String> list2 = this.f20030;
            if (list2 != null) {
                list2.add(str2 != null ? C6911.m10094(C6908.f20012, str2, 0, 0, " \"'<>#&=", true, false, true, false, null, 211) : null);
                return this;
            }
            C6635.m9822();
            throw null;
        }

        /* JADX WARN: Multi-variable type inference failed */
        /* JADX WARN: Removed duplicated region for block: B:198:0x03d6  */
        /* JADX WARN: Removed duplicated region for block: B:43:0x006d  */
        /* JADX WARN: Type inference failed for: r14v1 */
        /* JADX WARN: Type inference failed for: r14v13 */
        /* JADX WARN: Type inference failed for: r14v15 */
        /* JADX WARN: Type inference failed for: r14v2 */
        /* JADX WARN: Type inference failed for: r14v3, types: [boolean] */
        /* JADX WARN: Type inference failed for: r14v5 */
        /* JADX WARN: Type inference failed for: r14v6 */
        /* JADX WARN: Type inference failed for: r14v7 */
        /* JADX WARN: Type inference failed for: r2v51 */
        /* JADX WARN: Type inference failed for: r2v65 */
        /* JADX WARN: Type inference failed for: r3v51 */
        /* JADX WARN: Type inference failed for: r3v69 */
        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        /*
            Code decompiled incorrectly, please refer to instructions dump.
        */
        public final C6909 m10091(C6908 c6908, String str) {
            int i;
            char c;
            char c2;
            int iM10149;
            int i2;
            int i3;
            int i4;
            char c3;
            int i5;
            int i6;
            int i7;
            int i8;
            int i9;
            int i10;
            boolean z;
            String str2;
            int i11;
            ?? r14;
            int i12;
            String str3;
            C6909 c6909;
            C6909 c69092;
            String str4;
            int i13;
            String str5;
            int i14;
            C6909 c69093;
            int i15;
            C6909 c69094;
            String str6;
            char cCharAt;
            String str7 = str;
            if (str7 == null) {
                C6635.m9824("input");
                throw null;
            }
            int iM10147 = C6943.m10147(str7, 0, 0, 3);
            int iM10174 = C6943.m10174(str7, iM10147, str.length());
            if (f20023 == null) {
                throw null;
            }
            char c4 = ':';
            char c5 = 65535;
            if (iM10174 - iM10147 < 2) {
                i = -1;
            } else {
                char cCharAt2 = str7.charAt(iM10147);
                char c6 = 'Z';
                char c7 = 'z';
                if ((cCharAt2 >= 'a' && cCharAt2 <= 'z') || (cCharAt2 >= 'A' && cCharAt2 <= 'Z')) {
                    i = iM10147;
                    while (true) {
                        i++;
                        if (i < iM10174) {
                            char cCharAt3 = str7.charAt(i);
                            if (('a' > cCharAt3 || c7 < cCharAt3) && (('A' > cCharAt3 || c6 < cCharAt3) && (('0' > cCharAt3 || '9' < cCharAt3) && cCharAt3 != '+' && cCharAt3 != '-' && cCharAt3 != '.'))) {
                                if (cCharAt3 != ':') {
                                    break;
                                }
                            } else {
                                c6 = 'Z';
                                c7 = 'z';
                            }
                        } else {
                            break;
                        }
                    }
                    i = -1;
                }
            }
            if (i != -1) {
                if (C6703.m9883(str7, "https:", iM10147, true)) {
                    this.f20024 = "https";
                    iM10147 += 6;
                } else {
                    if (!C6703.m9883(str7, "http:", iM10147, true)) {
                        StringBuilder sbM4889 = C2803.m4889("Expected URL scheme 'http' or 'https' but was '");
                        String strSubstring = str7.substring(0, i);
                        C6635.m9823((Object) strSubstring, "(this as java.lang.Strin…ing(startIndex, endIndex)");
                        sbM4889.append(strSubstring);
                        sbM4889.append("'");
                        throw new IllegalArgumentException(sbM4889.toString());
                    }
                    this.f20024 = "http";
                    iM10147 += 5;
                }
            } else {
                if (c6908 == null) {
                    throw new IllegalArgumentException("Expected URL scheme 'http' or 'https' but no colon was found");
                }
                this.f20024 = c6908.f20014;
            }
            if (f20023 == null) {
                throw null;
            }
            int i16 = 0;
            int i17 = iM10147;
            while (true) {
                c = '/';
                c2 = '\\';
                if (i17 >= iM10174 || !((cCharAt = str7.charAt(i17)) == '\\' || cCharAt == '/')) {
                    break;
                }
                i16++;
                i17++;
            }
            char c8 = '?';
            if (i16 >= 2 || c6908 == null || (!C6635.m9825((Object) c6908.f20014, (Object) this.f20024))) {
                int i18 = iM10147 + i16;
                char c9 = '#';
                boolean z2 = false;
                boolean z3 = false;
                while (true) {
                    iM10149 = C6943.m10149(str7, "@/\\?#", i18, iM10174);
                    char cCharAt4 = iM10149 != iM10174 ? str7.charAt(iM10149) : (char) 65535;
                    if (cCharAt4 == c5 || cCharAt4 == c9 || cCharAt4 == c || cCharAt4 == c2 || cCharAt4 == c8) {
                        break;
                    }
                    if (cCharAt4 != '@') {
                        i10 = iM10174;
                    } else {
                        if (z2) {
                            boolean z4 = z2;
                            i9 = iM10149;
                            StringBuilder sb = new StringBuilder();
                            sb.append(this.f20026);
                            sb.append("%40");
                            i10 = iM10174;
                            sb.append(C6911.m10094(C6908.f20012, str, i18, i9, " \"':;<=>@[]^`{}|/\\?#", true, false, false, false, null, 240));
                            this.f20026 = sb.toString();
                            z = z4;
                        } else {
                            int iM10143 = C6943.m10143(str7, c4, i18, iM10149);
                            boolean z5 = z2;
                            i9 = iM10149;
                            String strM10094 = C6911.m10094(C6908.f20012, str, i18, iM10143, " \"':;<=>@[]^`{}|/\\?#", true, false, false, false, null, 240);
                            if (z3) {
                                strM10094 = this.f20025 + "%40" + strM10094;
                            }
                            this.f20025 = strM10094;
                            if (iM10143 != i9) {
                                this.f20026 = C6911.m10094(C6908.f20012, str, iM10143 + 1, i9, " \"':;<=>@[]^`{}|/\\?#", true, false, false, false, null, 240);
                                z = true;
                            } else {
                                z = z5;
                            }
                            z3 = true;
                            i10 = iM10174;
                        }
                        i18 = i9 + 1;
                        z2 = z;
                    }
                    c9 = '#';
                    c8 = '?';
                    c2 = '\\';
                    c = '/';
                    c5 = 65535;
                    c4 = ':';
                    iM10174 = i10;
                }
                i2 = iM10174;
                if (f20023 == null) {
                    throw null;
                }
                int i19 = i18;
                while (true) {
                    if (i19 < iM10149) {
                        char cCharAt5 = str7.charAt(i19);
                        if (cCharAt5 == ':') {
                            i3 = i19;
                            break;
                        }
                        if (cCharAt5 == '[') {
                            do {
                                i19++;
                                if (i19 < iM10149) {
                                }
                            } while (str7.charAt(i19) != ']');
                        }
                        i19++;
                    } else {
                        i3 = iM10149;
                        break;
                    }
                }
                int i20 = i3 + 1;
                if (i20 < iM10149) {
                    this.f20027 = C4303.m7203(C6911.m10095(C6908.f20012, str, i18, i3, false, 4));
                    if (f20023 == null) {
                        throw null;
                    }
                    try {
                        i7 = i20;
                        i4 = i18;
                        try {
                            i8 = Integer.parseInt(C6911.m10094(C6908.f20012, str, i20, iM10149, "", false, false, false, false, null, 248));
                        } catch (NumberFormatException unused) {
                        }
                    } catch (NumberFormatException unused2) {
                        i7 = i20;
                        i4 = i18;
                    }
                    if (1 <= i8 && 65535 >= i8) {
                        i5 = 1;
                    } else {
                        i5 = 1;
                        i8 = -1;
                    }
                    this.f20028 = i8;
                    if (!(i8 != -1)) {
                        StringBuilder sbM48892 = C2803.m4889("Invalid URL port: \"");
                        String strSubstring2 = str7.substring(i7, iM10149);
                        C6635.m9823((Object) strSubstring2, "(this as java.lang.Strin…ing(startIndex, endIndex)");
                        sbM48892.append(strSubstring2);
                        sbM48892.append('\"');
                        throw new IllegalArgumentException(sbM48892.toString().toString());
                    }
                    c3 = '\"';
                } else {
                    i4 = i18;
                    this.f20027 = C4303.m7203(C6911.m10095(C6908.f20012, str, i4, i3, false, 4));
                    C6911 c6911 = C6908.f20012;
                    String str8 = this.f20024;
                    if (str8 == null) {
                        C6635.m9822();
                        throw null;
                    }
                    this.f20028 = c6911.m10096(str8);
                    c3 = '\"';
                    i5 = 1;
                }
                if (!(this.f20027 != null)) {
                    StringBuilder sbM48893 = C2803.m4889("Invalid URL host: \"");
                    String strSubstring3 = str7.substring(i4, i3);
                    C6635.m9823((Object) strSubstring3, "(this as java.lang.Strin…ing(startIndex, endIndex)");
                    sbM48893.append(strSubstring3);
                    sbM48893.append(c3);
                    throw new IllegalArgumentException(sbM48893.toString().toString());
                }
                i6 = i5;
                iM10147 = iM10149;
            } else {
                this.f20025 = c6908.m10085();
                this.f20026 = c6908.m10079();
                this.f20027 = c6908.f20017;
                this.f20028 = c6908.f20018;
                this.f20029.clear();
                this.f20029.addAll(c6908.m10083());
                if (iM10147 == iM10174 || str7.charAt(iM10147) == '#') {
                    m10089(c6908.m10084());
                }
                i6 = 1;
                i2 = iM10174;
            }
            int i21 = i2;
            int iM101492 = C6943.m10149(str7, "?#", iM10147, i21);
            if (iM10147 == iM101492) {
                c69093 = this;
                i15 = i21;
                str5 = str7;
            } else {
                char cCharAt6 = str7.charAt(iM10147);
                if (cCharAt6 == '/' || cCharAt6 == '\\') {
                    this.f20029.clear();
                    this.f20029.add("");
                    int i22 = i6;
                    str2 = str7;
                    i11 = iM10147 + i22;
                    r14 = i22;
                    i12 = iM101492;
                    str3 = "";
                    c6909 = this;
                    c69092 = this;
                    str4 = str7;
                    i13 = i21;
                    str5 = str7;
                    i14 = iM101492;
                } else {
                    List<String> list = this.f20029;
                    list.set(list.size() - i6, "");
                    c69092 = this;
                    c6909 = c69092;
                    r14 = i6;
                    i12 = iM101492;
                    i13 = i21;
                    str3 = "";
                    str2 = str7;
                    str4 = str2;
                    str5 = str4;
                    i11 = iM10147;
                    i14 = i12;
                }
                while (i11 < i14) {
                    int iM101493 = C6943.m10149(str4, "/\\", i11, i14);
                    boolean z6 = iM101493 < i14;
                    String str9 = str4;
                    C6909 c69095 = c69092;
                    String str10 = str3;
                    int i23 = i14;
                    String strM100942 = C6911.m10094(C6908.f20012, str4, i11, iM101493, " \"<>^`{}|/\\?#", true, false, false, false, null, 240);
                    if (C6635.m9825((Object) strM100942, (Object) ".") || C6703.m9905(strM100942, "%2e", (boolean) r14)) {
                        c69094 = c69095;
                        str6 = str10;
                    } else {
                        if (C6635.m9825((Object) strM100942, (Object) "..") || C6703.m9905(strM100942, "%2e.", (boolean) r14) || C6703.m9905(strM100942, ".%2e", (boolean) r14) || C6703.m9905(strM100942, "%2e%2e", (boolean) r14)) {
                            c69094 = c69095;
                            List<String> list2 = c69094.f20029;
                            if (list2.remove(list2.size() - (r14 == true ? 1 : 0)).length() == 0) {
                                if (((c69094.f20029.isEmpty() ? 1 : 0) ^ (r14 == true ? 1 : 0)) != 0) {
                                    List<String> list3 = c69094.f20029;
                                    str6 = str10;
                                    list3.set(list3.size() - (r14 == true ? 1 : 0), str6);
                                } else {
                                    str6 = str10;
                                    c69094.f20029.add(str6);
                                }
                            }
                        } else {
                            c69094 = c69095;
                            str6 = str10;
                            List<String> list4 = c69094.f20029;
                            if (list4.get(list4.size() - (r14 == true ? 1 : 0)).length() == 0) {
                                List<String> list5 = c69094.f20029;
                                list5.set(list5.size() - (r14 == true ? 1 : 0), strM100942);
                            } else {
                                c69094.f20029.add(strM100942);
                            }
                            if (z6) {
                                c69094.f20029.add(str6);
                            }
                        }
                    }
                    if (z6) {
                        String str11 = str6;
                        String str12 = str5;
                        ?? r3 = r14 == true ? 1 : 0;
                        int i24 = i12;
                        C6909 c69096 = c6909;
                        int i25 = i13;
                        i11 = iM101493 + (r3 == true ? 1 : 0);
                        r14 = r3 == true ? 1 : 0;
                        i12 = i24;
                        str3 = str11;
                        c6909 = c69096;
                        c69092 = c69094;
                        str4 = str9;
                        i13 = i25;
                        str5 = str12;
                        i14 = i23;
                    } else {
                        str3 = str6;
                        c69092 = c69094;
                        str4 = str9;
                        i14 = i23;
                        i11 = iM101493;
                    }
                }
                str7 = str2;
                iM101492 = i12;
                c69093 = c6909;
                i15 = i13;
            }
            if (iM101492 < i15 && str5.charAt(iM101492) == '?') {
                int iM101432 = C6943.m10143(str5, '#', iM101492, i15);
                C6911 c69112 = C6908.f20012;
                c69093.f20030 = c69112.m10100(C6911.m10094(c69112, str7, iM101492 + 1, iM101432, " \"'<>#", true, false, true, false, null, 208));
                iM101492 = iM101432;
            }
            if (iM101492 < i15 && str5.charAt(iM101492) == '#') {
                c69093.f20031 = C6911.m10094(C6908.f20012, str7, iM101492 + 1, i15, "", true, false, false, true, null, 176);
            }
            return c69093;
        }

        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public final C6908 m10092() {
            ArrayList arrayList;
            String str = this.f20024;
            if (str == null) {
                throw new IllegalStateException("scheme == null");
            }
            String strM10095 = C6911.m10095(C6908.f20012, this.f20025, 0, 0, false, 7);
            String strM100952 = C6911.m10095(C6908.f20012, this.f20026, 0, 0, false, 7);
            String str2 = this.f20027;
            if (str2 == null) {
                throw new IllegalStateException("host == null");
            }
            int iM10093 = m10093();
            List<String> list = this.f20029;
            ArrayList arrayList2 = new ArrayList(C4303.m6985(list, 10));
            Iterator<T> it = list.iterator();
            while (it.hasNext()) {
                arrayList2.add(C6911.m10095(C6908.f20012, (String) it.next(), 0, 0, false, 7));
            }
            List<String> list2 = this.f20030;
            if (list2 != null) {
                ArrayList arrayList3 = new ArrayList(C4303.m6985(list2, 10));
                for (String str3 : list2) {
                    arrayList3.add(str3 != null ? C6911.m10095(C6908.f20012, str3, 0, 0, true, 3) : null);
                }
                arrayList = arrayList3;
            } else {
                arrayList = null;
            }
            String str4 = this.f20031;
            return new C6908(str, strM10095, strM100952, str2, iM10093, arrayList2, arrayList, str4 != null ? C6911.m10095(C6908.f20012, str4, 0, 0, false, 7) : null, toString());
        }

        /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
        public final int m10093() {
            int i = this.f20028;
            if (i != -1) {
                return i;
            }
            C6911 c6911 = C6908.f20012;
            String str = this.f20024;
            if (str != null) {
                return c6911.m10096(str);
            }
            C6635.m9822();
            throw null;
        }
    }

    /* JADX INFO: renamed from: ސ.ޔ$ؠ, reason: contains not printable characters */
    public static final class C6911 {
        public C6911() {
        }

        public /* synthetic */ C6911(DefaultConstructorMarker defaultConstructorMarker) {
        }

        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public static /* synthetic */ String m10094(C6911 c6911, String str, int i, int i2, String str2, boolean z, boolean z2, boolean z3, boolean z4, Charset charset, int i3) {
            boolean z5;
            int i4 = (i3 & 1) != 0 ? 0 : i;
            int length = (i3 & 2) != 0 ? str.length() : i2;
            boolean z6 = (i3 & 8) != 0 ? false : z;
            boolean z7 = (i3 & 16) != 0 ? false : z2;
            boolean z8 = (i3 & 32) != 0 ? false : z3;
            boolean z9 = (i3 & 64) != 0 ? false : z4;
            Charset charset2 = (i3 & 128) != 0 ? null : charset;
            if (c6911 == null) {
                throw null;
            }
            if (str == null) {
                C6635.m9824("$this$canonicalize");
                throw null;
            }
            if (str2 == null) {
                C6635.m9824("encodeSet");
                throw null;
            }
            int iCharCount = i4;
            while (iCharCount < length) {
                int iCodePointAt = str.codePointAt(iCharCount);
                int i5 = 2;
                if (iCodePointAt < 32 || iCodePointAt == 127 || ((iCodePointAt >= 128 && !z9) || C6703.m9878((CharSequence) str2, (char) iCodePointAt, false, 2) || ((iCodePointAt == 37 && (!z6 || (z7 && !c6911.m10098(str, iCharCount, length)))) || (iCodePointAt == 43 && z8)))) {
                    C7103 c7103 = new C7103();
                    c7103.mo10415(str, i4, iCharCount);
                    C7103 c71032 = null;
                    while (iCharCount < length) {
                        int iCodePointAt2 = str.codePointAt(iCharCount);
                        if (z6 && (iCodePointAt2 == 9 || iCodePointAt2 == 10 || iCodePointAt2 == 12 || iCodePointAt2 == 13)) {
                            z5 = z8;
                        } else if (iCodePointAt2 == 43 && z8) {
                            c7103.mo10414(z6 ? "+" : "%2B");
                            z5 = z8;
                        } else {
                            if (iCodePointAt2 < 32 || iCodePointAt2 == 127 || (iCodePointAt2 >= 128 && !z9)) {
                                z5 = z8;
                            } else {
                                z5 = z8;
                                if (!C6703.m9878((CharSequence) str2, (char) iCodePointAt2, false, i5) && (iCodePointAt2 != 37 || (z6 && (!z7 || c6911.m10098(str, iCharCount, length))))) {
                                    c7103.m10425(iCodePointAt2);
                                }
                            }
                            if (c71032 == null) {
                                c71032 = new C7103();
                            }
                            if (charset2 == null || C6635.m9825(charset2, StandardCharsets.UTF_8)) {
                                c71032.m10425(iCodePointAt2);
                            } else {
                                int iCharCount2 = Character.charCount(iCodePointAt2) + iCharCount;
                                if (!(iCharCount >= 0)) {
                                    throw new IllegalArgumentException(C2803.m4871("beginIndex < 0: ", iCharCount).toString());
                                }
                                if (!(iCharCount2 >= iCharCount)) {
                                    throw new IllegalArgumentException(C2803.m4873("endIndex < beginIndex: ", iCharCount2, " < ", iCharCount).toString());
                                }
                                if (!(iCharCount2 <= str.length())) {
                                    StringBuilder sbM4896 = C2803.m4896("endIndex > string.length: ", iCharCount2, " > ");
                                    sbM4896.append(str.length());
                                    throw new IllegalArgumentException(sbM4896.toString().toString());
                                }
                                if (C6635.m9825(charset2, C6689.f19437)) {
                                    c71032.mo10415(str, iCharCount, iCharCount2);
                                } else {
                                    String strSubstring = str.substring(iCharCount, iCharCount2);
                                    C6635.m9823((Object) strSubstring, "(this as java.lang.Strin…ing(startIndex, endIndex)");
                                    byte[] bytes = strSubstring.getBytes(charset2);
                                    C6635.m9823((Object) bytes, "(this as java.lang.String).getBytes(charset)");
                                    c71032.write(bytes, 0, bytes.length);
                                }
                            }
                            while (!c71032.mo10436()) {
                                int i6 = c71032.readByte() & 255;
                                c7103.writeByte(37);
                                c7103.writeByte((int) C6908.f20011[(i6 >> 4) & 15]);
                                c7103.writeByte((int) C6908.f20011[i6 & 15]);
                            }
                        }
                        iCharCount += Character.charCount(iCodePointAt2);
                        i5 = 2;
                        z8 = z5;
                    }
                    return c7103.m10437();
                }
                iCharCount += Character.charCount(iCodePointAt);
            }
            String strSubstring2 = str.substring(i4, length);
            C6635.m9823((Object) strSubstring2, "(this as java.lang.Strin…ing(startIndex, endIndex)");
            return strSubstring2;
        }

        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public static /* synthetic */ String m10095(C6911 c6911, String str, int i, int i2, boolean z, int i3) {
            int i4;
            if ((i3 & 1) != 0) {
                i = 0;
            }
            if ((i3 & 2) != 0) {
                i2 = str.length();
            }
            if ((i3 & 4) != 0) {
                z = false;
            }
            if (c6911 == null) {
                throw null;
            }
            if (str == null) {
                C6635.m9824("$this$percentDecode");
                throw null;
            }
            int iCharCount = i;
            while (iCharCount < i2) {
                char cCharAt = str.charAt(iCharCount);
                if (cCharAt == '%' || (cCharAt == '+' && z)) {
                    C7103 c7103 = new C7103();
                    c7103.mo10415(str, i, iCharCount);
                    while (iCharCount < i2) {
                        int iCodePointAt = str.codePointAt(iCharCount);
                        if (iCodePointAt == 37 && (i4 = iCharCount + 2) < i2) {
                            int iM10142 = C6943.m10142(str.charAt(iCharCount + 1));
                            int iM101422 = C6943.m10142(str.charAt(i4));
                            if (iM10142 == -1 || iM101422 == -1) {
                                c7103.m10425(iCodePointAt);
                                iCharCount += Character.charCount(iCodePointAt);
                            } else {
                                c7103.writeByte((iM10142 << 4) + iM101422);
                                iCharCount = Character.charCount(iCodePointAt) + i4;
                            }
                        } else if (iCodePointAt == 43 && z) {
                            c7103.writeByte(32);
                            iCharCount++;
                        } else {
                            c7103.m10425(iCodePointAt);
                            iCharCount += Character.charCount(iCodePointAt);
                        }
                    }
                    return c7103.m10437();
                }
                iCharCount++;
            }
            String strSubstring = str.substring(i, i2);
            C6635.m9823((Object) strSubstring, "(this as java.lang.Strin…ing(startIndex, endIndex)");
            return strSubstring;
        }

        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public final int m10096(String str) {
            if (str == null) {
                C6635.m9824("scheme");
                throw null;
            }
            int iHashCode = str.hashCode();
            if (iHashCode != 3213448) {
                if (iHashCode == 99617003 && str.equals("https")) {
                    return 443;
                }
            } else if (str.equals("http")) {
                return 80;
            }
            return -1;
        }

        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public final void m10097(List<String> list, StringBuilder sb) {
            if (list == null) {
                C6635.m9824("$this$toQueryString");
                throw null;
            }
            if (sb == null) {
                C6635.m9824("out");
                throw null;
            }
            C6659 c6659M9845 = C6664.m9845(C6664.m9846(0, list.size()), 2);
            int i = c6659M9845.f19412;
            int i2 = c6659M9845.f19413;
            int i3 = c6659M9845.f19414;
            if (i3 >= 0) {
                if (i > i2) {
                    return;
                }
            } else if (i < i2) {
                return;
            }
            while (true) {
                String str = list.get(i);
                String str2 = list.get(i + 1);
                if (i > 0) {
                    sb.append('&');
                }
                sb.append(str);
                if (str2 != null) {
                    sb.append('=');
                    sb.append(str2);
                }
                if (i == i2) {
                    return;
                } else {
                    i += i3;
                }
            }
        }

        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public final boolean m10098(String str, int i, int i2) {
            int i3 = i + 2;
            return i3 < i2 && str.charAt(i) == '%' && C6943.m10142(str.charAt(i + 1)) != -1 && C6943.m10142(str.charAt(i3)) != -1;
        }

        /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
        public final C6908 m10099(String str) {
            if (str == null) {
                C6635.m9824("$this$toHttpUrl");
                throw null;
            }
            C6909 c6909 = new C6909();
            c6909.m10091((C6908) null, str);
            return c6909.m10092();
        }

        /* JADX INFO: renamed from: ހ, reason: contains not printable characters */
        public final List<String> m10100(String str) {
            if (str == null) {
                C6635.m9824("$this$toQueryNamesAndValues");
                throw null;
            }
            ArrayList arrayList = new ArrayList();
            int i = 0;
            while (i <= str.length()) {
                int iM9856 = C6703.m9856((CharSequence) str, '&', i, false, 4);
                if (iM9856 == -1) {
                    iM9856 = str.length();
                }
                int iM98562 = C6703.m9856((CharSequence) str, '=', i, false, 4);
                if (iM98562 == -1 || iM98562 > iM9856) {
                    String strSubstring = str.substring(i, iM9856);
                    C6635.m9823((Object) strSubstring, "(this as java.lang.Strin…ing(startIndex, endIndex)");
                    arrayList.add(strSubstring);
                    arrayList.add(null);
                } else {
                    String strSubstring2 = str.substring(i, iM98562);
                    C6635.m9823((Object) strSubstring2, "(this as java.lang.Strin…ing(startIndex, endIndex)");
                    arrayList.add(strSubstring2);
                    String strSubstring3 = str.substring(iM98562 + 1, iM9856);
                    C6635.m9823((Object) strSubstring3, "(this as java.lang.Strin…ing(startIndex, endIndex)");
                    arrayList.add(strSubstring3);
                }
                i = iM9856 + 1;
            }
            return arrayList;
        }
    }

    public C6908(String str, String str2, String str3, String str4, int i, List<String> list, List<String> list2, String str5, String str6) {
        if (str == null) {
            C6635.m9824("scheme");
            throw null;
        }
        if (str2 == null) {
            C6635.m9824("username");
            throw null;
        }
        if (str3 == null) {
            C6635.m9824("password");
            throw null;
        }
        if (str4 == null) {
            C6635.m9824("host");
            throw null;
        }
        if (list == null) {
            C6635.m9824("pathSegments");
            throw null;
        }
        if (str6 == null) {
            C6635.m9824("url");
            throw null;
        }
        this.f20014 = str;
        this.f20015 = str2;
        this.f20016 = str3;
        this.f20017 = str4;
        this.f20018 = i;
        this.f20019 = list;
        this.f20020 = list2;
        this.f20021 = str5;
        this.f20022 = str6;
        this.f20013 = C6635.m9825((Object) str, (Object) "https");
    }

    public boolean equals(Object obj) {
        return (obj instanceof C6908) && C6635.m9825((Object) ((C6908) obj).f20022, (Object) this.f20022);
    }

    public int hashCode() {
        return this.f20022.hashCode();
    }

    public String toString() {
        return this.f20022;
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final String m10079() {
        if (this.f20016.length() == 0) {
            return "";
        }
        int iM9856 = C6703.m9856((CharSequence) this.f20022, ':', this.f20014.length() + 3, false, 4) + 1;
        int iM98562 = C6703.m9856((CharSequence) this.f20022, '@', 0, false, 6);
        String str = this.f20022;
        if (str == null) {
            throw new TypeCastException("null cannot be cast to non-null type java.lang.String");
        }
        String strSubstring = str.substring(iM9856, iM98562);
        C6635.m9823((Object) strSubstring, "(this as java.lang.Strin…ing(startIndex, endIndex)");
        return strSubstring;
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final C6909 m10080(String str) {
        if (str == null) {
            C6635.m9824("link");
            throw null;
        }
        try {
            C6909 c6909 = new C6909();
            c6909.m10091(this, str);
            return c6909;
        } catch (IllegalArgumentException unused) {
            return null;
        }
    }

    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
    public final String m10081() {
        int iM9856 = C6703.m9856((CharSequence) this.f20022, '/', this.f20014.length() + 3, false, 4);
        String str = this.f20022;
        int iM10149 = C6943.m10149(str, "?#", iM9856, str.length());
        String str2 = this.f20022;
        if (str2 == null) {
            throw new TypeCastException("null cannot be cast to non-null type java.lang.String");
        }
        String strSubstring = str2.substring(iM9856, iM10149);
        C6635.m9823((Object) strSubstring, "(this as java.lang.Strin…ing(startIndex, endIndex)");
        return strSubstring;
    }

    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
    public final C6908 m10082(String str) {
        if (str == null) {
            C6635.m9824("link");
            throw null;
        }
        C6909 c6909M10080 = m10080(str);
        if (c6909M10080 != null) {
            return c6909M10080.m10092();
        }
        return null;
    }

    /* JADX INFO: renamed from: ހ, reason: contains not printable characters */
    public final List<String> m10083() {
        int iM9856 = C6703.m9856((CharSequence) this.f20022, '/', this.f20014.length() + 3, false, 4);
        String str = this.f20022;
        int iM10149 = C6943.m10149(str, "?#", iM9856, str.length());
        ArrayList arrayList = new ArrayList();
        while (iM9856 < iM10149) {
            int i = iM9856 + 1;
            int iM10143 = C6943.m10143(this.f20022, '/', i, iM10149);
            String str2 = this.f20022;
            if (str2 == null) {
                throw new TypeCastException("null cannot be cast to non-null type java.lang.String");
            }
            String strSubstring = str2.substring(i, iM10143);
            C6635.m9823((Object) strSubstring, "(this as java.lang.Strin…ing(startIndex, endIndex)");
            arrayList.add(strSubstring);
            iM9856 = iM10143;
        }
        return arrayList;
    }

    /* JADX INFO: renamed from: ށ, reason: contains not printable characters */
    public final String m10084() {
        if (this.f20020 == null) {
            return null;
        }
        int iM9856 = C6703.m9856((CharSequence) this.f20022, '?', 0, false, 6) + 1;
        String str = this.f20022;
        int iM10143 = C6943.m10143(str, '#', iM9856, str.length());
        String str2 = this.f20022;
        if (str2 == null) {
            throw new TypeCastException("null cannot be cast to non-null type java.lang.String");
        }
        String strSubstring = str2.substring(iM9856, iM10143);
        C6635.m9823((Object) strSubstring, "(this as java.lang.Strin…ing(startIndex, endIndex)");
        return strSubstring;
    }

    /* JADX INFO: renamed from: ނ, reason: contains not printable characters */
    public final String m10085() {
        if (this.f20015.length() == 0) {
            return "";
        }
        int length = this.f20014.length() + 3;
        String str = this.f20022;
        int iM10149 = C6943.m10149(str, ":@", length, str.length());
        String str2 = this.f20022;
        if (str2 == null) {
            throw new TypeCastException("null cannot be cast to non-null type java.lang.String");
        }
        String strSubstring = str2.substring(length, iM10149);
        C6635.m9823((Object) strSubstring, "(this as java.lang.Strin…ing(startIndex, endIndex)");
        return strSubstring;
    }

    /* JADX INFO: renamed from: ރ, reason: contains not printable characters */
    public final C6909 m10086() {
        C6909 c6909 = new C6909();
        c6909.f20024 = this.f20014;
        String strM10085 = m10085();
        String strSubstring = null;
        if (strM10085 == null) {
            C6635.m9824("<set-?>");
            throw null;
        }
        c6909.f20025 = strM10085;
        String strM10079 = m10079();
        if (strM10079 == null) {
            C6635.m9824("<set-?>");
            throw null;
        }
        c6909.f20026 = strM10079;
        c6909.f20027 = this.f20017;
        c6909.f20028 = this.f20018 != f20012.m10096(this.f20014) ? this.f20018 : -1;
        c6909.f20029.clear();
        c6909.f20029.addAll(m10083());
        c6909.m10089(m10084());
        if (this.f20021 != null) {
            int iM9856 = C6703.m9856((CharSequence) this.f20022, '#', 0, false, 6) + 1;
            String str = this.f20022;
            if (str == null) {
                throw new TypeCastException("null cannot be cast to non-null type java.lang.String");
            }
            strSubstring = str.substring(iM9856);
            C6635.m9823((Object) strSubstring, "(this as java.lang.String).substring(startIndex)");
        }
        c6909.f20031 = strSubstring;
        return c6909;
    }

    /* JADX INFO: renamed from: ބ, reason: contains not printable characters */
    public final String m10087() {
        C6909 c6909M10080 = m10080("/...");
        if (c6909M10080 == null) {
            C6635.m9822();
            throw null;
        }
        if (c6909M10080 == null) {
            throw null;
        }
        c6909M10080.f20025 = C6911.m10094(f20012, "", 0, 0, " \"':;<=>@[]^`{}|/\\?#", false, false, false, false, null, 251);
        c6909M10080.f20026 = C6911.m10094(f20012, "", 0, 0, " \"':;<=>@[]^`{}|/\\?#", false, false, false, false, null, 251);
        return c6909M10080.m10092().f20022;
    }

    /* JADX INFO: renamed from: ޅ, reason: contains not printable characters */
    public final URI m10088() {
        C6909 c6909M10086 = m10086();
        String str = c6909M10086.f20027;
        c6909M10086.f20027 = str != null ? new C6695("[\"<>^`{|}]").m9853(str, "") : null;
        int size = c6909M10086.f20029.size();
        for (int i = 0; i < size; i++) {
            List<String> list = c6909M10086.f20029;
            list.set(i, C6911.m10094(f20012, list.get(i), 0, 0, "[]", true, true, false, false, null, 227));
        }
        List<String> list2 = c6909M10086.f20030;
        if (list2 != null) {
            int size2 = list2.size();
            for (int i2 = 0; i2 < size2; i2++) {
                String str2 = list2.get(i2);
                list2.set(i2, str2 != null ? C6911.m10094(f20012, str2, 0, 0, "\\^`{|}", true, true, true, false, null, 195) : null);
            }
        }
        String str3 = c6909M10086.f20031;
        c6909M10086.f20031 = str3 != null ? C6911.m10094(f20012, str3, 0, 0, " \"#<>\\^`{|}", true, true, false, true, null, 163) : null;
        String string = c6909M10086.toString();
        try {
            return new URI(string);
        } catch (URISyntaxException e) {
            try {
                URI uriCreate = URI.create(new C6695("[\\u0000-\\u001F\\u007F-\\u009F\\p{javaWhitespace}]").m9853(string, ""));
                C6635.m9823((Object) uriCreate, "URI.create(stripped)");
                return uriCreate;
            } catch (Exception unused) {
                throw new RuntimeException(e);
            }
        }
    }
}
