package defpackage;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InterruptedIOException;
import java.net.ProtocolException;
import java.net.Proxy;
import java.net.SocketException;
import java.net.SocketTimeoutException;
import java.security.cert.CertificateException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.regex.Pattern;
import javax.net.SocketFactory;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLHandshakeException;
import javax.net.ssl.SSLPeerUnverifiedException;
import javax.net.ssl.SSLSocketFactory;
import okhttp3.internal.http2.ConnectionShutdownException;

/* JADX INFO: renamed from: ᵾᵷ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes3.dex */
public final class C5468 implements InterfaceC4229 {

    /* JADX INFO: renamed from: ʽˈˋ, reason: contains not printable characters */
    public static final C5468 f20703 = new C5468(0);

    /* JADX INFO: renamed from: ːˏᵟᵯ, reason: contains not printable characters */
    public static final C5468 f20704 = new C5468(1);

    /* JADX INFO: renamed from: ᵷᵺʾᵖ, reason: contains not printable characters */
    public static final C5468 f20705 = new C5468(2);

    /* JADX INFO: renamed from: ᵲᵶᵳˈ, reason: contains not printable characters */
    public final /* synthetic */ int f20706;

    public /* synthetic */ C5468(int i) {
        this.f20706 = i;
    }

    /* JADX WARN: Removed duplicated region for block: B:74:0x00d2  */
    /* JADX INFO: renamed from: ʽˈˋ, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public static C4402 m11090(C1120 c1120, C0764 c0764, C2729 c2729) throws ProtocolException {
        C5096 c5096;
        AbstractC0782 abstractC0782;
        C1120 c11202;
        C0158 c0158 = c0764 != null ? c0764.m2751().f15413 : null;
        int i = c1120.f4790;
        C4402 c4402 = c1120.f4784;
        String str = c4402.f16705;
        if (i == 307 || i == 308) {
            if (c2729.f10493.f18174.f13187) {
                String strM2425 = c1120.f4792.m2425("Location");
                if (strM2425 == null) {
                    strM2425 = null;
                }
                C4402 c44022 = c1120.f4784;
                if (strM2425 != null) {
                    C1695 c1695 = c44022.f16708;
                    c1695.getClass();
                    try {
                        c5096 = new C5096(2);
                        c5096.m10582(c1695, strM2425);
                    } catch (IllegalArgumentException unused) {
                        c5096 = null;
                    }
                    C1695 c1695M10583 = c5096 != null ? c5096.m10583() : null;
                    if (c1695M10583 != null && (ᵥˈᵛ.ˊᵫᵗ(c1695M10583.f6698, c44022.f16708.f6698) || c2729.f10493.f18174.f13208)) {
                        ᵕˁـ r13 = c44022.m9412();
                        if (ᵘᵞʿⁱ.ˌᵨʠᵫ(str)) {
                            int i2 = c1120.f4790;
                            boolean z = str.equals("PROPFIND") || i2 == 308 || i2 == 307;
                            if (str.equals("PROPFIND") || i2 == 308 || i2 == 307) {
                                r13.ˉᵲ(str, z ? c44022.f16709 : null);
                            } else {
                                r13.ˉᵲ("GET", (AbstractC0782) null);
                            }
                            if (!z) {
                                r13.ˏːˆ("Transfer-Encoding");
                                r13.ˏːˆ("Content-Length");
                                r13.ˏːˆ("Content-Type");
                            }
                        }
                        if (!AbstractC1190.m3669(c44022.f16708, c1695M10583)) {
                            r13.ˏːˆ("Authorization");
                        }
                        r13.ᵜᵪʾ = c1695M10583;
                        return new C4402(r13);
                    }
                }
            }
        } else {
            if (i == 401) {
                c2729.f10497.getClass();
                return null;
            }
            if (i == 421) {
                AbstractC0782 abstractC07822 = c4402.f16709;
                if ((abstractC07822 == null || !abstractC07822.mo2796()) && c0764 != null && !ᵥˈᵛ.ˊᵫᵗ(((InterfaceC2274) c0764.f3427).mo5888().f1845.f1327.f6700, ((InterfaceC0340) c0764.f3429).mo1604().mo8821().f1565.f1327.f6700)) {
                    C4013 c4013M2751 = c0764.m2751();
                    synchronized (c4013M2751) {
                        c4013M2751.f15422 = true;
                    }
                    return c1120.f4784;
                }
            } else if (i == 503) {
                C1120 c11203 = c1120.f4777;
                if ((c11203 == null || c11203.f4790 != 503) && m11092(c1120, Integer.MAX_VALUE) == 0) {
                    return c1120.f4784;
                }
            } else {
                if (i == 407) {
                    if (c0158.f1563.type() != Proxy.Type.HTTP) {
                        throw new ProtocolException("Received HTTP_PROXY_AUTH (407) code while not using proxy");
                    }
                    c2729.f10489.getClass();
                    return null;
                }
                if (i != 408) {
                    switch (i) {
                        case 300:
                        case 301:
                        case 302:
                        case 303:
                        default:
                            return null;
                    }
                } else if (c2729.f10491 && (((abstractC0782 = c4402.f16709) == null || !abstractC0782.mo2796()) && (((c11202 = c1120.f4777) == null || c11202.f4790 != 408) && m11092(c1120, 0) <= 0))) {
                    return c1120.f4784;
                }
            }
        }
        return null;
    }

    /* JADX INFO: renamed from: ːˏᵟᵯ, reason: contains not printable characters */
    private final C1120 m11091(C2729 c2729) throws SocketException {
        Object c2376;
        C4778 c4778 = c2729.f10493;
        synchronized (c4778) {
            if (!c4778.f18173) {
                throw new IllegalStateException("released");
            }
            if (c4778.f18171 || c4778.f18180 || c4778.f18168 || c4778.f18169) {
                throw new IllegalStateException("Check failed.");
            }
        }
        InterfaceC2274 interfaceC2274 = c4778.f18175;
        C4013 c4013Mo5887 = interfaceC2274.mo5887();
        C3423 c3423 = c4778.f18174;
        int i = c2729.f10494;
        ᵣˊˈᵪ r4 = c4013Mo5887.f15411;
        C4901 c4901 = c4013Mo5887.f15424;
        if (c4901 != null) {
            c2376 = new C0458(c3423, c4013Mo5887, c2729, c4901);
        } else {
            c4013Mo5887.f15416.setSoTimeout(i);
            ((C1978) r4.ᵔᵖᵹᵫ).f7847.mo1491().mo3055(i);
            ((C0584) r4.ᵨᵼⁱ).f2858.mo1844().mo3055(c2729.f10481);
            c2376 = new C2376(c3423, c4013Mo5887, r4);
        }
        C0764 c0764 = new C0764(c4778, interfaceC2274, c2376);
        c4778.f18167 = c0764;
        c4778.f18178 = c0764;
        synchronized (c4778) {
            c4778.f18180 = true;
            c4778.f18171 = true;
        }
        if (!c4778.f18172) {
            return C2729.m6628(c2729, 0, c0764, null, 2097149).m6629(c2729.f10488);
        }
        C1685.m4568("Canceled");
        return null;
    }

