package defpackage;

import android.content.Context;
import android.content.pm.PackageManager;
import android.graphics.Typeface;
import android.os.Build;
import android.os.Trace;
import defpackage.mh3;
import defpackage.r08;
import java.util.List;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/* JADX INFO: loaded from: classes.dex */
class jh3 {
    public static final ol5 a = new ol5(16);
    public static final ThreadPoolExecutor b;
    public static final Object c;
    public static final zs8 d;

    static {
        r08.a aVar = new r08.a();
        aVar.a = "fonts-androidx";
        aVar.b = 10;
        ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(0, 1, 10000, TimeUnit.MILLISECONDS, new LinkedBlockingDeque(), aVar);
        threadPoolExecutor.allowCoreThreadTimeOut(true);
        b = threadPoolExecutor;
        c = new Object();
        d = new zs8(0);
    }

    public static String a(int i, List list) {
        StringBuilder sb = new StringBuilder();
        for (int i2 = 0; i2 < list.size(); i2++) {
            sb.append(((eh3) list.get(i2)).g);
            sb.append("-");
            sb.append(i);
            if (i2 < list.size() - 1) {
                sb.append(";");
            }
        }
        return sb.toString();
    }

    public static a b(String str, Context context, List list, int i) {
        int i2;
        ol5 ol5Var = a;
        Trace.beginSection("getFontSync");
        try {
            Typeface typeface = (Typeface) ol5Var.get(str);
            if (typeface != null) {
                return new a(typeface);
            }
            mh3.b bVarA = dh3.a(list, context);
            List list2 = bVarA.b;
            int i3 = bVarA.a;
            if (i3 != 0) {
                i2 = i3 != 1 ? -3 : -2;
            } else {
                mh3.c[] cVarArr = (mh3.c[]) list2.get(0);
                if (cVarArr == null || cVarArr.length == 0) {
                    i2 = 1;
                } else {
                    int length = cVarArr.length;
                    int i4 = 0;
                    while (true) {
                        if (i4 >= length) {
                            i2 = 0;
                            break;
                        }
                        int i5 = cVarArr[i4].f;
                        if (i5 == 0) {
                            i4++;
                        } else if (i5 >= 0) {
                            i2 = i5;
                        }
                    }
                }
            }
            if (i2 != 0) {
                return new a(i2);
            }
            Typeface typefaceA = (list2.size() <= 1 || Build.VERSION.SDK_INT < 29) ? r0a.a(context, (mh3.c[]) list2.get(0), i) : r0a.b(context, list2, i);
            if (typefaceA == null) {
                return new a(-3);
            }
            ol5Var.put(str, typefaceA);
            return new a(typefaceA);
        } catch (PackageManager.NameNotFoundException unused) {
            return new a(-1);
        } finally {
            Trace.endSection();
        }
    }

    public static final class a {
        public final Typeface a;
        public final int b;

        public a(int i) {
            this.a = null;
            this.b = i;
        }

        public a(Typeface typeface) {
            this.a = typeface;
            this.b = 0;
        }
    }
}
