package o;

import java.io.File;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Collections;
import java.util.UUID;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.util.regex.Pattern;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* renamed from: o.uT, reason: case insensitive filesystem */
/* loaded from: classes.dex */
public abstract class AbstractC2619uT {
    public static final C2804wO a;
    public static final C2429sT b;

    static {
        Pattern pattern = C2804wO.d;
        a = AbstractC2378rs0.L("application/json; charset=utf-8");
        ExecutorService executorServiceNewFixedThreadPool = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors() * 2);
        C1713ks c1713ks = new C1713ks();
        c1713ks.c = executorServiceNewFixedThreadPool;
        synchronized (c1713ks) {
            c1713ks.a = 1000;
        }
        c1713ks.c();
        synchronized (c1713ks) {
            c1713ks.b = 500;
        }
        c1713ks.c();
        C2334rT c2334rT = new C2334rT();
        TimeUnit timeUnit = TimeUnit.MILLISECONDS;
        c2334rT.r = AbstractC2264qi0.b(0L, timeUnit);
        c2334rT.s = AbstractC2264qi0.b(0L, timeUnit);
        c2334rT.t = AbstractC2264qi0.b(0L, timeUnit);
        c2334rT.f = false;
        c2334rT.a = c1713ks;
        TimeUnit timeUnit2 = TimeUnit.MINUTES;
        c2334rT.b = new OD(200, 10L);
        EnumC2910xZ enumC2910xZ = EnumC2910xZ.p;
        EnumC2910xZ enumC2910xZ2 = EnumC2910xZ.n;
        ArrayList arrayList = new ArrayList(AbstractC0008Ai.S(enumC2910xZ, enumC2910xZ2));
        EnumC2910xZ enumC2910xZ3 = EnumC2910xZ.q;
        if (!arrayList.contains(enumC2910xZ3) && !arrayList.contains(enumC2910xZ2)) {
            throw new IllegalArgumentException(("protocols must contain h2_prior_knowledge or http/1.1: " + arrayList).toString());
        }
        if (arrayList.contains(enumC2910xZ3) && arrayList.size() > 1) {
            throw new IllegalArgumentException(("protocols containing h2_prior_knowledge cannot use other protocols: " + arrayList).toString());
        }
        if (arrayList.contains(EnumC2910xZ.m)) {
            throw new IllegalArgumentException(("protocols must not contain http/1.0: " + arrayList).toString());
        }
        if (arrayList.contains(null)) {
            throw new IllegalArgumentException("protocols must not contain null");
        }
        arrayList.remove(EnumC2910xZ.f792o);
        arrayList.equals(c2334rT.f700o);
        c2334rT.f700o = Collections.unmodifiableList(arrayList);
        c2334rT.c.add(new C0316Mf(3));
        b = new C2429sT(c2334rT);
    }

    public static void a(String str, String str2) {
        Charset charset = AbstractC2355rh.a;
        C2804wO c2804wOL = a;
        if (c2804wOL != null) {
            Pattern pattern = C2804wO.d;
            Charset charsetA = c2804wOL.a(null);
            if (charsetA == null) {
                try {
                    c2804wOL = AbstractC2378rs0.L(c2804wOL + "; charset=utf-8");
                } catch (IllegalArgumentException unused) {
                    c2804wOL = null;
                }
            } else {
                charset = charsetA;
            }
        }
        byte[] bytes = str2.getBytes(charset);
        int length = bytes.length;
        AbstractC2264qi0.c(bytes.length, 0, length);
        C1636k20 c1636k20 = new C1636k20(c2804wOL, length, bytes);
        Q1 q1 = new Q1();
        q1.D(str);
        q1.v("POST", c1636k20);
        ((KE) q1.n).a("User-Agent", "AndroidApp/1.0");
        ((KE) q1.n).a("Content-Type", "application/json");
        ((KE) q1.n).a("Connection", "keep-alive");
        U7 u7G = q1.g();
        try {
            C2429sT c2429sT = b;
            c2429sT.getClass();
            new C2202q00(c2429sT, u7G).e().close();
        } catch (Exception unused2) {
        }
    }

    public static String b(String str, String str2) {
        AbstractC3081zG abstractC3081zG;
        Charset charset = AbstractC2355rh.a;
        C2804wO c2804wOL = a;
        if (c2804wOL != null) {
            Pattern pattern = C2804wO.d;
            Charset charsetA = c2804wOL.a(null);
            if (charsetA == null) {
                try {
                    c2804wOL = AbstractC2378rs0.L(c2804wOL + "; charset=utf-8");
                } catch (IllegalArgumentException unused) {
                    c2804wOL = null;
                }
            } else {
                charset = charsetA;
            }
        }
        byte[] bytes = str2.getBytes(charset);
        int length = bytes.length;
        AbstractC2264qi0.c(bytes.length, 0, length);
        C1636k20 c1636k20 = new C1636k20(c2804wOL, length, bytes);
        Q1 q1 = new Q1();
        q1.D(str);
        q1.v("POST", c1636k20);
        ((KE) q1.n).a("User-Agent", "AndroidApp/1.0");
        ((KE) q1.n).a("Content-Type", "application/json");
        ((KE) q1.n).a("Connection", "keep-alive");
        U7 u7G = q1.g();
        try {
            C2429sT c2429sT = b;
            c2429sT.getClass();
            C20 c20E = new C2202q00(c2429sT, u7G).e();
            try {
                String strG = (c20E.b() && (abstractC3081zG = c20E.r) != null) ? abstractC3081zG.g() : null;
                c20E.close();
                return strG;
            } finally {
            }
        } catch (Exception unused2) {
            return null;
        }
    }

    public static boolean c(String str, String str2, String str3, String str4) {
        File file = new File(str2);
        int i = 0;
        if (file.exists()) {
            C2524tT c2524tT = new C2524tT(str3, file, i);
            String string = UUID.randomUUID().toString();
            C0135Ff c0135Ff = new C0135Ff(string.getBytes(AbstractC2355rh.a));
            c0135Ff.n = string;
            C2804wO c2804wO = EQ.m;
            ArrayList arrayList = new ArrayList();
            C2804wO c2804wO2 = EQ.n;
            if (!c2804wO2.b.equals("multipart")) {
                throw new IllegalArgumentException(("multipart != " + c2804wO2).toString());
            }
            arrayList.add(IJ.i("file", str4, c2524tT));
            if (arrayList.isEmpty()) {
                throw new IllegalStateException("Multipart body must have at least one part.");
            }
            EQ eq = new EQ(c0135Ff, c2804wO2, AbstractC2264qi0.w(arrayList));
            Q1 q1 = new Q1();
            q1.D(str);
            q1.v("POST", eq);
            ((KE) q1.n).a("User-Agent", "AndroidApp/1.0");
            ((KE) q1.n).a("Connection", "keep-alive");
            U7 u7G = q1.g();
            try {
                C2429sT c2429sT = b;
                c2429sT.getClass();
                C20 c20E = new C2202q00(c2429sT, u7G).e();
                try {
                    boolean zB = c20E.b();
                    long length = file.length() / 1024;
                    c20E.close();
                    return zB;
                } finally {
                }
            } catch (Exception unused) {
            }
        }
        return false;
    }
}
