package C1;

import android.content.Context;
import android.content.pm.PackageManager;
import android.graphics.Typeface;
import android.os.Build;
import android.os.Trace;
import java.util.List;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import n.C2594v;
import n.d0;
import n2.AbstractC2612c;

/* JADX INFO: loaded from: classes.dex */
public abstract class j {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public static final C2594v f685a = new C2594v(16);

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public static final ThreadPoolExecutor f686b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public static final Object f687c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public static final d0 f688d;

    static {
        ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(0, 1, 10000, TimeUnit.MILLISECONDS, new LinkedBlockingDeque(), new n());
        threadPoolExecutor.allowCoreThreadTimeOut(true);
        f686b = threadPoolExecutor;
        f687c = new Object();
        f688d = new d0(0);
    }

    public static String a(int i6, List list) {
        StringBuilder sb = new StringBuilder();
        for (int i7 = 0; i7 < list.size(); i7++) {
            sb.append(((f) list.get(i7)).f675f);
            sb.append("-");
            sb.append(i6);
            if (i7 < list.size() - 1) {
                sb.append(";");
            }
        }
        return sb.toString();
    }

    /* JADX WARN: Code restructure failed: missing block: B:60:0x00b6, code lost:
    
        r8 = move-exception;
     */
    /* JADX WARN: Code restructure failed: missing block: B:62:0x00ba, code lost:
    
        throw r8;
     */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public static i b(String str, Context context, List list, int i6) {
        int i7;
        Typeface typefaceG;
        AbstractC2612c.d("getFontSync");
        C2594v c2594v = f685a;
        try {
            Typeface typeface = (Typeface) c2594v.get(str);
            if (typeface != null) {
                return new i(typeface);
            }
            k kVarA = e.a(context, list);
            int i8 = kVarA.f690b;
            List list2 = (List) kVarA.f691c;
            if (i8 != 0) {
                i7 = i8 != 1 ? -3 : -2;
            } else {
                l[] lVarArr = (l[]) list2.get(0);
                if (lVarArr == null || lVarArr.length == 0) {
                    i7 = 1;
                } else {
                    int length = lVarArr.length;
                    int i9 = 0;
                    while (true) {
                        if (i9 >= length) {
                            i7 = 0;
                            break;
                        }
                        int i10 = lVarArr[i9].f696e;
                        if (i10 == 0) {
                            i9++;
                        } else if (i10 >= 0) {
                            i7 = i10;
                        }
                    }
                }
            }
            if (i7 != 0) {
                return new i(i7);
            }
            if (list2.size() <= 1 || Build.VERSION.SDK_INT < 29) {
                l[] lVarArr2 = (l[]) list2.get(0);
                AbstractC2612c abstractC2612c = z1.f.f26277a;
                AbstractC2612c.d("TypefaceCompat.createFromFontInfo");
                typefaceG = z1.f.f26277a.g(context, lVarArr2, i6);
                Trace.endSection();
            } else {
                AbstractC2612c abstractC2612c2 = z1.f.f26277a;
                AbstractC2612c.d("TypefaceCompat.createFromFontInfoWithFallback");
                typefaceG = z1.f.f26277a.h(context, list2, i6);
                Trace.endSection();
            }
            if (typefaceG == null) {
                return new i(-3);
            }
            c2594v.put(str, typefaceG);
            return new i(typefaceG);
        } catch (PackageManager.NameNotFoundException unused) {
            return new i(-1);
        } catch (Throwable th) {
            throw th;
        } finally {
        }
    }
}