    /* JADX INFO: renamed from: ᵨᵣ, reason: contains not printable characters */
    public static int m11092(C1120 c1120, int i) {
        String strM2425 = c1120.f4792.m2425("Retry-After");
        if (strM2425 == null) {
            strM2425 = null;
        }
        if (strM2425 == null) {
            return i;
        }
        if (Pattern.compile("\\d+").matcher(strM2425).matches()) {
            return Integer.valueOf(strM2425).intValue();
        }
        return Integer.MAX_VALUE;
    }

    /* JADX INFO: renamed from: ᵷᵺʾᵖ, reason: contains not printable characters */
    public static boolean m11093(IOException iOException, C4778 c4778, C2729 c2729, C4402 c4402) {
        AbstractC0782 abstractC0782;
        boolean z = iOException instanceof ConnectionShutdownException;
        if (!c2729.f10491) {
            return false;
        }
        if ((!z && (((abstractC0782 = c4402.f16709) != null && abstractC0782.mo2796()) || (iOException instanceof FileNotFoundException))) || (iOException instanceof ProtocolException)) {
            return false;
        }
        if (iOException instanceof InterruptedIOException) {
            if (!(iOException instanceof SocketTimeoutException) || !z) {
                return false;
            }
        } else if (((iOException instanceof SSLHandshakeException) && (iOException.getCause() instanceof CertificateException)) || (iOException instanceof SSLPeerUnverifiedException)) {
            return false;
        }
        C0764 c0764 = c4778.f18178;
        if (c0764 == null || !c0764.f3426) {
            return false;
        }
        C0252 c0252Mo5888 = c4778.f18175.mo5888();
        C0764 c07642 = c4778.f18178;
        return c0252Mo5888.m1468(c07642 != null ? c07642.m2751() : null);
    }

    /* JADX WARN: Code restructure failed: missing block: B:397:?, code lost:
    
        return r0;
     */
    /* JADX WARN: Code restructure failed: missing block: B:42:0x00f2, code lost:
    
        r2.m9963(r1);
     */
    /* JADX WARN: Code restructure failed: missing block: B:75:0x0185, code lost:
    
        throw new java.lang.IllegalStateException("Check failed.");
     */
    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Removed duplicated region for block: B:271:0x05f3  */
    /* JADX WARN: Removed duplicated region for block: B:275:0x05fc  */
    /* JADX WARN: Removed duplicated region for block: B:292:0x063f A[Catch: IOException -> 0x060f, TryCatch #3 {IOException -> 0x060f, blocks: (B:276:0x05fd, B:278:0x0603, B:281:0x0612, B:290:0x0639, B:292:0x063f, B:293:0x0648, B:294:0x0661, B:299:0x0674, B:305:0x0682, B:306:0x0689, B:308:0x068c, B:311:0x0696, B:317:0x06a2, B:319:0x06db, B:321:0x06e9, B:324:0x06f3, B:331:0x070c, B:334:0x0719, B:335:0x073d, B:326:0x06f9, B:318:0x06c4), top: B:348:0x05fd }] */
    /* JADX WARN: Removed duplicated region for block: B:296:0x066f  */
    /* JADX WARN: Removed duplicated region for block: B:297:0x0671  */
    /* JADX WARN: Removed duplicated region for block: B:299:0x0674 A[Catch: IOException -> 0x060f, TryCatch #3 {IOException -> 0x060f, blocks: (B:276:0x05fd, B:278:0x0603, B:281:0x0612, B:290:0x0639, B:292:0x063f, B:293:0x0648, B:294:0x0661, B:299:0x0674, B:305:0x0682, B:306:0x0689, B:308:0x068c, B:311:0x0696, B:317:0x06a2, B:319:0x06db, B:321:0x06e9, B:324:0x06f3, B:331:0x070c, B:334:0x0719, B:335:0x073d, B:326:0x06f9, B:318:0x06c4), top: B:348:0x05fd }] */
    /* JADX WARN: Removed duplicated region for block: B:308:0x068c A[Catch: IOException -> 0x060f, TryCatch #3 {IOException -> 0x060f, blocks: (B:276:0x05fd, B:278:0x0603, B:281:0x0612, B:290:0x0639, B:292:0x063f, B:293:0x0648, B:294:0x0661, B:299:0x0674, B:305:0x0682, B:306:0x0689, B:308:0x068c, B:311:0x0696, B:317:0x06a2, B:319:0x06db, B:321:0x06e9, B:324:0x06f3, B:331:0x070c, B:334:0x0719, B:335:0x073d, B:326:0x06f9, B:318:0x06c4), top: B:348:0x05fd }] */
    /* JADX WARN: Removed duplicated region for block: B:314:0x069d  */
    /* JADX WARN: Removed duplicated region for block: B:318:0x06c4 A[Catch: IOException -> 0x060f, TryCatch #3 {IOException -> 0x060f, blocks: (B:276:0x05fd, B:278:0x0603, B:281:0x0612, B:290:0x0639, B:292:0x063f, B:293:0x0648, B:294:0x0661, B:299:0x0674, B:305:0x0682, B:306:0x0689, B:308:0x068c, B:311:0x0696, B:317:0x06a2, B:319:0x06db, B:321:0x06e9, B:324:0x06f3, B:331:0x070c, B:334:0x0719, B:335:0x073d, B:326:0x06f9, B:318:0x06c4), top: B:348:0x05fd }] */
    /* JADX WARN: Removed duplicated region for block: B:321:0x06e9 A[Catch: IOException -> 0x060f, TryCatch #3 {IOException -> 0x060f, blocks: (B:276:0x05fd, B:278:0x0603, B:281:0x0612, B:290:0x0639, B:292:0x063f, B:293:0x0648, B:294:0x0661, B:299:0x0674, B:305:0x0682, B:306:0x0689, B:308:0x068c, B:311:0x0696, B:317:0x06a2, B:319:0x06db, B:321:0x06e9, B:324:0x06f3, B:331:0x070c, B:334:0x0719, B:335:0x073d, B:326:0x06f9, B:318:0x06c4), top: B:348:0x05fd }] */
    /* JADX WARN: Removed duplicated region for block: B:326:0x06f9 A[Catch: IOException -> 0x060f, TryCatch #3 {IOException -> 0x060f, blocks: (B:276:0x05fd, B:278:0x0603, B:281:0x0612, B:290:0x0639, B:292:0x063f, B:293:0x0648, B:294:0x0661, B:299:0x0674, B:305:0x0682, B:306:0x0689, B:308:0x068c, B:311:0x0696, B:317:0x06a2, B:319:0x06db, B:321:0x06e9, B:324:0x06f3, B:331:0x070c, B:334:0x0719, B:335:0x073d, B:326:0x06f9, B:318:0x06c4), top: B:348:0x05fd }] */
    /* JADX WARN: Removed duplicated region for block: B:341:0x0746 A[ADDED_TO_REGION, REMOVE] */
    /* JADX WARN: Removed duplicated region for block: B:396:0x0648 A[SYNTHETIC] */
    /* JADX WARN: Type inference failed for: r4v14, types: [ᵵᵾʝ] */
    /* JADX WARN: Type inference failed for: r5v13 */
    /* JADX WARN: Type inference failed for: r5v14, types: [ˁᵵ] */
    /* JADX WARN: Type inference failed for: r5v17 */
    /* JADX WARN: Type inference failed for: r5v23 */
    /* JADX WARN: Type inference failed for: r5v27 */
    /* JADX WARN: Type inference failed for: r5v28 */
    /* JADX WARN: Type inference failed for: r5v29 */
    /* JADX WARN: Type inference failed for: r5v3 */
    /* JADX WARN: Type inference failed for: r5v36, types: [ˁᵵ] */
    /* JADX WARN: Type inference failed for: r5v37 */
    /* JADX WARN: Type inference failed for: r5v38, types: [ˁᵵ] */
    /* JADX WARN: Type inference failed for: r5v39 */
    /* JADX WARN: Type inference failed for: r5v4 */
    /* JADX WARN: Type inference failed for: r5v5 */
    /* JADX WARN: Type inference failed for: r5v6 */
    /* JADX WARN: Type inference failed for: r5v69 */
    /* JADX WARN: Type inference failed for: r5v7 */
    /* JADX WARN: Type inference failed for: r5v70 */
    /* JADX WARN: Type inference failed for: r5v71 */
    /* JADX WARN: Type inference failed for: r5v72 */
    /* JADX WARN: Type inference failed for: r5v73 */
    /* JADX WARN: Type inference failed for: r5v74 */
    /* JADX WARN: Type inference failed for: r5v75 */
    /* JADX WARN: Type inference failed for: r5v76 */
    /* JADX WARN: Type inference failed for: r5v77 */
    /* JADX WARN: Type inference failed for: r5v78 */
    /* JADX WARN: Type inference failed for: r5v79 */
    /* JADX WARN: Type inference failed for: r5v8, types: [ˁᵵ] */
    /* JADX WARN: Type inference failed for: r5v9, types: [ˁᵵ] */
    @Override // defpackage.InterfaceC4229
    /* JADX INFO: renamed from: ᵲᵶᵳˈ */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final C1120 mo9201(C2729 c2729) throws Throwable {
        boolean z;
        IOException iOException;
        ?? r5;
        boolean z2;
        C2651 c2651;
        ?? r52;
        IOException iOException2;
        C2651 c2651M2752;
        ?? r53;
        C1120 c1120M6424;
        int i;
        boolean z3;
        C1120 c1120M64242;
        ?? r54;
        IOException e;
        ?? r55;
        C2651 c2651M27522;
        ?? r56;
        boolean z4;
        String str;
        C0661 c0661;
        List list;
        boolean z5;
        boolean z6;
        SSLSocketFactory sSLSocketFactory;
        HostnameVerifier hostnameVerifier;
        C2711 c2711;
        switch (this.f20706) {
            case 0:
                C0764 c0764 = c2729.f10496;
                C4402 c4402 = c2729.f10488;
                AbstractC0782 abstractC0782 = c4402.f16709;
                long jCurrentTimeMillis = System.currentTimeMillis();
                ?? r57 = (!ᵘᵞʿⁱ.ˌᵨʠᵫ(c4402.f16705) || abstractC0782 == null) ? 0 : 1;
                boolean zEqualsIgnoreCase = "upgrade".equalsIgnoreCase(c4402.f16706.m2425("Connection"));
                try {
                    c0764.getClass();
                } catch (IOException e2) {
                    e = e2;
                    r57 = c0764;
                    z = true;
                }
                try {
                    try {
                        ((C4778) c0764.f3428).f18181.getClass();
                        ((InterfaceC0340) c0764.f3429).mo1600(c4402);
                        ((C4778) c0764.f3428).f18181.getClass();
                        if (r57 != 0) {
                            boolean zEqualsIgnoreCase2 = "100-continue".equalsIgnoreCase(c4402.f16706.m2425("Expect"));
                            if (zEqualsIgnoreCase2) {
                                try {
                                    try {
                                        ((InterfaceC0340) c0764.f3429).mo1602();
                                        z = true;
                                        c2651M27522 = c0764.m2752(true);
                                    } catch (IOException e3) {
                                        ((C4778) c0764.f3428).f18181.getClass();
                                        c0764.m2750(e3);
                                        throw e3;
                                    }
                                } catch (IOException e4) {
                                    iOException = e4;
                                    r5 = c0764;
                                    z2 = true;
                                    c2651 = null;
                                    r52 = r5;
                                    if (iOException instanceof ConnectionShutdownException) {
                                        throw iOException;
                                    }
                                    throw iOException;
                                }
                                try {
                                    AbstractC0396 abstractC0396 = ((C4778) c0764.f3428).f18181;
                                    abstractC0396.getClass();
                                    c2651 = c2651M27522;
                                    z2 = false;
                                    r56 = abstractC0396;
                                } catch (IOException e5) {
                                    e = e5;
                                    r54 = c0764;
                                    c2651 = c2651M27522;
                                    z2 = true;
                                    iOException = e;
                                    r52 = r54;
                                    if (iOException instanceof ConnectionShutdownException) {
                                    }
                                }
                            } else {
                                z = true;
                                z2 = true;
                                c2651 = null;
                                r56 = zEqualsIgnoreCase2;
                            }
                            try {
                                if (c2651 == null) {
                                    try {
                                        abstractC0782.getClass();
                                        long jMo2797 = c4402.f16709.mo2797();
                                        ((C4778) c0764.f3428).f18181.getClass();
                                        r56 = c0764;
                                        C0584 c0584 = new C0584(new C1769(r56, ((InterfaceC0340) c0764.f3429).mo1601(c4402, jMo2797), jMo2797, false));
                                        abstractC0782.mo2798(c0584);
                                        c0584.close();
                                    } catch (IOException e6) {
                                        e = e6;
                                        r54 = c0764;
                                        iOException = e;
                                        r52 = r54;
                                        if (iOException instanceof ConnectionShutdownException) {
                                        }
                                    }
                                } else {
                                    r56 = c0764;
                                    ((C4778) r56.f3428).m9966(r56, true, false, false, false, null);
                                    if (!(r56.m2751().f15424 != null ? z : false)) {
                                        ((InterfaceC0340) r56.f3429).mo1604().mo8822();
                                    }
                                }
                                c2651M2752 = c2651;
                                r55 = r56;
                            } catch (IOException e7) {
                                e = e7;
                                r54 = r56;
                            }
                        } else {
                            C0764 c07642 = c0764;
                            z = true;
                            ((C4778) c07642.f3428).m9966(c07642, true, false, false, false, null);
                            z2 = true;
                            c2651M2752 = null;
                            r55 = c07642;
                        }
                        try {
                            ((InterfaceC0340) r55.f3429).mo1598();
                            iOException2 = null;
                            r53 = r55;
                        } catch (IOException e8) {
                            try {
                                ((C4778) r55.f3428).f18181.getClass();
                                r55.m2750(e8);
                                throw e8;
                            } catch (IOException e9) {
                                e = e9;
                                c2651 = c2651M2752;
                                r54 = r55;
                                iOException = e;
                                r52 = r54;
                                if ((iOException instanceof ConnectionShutdownException) || !r52.f3426) {
                                    throw iOException;
                                }
                                iOException2 = iOException;
                                c2651M2752 = c2651;
                                r53 = r52;
                                if (c2651M2752 == null) {
                                }
                                c2651M2752.f10278 = c4402;
                                c2651M2752.f10274 = r53.m2751().f15425;
                                c2651M2752.f10276 = jCurrentTimeMillis;
                                c2651M2752.f10273 = System.currentTimeMillis();
                                c1120M6424 = c2651M2752.m6424();
                                i = c1120M6424.f4790;
                                while (true) {
                                    if (i != 100) {
                                        ((C4778) r53.f3428).f18181.getClass();
                                        if (i != 101) {
                                        }
                                        if (z3) {
                                        }
                                        if (z3) {
                                        }
                                        if (zEqualsIgnoreCase) {
                                            C4891 c4891M2741 = r53.m2741(c1120M6424);
                                            C2651 c2651M3613 = c1120M6424.m3613();
                                            c2651M3613.f10279 = c4891M2741;
                                            c2651M3613.f10275 = new ˉᵠﹳᵘ(14);
                                            c1120M64242 = c2651M3613.m6424();
                                        }
                                        if ("close".equalsIgnoreCase(c1120M64242.f4784.f16706.m2425("Connection"))) {
                                        }
                                        if (i == 204) {
                                            throw new ProtocolException("HTTP " + i + " had non-zero Content-Length: " + c1120M64242.f4780.mo2195());
                                        }
                                        throw new ProtocolException("HTTP " + i + " had non-zero Content-Length: " + c1120M64242.f4780.mo2195());
                                        return c1120M64242;
                                    }
                                    C2651 c2651M27523 = r53.m2752(false);
                                    if (!z2) {
                                    }
                                    c2651M27523.f10278 = c4402;
                                    c2651M27523.f10274 = r53.m2751().f15425;
                                    c2651M27523.f10276 = jCurrentTimeMillis;
                                    c2651M27523.f10273 = System.currentTimeMillis();
                                    c1120M6424 = c2651M27523.m6424();
                                    i = c1120M6424.f4790;
                                }
                            }
                        }
                    } catch (IOException e10) {
                        ((C4778) c0764.f3428).f18181.getClass();
                        c0764.m2750(e10);
                        throw e10;
                    }
                    break;
                } catch (IOException e11) {
                    e = e11;
                    iOException = e;
                    r5 = r57;
                    z2 = true;
                    c2651 = null;
                    r52 = r5;
                    if (iOException instanceof ConnectionShutdownException) {
                    }
                }
                if (c2651M2752 == null) {
                    try {
                        c2651M2752 = r53.m2752(false);
                        if (z2) {
                            ((C4778) r53.f3428).f18181.getClass();
                            z2 = false;
                        }
                    } catch (IOException e12) {
                        if (iOException2 == null) {
                            throw e12;
                        }
                        ᵷˆᵣ.ʽˈˋ(iOException2, e12);
                        throw iOException2;
                    }
                }
                c2651M2752.f10278 = c4402;
                c2651M2752.f10274 = r53.m2751().f15425;
                c2651M2752.f10276 = jCurrentTimeMillis;
                c2651M2752.f10273 = System.currentTimeMillis();
                c1120M6424 = c2651M2752.m6424();
                i = c1120M6424.f4790;
                while (true) {
                    if (i != 100 && (102 > i || i >= 200)) {
                    }
                    C2651 c2651M275232 = r53.m2752(false);
                    if (!z2) {
                        ((C4778) r53.f3428).f18181.getClass();
                    }
                    c2651M275232.f10278 = c4402;
                    c2651M275232.f10274 = r53.m2751().f15425;
                    c2651M275232.f10276 = jCurrentTimeMillis;
                    c2651M275232.f10273 = System.currentTimeMillis();
                    c1120M6424 = c2651M275232.m6424();
                    i = c1120M6424.f4790;
                }
                ((C4778) r53.f3428).f18181.getClass();
                z3 = i != 101 ? z : false;
                if (z3) {
                    if (r53.m2751().f15424 != null ? z : false) {
                        throw new ProtocolException("Unexpected 101 code on HTTP/2 connection");
                    }
                }
                if (z3) {
                    String strM2425 = c1120M6424.f4792.m2425("Connection");
                    if (strM2425 == null) {
                        strM2425 = null;
                    }
                    if ("upgrade".equalsIgnoreCase(strM2425)) {
                    }
                } else {
                    z = false;
                }
                if (zEqualsIgnoreCase || !z) {
                    C4891 c4891M27412 = r53.m2741(c1120M6424);
                    C2651 c2651M36132 = c1120M6424.m3613();
                    c2651M36132.f10279 = c4891M27412;
                    c2651M36132.f10275 = new ˉᵠﹳᵘ(14);
                    c1120M64242 = c2651M36132.m6424();
                } else {
                    C2651 c2651M36133 = c1120M6424.m3613();
                    c2651M36133.f10279 = new C0574(c1120M6424.f4780.mo2193(), c1120M6424.f4780.mo2195());
                    c2651M36133.f10270 = r53.m2746();
                    c1120M64242 = c2651M36133.m6424();
                }
                if ("close".equalsIgnoreCase(c1120M64242.f4784.f16706.m2425("Connection"))) {
                    ((InterfaceC0340) r53.f3429).mo1604().mo8822();
                } else {
                    String strM24252 = c1120M64242.f4792.m2425("Connection");
                    if (strM24252 == null) {
                        strM24252 = null;
                    }
                    if ("close".equalsIgnoreCase(strM24252)) {
                    }
                }
                if ((i == 204 && i != 205) || c1120M64242.f4780.mo2195() <= 0) {
                    return c1120M64242;
                }
                throw new ProtocolException("HTTP " + i + " had non-zero Content-Length: " + c1120M64242.f4780.mo2195());
            case 1:
                return m11091(c2729);
            case 2:
                try {
                    return c2729.m6629(c2729.f10488);
                } catch (IOException e13) {
                    throw e13;
                } catch (Exception e14) {
                    ᵕᵛ.ᵧᵠᵾ(e14);
                    throw new IOException("OkHttp internal failure: ".concat(e14.getClass().getSimpleName()), e14);
                }
            case 3:
                InterfaceC2605 interfaceC2605 = c2729.f10490;
                C4402 c44022 = c2729.f10488;
                ᵕˁـ r12 = c44022.m9412();
                C1695 c1695 = c44022.f16708;
                C0661 c06612 = c44022.f16706;
                AbstractC0782 abstractC07822 = c44022.f16709;
                if (abstractC07822 != null) {
                    C4738 c4738Mo2795 = abstractC07822.mo2795();
                    if (c4738Mo2795 != null) {
                        r12.ᵱʡˏ("Content-Type", c4738Mo2795.f18014);
                    }
                    long jMo27972 = abstractC07822.mo2797();
                    if (jMo27972 != -1) {
                        r12.ᵱʡˏ("Content-Length", String.valueOf(jMo27972));
                        r12.ˏːˆ("Transfer-Encoding");
                    } else {
                        r12.ᵱʡˏ("Transfer-Encoding", "chunked");
                        r12.ˏːˆ("Content-Length");
                    }
                }
                if (c06612.m2425("Host") == null) {
                    r12.ᵱʡˏ("Host", AbstractC1190.m3665(c1695, false));
                }
                if (c06612.m2425("Connection") == null) {
                    r12.ᵱʡˏ("Connection", "Keep-Alive");
                }
                if (c06612.m2425("Accept-Encoding") == null && c06612.m2425("Range") == null) {
                    r12.ᵱʡˏ("Accept-Encoding", "gzip");
                    z4 = true;
                } else {
                    z4 = false;
                }
                List listM6324 = interfaceC2605.m6324(c1695);
                if (listM6324.isEmpty()) {
                    str = null;
                } else {
                    StringBuilder sb = new StringBuilder();
                    int i2 = 0;
                    for (Object obj : listM6324) {
                        int i3 = i2 + 1;
                        if (i2 < 0) {
                            AbstractC0892.m3124();
                            throw null;
                        }
                        C0939 c0939 = (C0939) obj;
                        if (i2 > 0) {
                            sb.append("; ");
                        }
                        sb.append(c0939.f4099);
                        sb.append('=');
                        sb.append(c0939.f4094);
                        i2 = i3;
                    }
                    str = null;
                    r12.ᵱʡˏ("Cookie", sb.toString());
                }
                if (c06612.m2425("User-Agent") == null) {
                    r12.ᵱʡˏ("User-Agent", "okhttp/5.4.0");
                }
                C4402 c44023 = new C4402(r12);
                C1120 c1120M6629 = c2729.m6629(c44023);
                C0661 c06613 = c1120M6629.f4792;
                AbstractC1384.m3960(interfaceC2605, c44023.f16708, c06613);
                C2651 c2651M36134 = c1120M6629.m3613();
                c2651M36134.f10278 = c44023;
                if (z4) {
                    String strM24253 = c06613.m2425("Content-Encoding");
                    if (strM24253 == null) {
                        strM24253 = str;
                    }
                    if ("gzip".equalsIgnoreCase(strM24253) && AbstractC1384.m3961(c1120M6629)) {
                        C3179 c3179 = new C3179(c1120M6629.f4780.mo2194());
                        C4759 c4759M2428 = c06613.m2428();
                        c4759M2428.m9940("Content-Encoding");
                        c4759M2428.m9940("Content-Length");
                        c2651M36134.f10283 = c4759M2428.m9936().m2428();
                        String strM24254 = c06613.m2425("Content-Type");
                        c2651M36134.f10279 = new C4891(strM24254 == null ? str : strM24254, -1L, new C1978(c3179));
                    }
                }
                return c2651M36134.m6424();
            case 4:
                System.currentTimeMillis();
                C4402 c44024 = c2729.f10488;
                int i4 = 11;
                C0767 c0767 = new C0767(i4, c44024, null, false);
                C3405 c3405 = c44024.f16710;
                if (c3405 == null) {
                    int i5 = C3405.f13109;
                    c3405 = ˑᵕʾ.ᵯᵷʽ(c44024.f16706);
                    c44024.f16710 = c3405;
                }
                if (c3405.f13116) {
                    Object obj2 = null;
                    c0767 = new C0767(i4, obj2, obj2, false);
                }
                C4402 c44025 = (C4402) c0767.f3433;
                C1120 c1120 = (C1120) c0767.f3432;
                if (c44025 == null && c1120 == null) {
                    C1120 c11202 = new C1120(c2729.f10488, EnumC0876.f3876, "Unsatisfiable Request (only-if-cached)", 504, null, new C0661((String[]) new ArrayList(20).toArray(new String[0])), AbstractC4407.f16717, null, null, null, null, -1L, System.currentTimeMillis(), null, InterfaceC0194.f1648);
                    c2729.f10493.f18181.getClass();
                    return c11202;
                }
                if (c44025 == null) {
                    C2651 c2651M36135 = c1120.m3613();
                    C1120 c11203 = ᵷᵸˁ.ᵸˆˁ(c1120);
                    C2651.m6423("cacheResponse", c11203);
                    c2651M36135.f10277 = c11203;
                    C1120 c1120M64243 = c2651M36135.m6424();
                    c2729.f10493.f18181.getClass();
                    return c1120M64243;
                }
                if (c1120 != null) {
                    c2729.f10493.f18181.getClass();
                }
                C1120 c1120M66292 = c2729.m6629(c44025);
                if (c1120 != null) {
                    if (c1120M66292.f4790 == 304) {
                        C2651 c2651M36136 = c1120.m3613();
                        C0661 c06614 = c1120.f4792;
                        C0661 c06615 = c1120M66292.f4792;
                        ArrayList arrayList = new ArrayList(20);
                        int size = c06614.size();
                        int i6 = 0;
                        while (i6 < size) {
                            String strM2426 = c06614.m2426(i6);
                            String strM2429 = c06614.m2429(i6);
                            if ("Warning".equalsIgnoreCase(strM2426)) {
                                c0661 = c06614;
                                if (AbstractC5498.m11136(strM2429, "1", false)) {
                                }
                                i6++;
                                c06614 = c0661;
                            } else {
                                c0661 = c06614;
                            }
                            if ("Content-Length".equalsIgnoreCase(strM2426) || "Content-Encoding".equalsIgnoreCase(strM2426) || "Content-Type".equalsIgnoreCase(strM2426) || !ᵴᵧˈ.ˋˈ(strM2426) || c06615.m2425(strM2426) == null) {
                                arrayList.add(strM2426);
                                arrayList.add(AbstractC3801.m8464(strM2429).toString());
                            }
                            i6++;
                            c06614 = c0661;
                        }
                        int size2 = c06615.size();
                        for (int i7 = 0; i7 < size2; i7++) {
                            String strM24262 = c06615.m2426(i7);
                            if (!"Content-Length".equalsIgnoreCase(strM24262) && !"Content-Encoding".equalsIgnoreCase(strM24262) && !"Content-Type".equalsIgnoreCase(strM24262) && ᵴᵧˈ.ˋˈ(strM24262)) {
                                String strM24292 = c06615.m2429(i7);
                                arrayList.add(strM24262);
                                arrayList.add(AbstractC3801.m8464(strM24292).toString());
                            }
                        }
                        String[] strArr = (String[]) arrayList.toArray(new String[0]);
                        C4759 c4759 = new C4759();
                        c4759.f18134.addAll(Arrays.asList(strArr));
                        c2651M36136.f10283 = c4759;
                        c2651M36136.f10276 = c1120M66292.f4789;
                        c2651M36136.f10273 = c1120M66292.f4781;
                        C1120 c11204 = ᵷᵸˁ.ᵸˆˁ(c1120);
                        C2651.m6423("cacheResponse", c11204);
                        c2651M36136.f10277 = c11204;
                        C1120 c11205 = ᵷᵸˁ.ᵸˆˁ(c1120M66292);
                        C2651.m6423("networkResponse", c11205);
                        c2651M36136.f10282 = c11205;
                        c2651M36136.m6424();
                        c1120M66292.f4780.close();
                        throw null;
                    }
                    AbstractC1701.m4653(c1120.f4780);
                }
                C2651 c2651M36137 = c1120M66292.m3613();
                C1120 c11206 = c1120 != null ? ᵷᵸˁ.ᵸˆˁ(c1120) : null;
                C2651.m6423("cacheResponse", c11206);
                c2651M36137.f10277 = c11206;
                C1120 c11207 = ᵷᵸˁ.ᵸˆˁ(c1120M66292);
                C2651.m6423("networkResponse", c11207);
                c2651M36137.f10282 = c11207;
                return c2651M36137.m6424();
            default:
                C4402 c44026 = c2729.f10488;
                C4778 c4778 = c2729.f10493;
                List listM8997 = C2808.f10794;
                C1120 c11208 = null;
                int i8 = 0;
                C4402 c4402M11090 = c44026;
                while (true) {
                    boolean z7 = true;
                    while (c4778.f18167 == null) {
                        synchronized (c4778) {
                            if (c4778.f18171) {
                                throw new IllegalStateException("cannot make a new request because the previous response is still open: please call response.close()");
                            }
                            if (c4778.f18180 || c4778.f18168 || c4778.f18169) {
                                break;
                            }
                        }
                        if (z7) {
                            C3423 c3423 = c4778.f18174;
                            List list2 = listM8997;
                            C5377 c5377 = c3423.f13200;
                            C2736 c2736 = (C2736) c2729.f10495.ˌᴵ;
                            int i9 = c2729.f10494;
                            int i10 = c2729.f10481;
                            int i11 = c2729.f10498;
                            boolean z8 = c2729.f10491;
                            boolean z9 = c3423.f13209;
                            C1695 c16952 = c4402M11090.f16708;
                            if (ᵥˈᵛ.ˊᵫᵗ(c16952.f6698, "https")) {
                                sSLSocketFactory = c2729.f10478;
                                hostnameVerifier = c2729.f10482;
                                c2711 = c2729.f10492;
                            } else {
                                sSLSocketFactory = null;
                                hostnameVerifier = null;
                                c2711 = null;
                            }
                            String str2 = c16952.f6700;
                            int i12 = c16952.f6697;
                            C3814 c3814 = c2729.f10486;
                            SocketFactory socketFactory = c2729.f10479;
                            ᵠʽᵲ r0 = c2729.f10489;
                            C3423 c34232 = c2729.f10493.f18174;
                            list = list2;
                            C4402 c44027 = c4402M11090;
                            C0252 c0252 = new C0252(c5377, c2736, i9, i10, i11, i9, z8, z9, new C0095(str2, i12, c3814, socketFactory, sSLSocketFactory, hostnameVerifier, c2711, r0, c34232.f13185, c34232.f13201, c2729.f10487), c4778.f18174.f13197, c4778, c44027);
                            c4402M11090 = c44027;
                            C3423 c34233 = c4778.f18174;
                            c4778.f18175 = c34233.f13209 ? new C5227(c0252, c34233.f13200) : new ᵢʒʡᵟ(23, c0252);
                        } else {
                            list = listM8997;
                        }
                        try {
                            if (c4778.f18172) {
                                throw new IOException("Canceled");
                            }
                            try {
                                C2651 c2651M36138 = c2729.m6629(c4402M11090).m3613();
                                c2651M36138.f10278 = c4402M11090;
                                c2651M36138.f10280 = c11208 != null ? ᵷᵸˁ.ᵸˆˁ(c11208) : null;
                                C1120 c1120M64244 = c2651M36138.m6424();
                                c4402M11090 = m11090(c1120M64244, c4778.f18167, c2729);
                                try {
                                    if (c4402M11090 == null) {
                                        c4778.f18181.getClass();
                                        z6 = false;
                                    } else {
                                        AbstractC0782 abstractC07823 = c4402M11090.f16709;
                                        if (abstractC07823 != null && abstractC07823.mo2796()) {
                                            c4778.f18181.getClass();
                                            z6 = false;
                                        } else {
                                            AbstractC1701.m4653(c1120M64244.f4780);
                                            int i13 = i8 + 1;
                                            AbstractC0396 abstractC03962 = c4778.f18181;
                                            if (i13 > 20) {
                                                abstractC03962.getClass();
                                                throw new ProtocolException("Too many follow-up requests: " + i13);
                                            }
                                            abstractC03962.getClass();
                                            c4778.m9963(true);
                                            c11208 = c1120M64244;
                                            listM8997 = list;
                                            i8 = i13;
                                        }
                                    }
                                } catch (Throwable th) {
                                    th = th;
                                    z5 = false;
                                }
                            } catch (IOException e15) {
                                boolean zM11093 = m11093(e15, c4778, c2729, c4402M11090);
                                c4778.f18181.getClass();
                                if (!zM11093) {
                                    byte[] bArr = AbstractC1701.f6716;
                                    Iterator it = list.iterator();
                                    while (it.hasNext()) {
                                        ᵷˆᵣ.ʽˈˋ(e15, (Exception) it.next());
                                    }
                                    throw e15;
                                }
                                listM8997 = AbstractC4126.m8997(list, e15);
                                c4778.m9963(true);
                                z7 = false;
                            }
                            break;
                        } catch (Throwable th2) {
                            th = th2;
                            z5 = true;
                        }
                        c4778.m9963(z5);
                        throw th;
                    }
                    ᵕᵩʽᵲ.ᵪᵹᵥᵻ("Check failed.");
                    return null;
                }
        }
    }
}
