package n2;

import C1.l;
import a.AbstractC0872a;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Typeface;
import android.os.Build;
import android.os.Bundle;
import android.os.Trace;
import android.util.Log;
import androidx.navigation.C1134i;
import com.revenuecat.purchases.common.networking.RCHTTPStatusCodes;
import com.revenuecat.purchases.ui.revenuecatui.helpers.ColorExtractionConstants;
import java.io.File;
import java.io.InputStream;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
import kotlin.jvm.internal.o;
import u2.AbstractC2963a;
import x4.AbstractC3243i;
import y4.C3274b;

/* JADX INFO: renamed from: n2.c, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes.dex */
public abstract class AbstractC2612c {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public static long f21610a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public static Method f21611b;

    public AbstractC2612c() {
        new ConcurrentHashMap();
    }

    public static final boolean a(Object[] objArr, int i6, int i7, List list) {
        if (i7 == list.size()) {
            for (int i8 = 0; i8 < i7; i8++) {
                if (o.c(objArr[i6 + i8], list.get(i8))) {
                }
            }
            return true;
        }
        return false;
    }

    public static final String b(Object[] objArr, int i6, int i7, AbstractC3243i abstractC3243i) {
        StringBuilder sb = new StringBuilder((i7 * 3) + 2);
        sb.append("[");
        for (int i8 = 0; i8 < i7; i8++) {
            if (i8 > 0) {
                sb.append(", ");
            }
            Object obj = objArr[i6 + i8];
            if (obj == abstractC3243i) {
                sb.append("(this Collection)");
            } else {
                sb.append(obj);
            }
        }
        sb.append("]");
        String string = sb.toString();
        o.g(string, "toString(...)");
        return string;
    }

    /* JADX WARN: Code restructure failed: missing block: B:13:0x0011, code lost:
    
        if (r5 == false) goto L15;
     */
    /* JADX WARN: Code restructure failed: missing block: B:16:0x0015, code lost:
    
        return r2 - r3;
     */
    /* JADX WARN: Removed duplicated region for block: B:27:0x0026 A[RETURN] */
    /* JADX WARN: Removed duplicated region for block: B:28:0x0027  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public static final int c(int i6, int i7, int i8, boolean z6) {
        if (i7 >= i8) {
            if (z6) {
                return 0;
            }
            return i8 - i7;
        }
        if (z6) {
            if (z6) {
                if (z6) {
                }
            } else if (z6) {
            }
        } else {
            if (z6 ? i8 - i7 <= i6 : i7 > i6) {
                if (z6) {
                    return i8 - i7;
                }
                return 0;
            }
            if (z6) {
                return i6 - i7;
            }
        }
        return i6;
    }

    public static void d(String str) {
        if (str.length() > 127) {
            str = str.substring(0, 127);
        }
        Trace.beginSection(str);
    }

    public static C3274b e(C3274b c3274b) {
        c3274b.k();
        c3274b.f26210c = true;
        return c3274b.f26209b > 0 ? c3274b : C3274b.f26207d;
    }

    public static C3274b k() {
        return new C3274b(10);
    }

    public static final int l(double d6) {
        if (Double.isNaN(d6) || d6 <= u(0)) {
            return 0;
        }
        if (d6 >= u(-1)) {
            return -1;
        }
        return d6 <= 2.147483647E9d ? (int) d6 : ((int) (d6 - ((double) Integer.MAX_VALUE))) + Integer.MAX_VALUE;
    }

    public static final int n(Bundle bundle, String key) {
        o.h(key, "key");
        int i6 = bundle.getInt(key, Integer.MIN_VALUE);
        if (i6 != Integer.MIN_VALUE || bundle.getInt(key, Integer.MAX_VALUE) != Integer.MAX_VALUE) {
            return i6;
        }
        AbstractC2613d.i(key);
        throw null;
    }

    public static final Bundle o(Bundle bundle, String key) {
        o.h(key, "key");
        Bundle bundle2 = bundle.getBundle(key);
        if (bundle2 != null) {
            return bundle2;
        }
        AbstractC2613d.i(key);
        throw null;
    }

    public static boolean p() {
        if (Build.VERSION.SDK_INT >= 29) {
            return AbstractC2963a.a();
        }
        try {
            if (f21611b == null) {
                f21610a = Trace.class.getField("TRACE_TAG_APP").getLong(null);
                f21611b = Trace.class.getMethod("isTagEnabled", Long.TYPE);
            }
            return ((Boolean) f21611b.invoke(null, Long.valueOf(f21610a))).booleanValue();
        } catch (Exception e6) {
            if (!(e6 instanceof InvocationTargetException)) {
                Log.v("Trace", "Unable to call isTagEnabled via reflection", e6);
                return false;
            }
            Throwable cause = e6.getCause();
            if (cause instanceof RuntimeException) {
                throw ((RuntimeException) cause);
            }
            throw new RuntimeException(cause);
        }
    }

    public static List q(Object obj) {
        List listSingletonList = Collections.singletonList(obj);
        o.g(listSingletonList, "singletonList(...)");
        return listSingletonList;
    }

    public static String r(String str, String str2) {
        int length = str.length() - str2.length();
        if (length < 0 || length > 1) {
            throw new IllegalArgumentException("Invalid input received");
        }
        StringBuilder sb = new StringBuilder(str2.length() + str.length());
        for (int i6 = 0; i6 < str.length(); i6++) {
            sb.append(str.charAt(i6));
            if (str2.length() > i6) {
                sb.append(str2.charAt(i6));
            }
        }
        return sb.toString();
    }

    public static final void s(Object[] objArr, int i6, int i7) {
        o.h(objArr, "<this>");
        while (i6 < i7) {
            objArr[i6] = null;
            i6++;
        }
    }

    public static final String t(float f6) {
        if (Float.isNaN(f6)) {
            return "NaN";
        }
        if (Float.isInfinite(f6)) {
            return f6 < 0.0f ? "-Infinity" : "Infinity";
        }
        int iMax = Math.max(1, 0);
        float fPow = (float) Math.pow(10.0f, iMax);
        float f7 = f6 * fPow;
        int i6 = (int) f7;
        if (f7 - i6 >= 0.5f) {
            i6++;
        }
        float f8 = i6 / fPow;
        return iMax > 0 ? String.valueOf(f8) : String.valueOf((int) f8);
    }

    public static final double u(int i6) {
        return (((double) ((i6 >>> 31) << 30)) * ((double) 2)) + ((double) (Integer.MAX_VALUE & i6));
    }

    public static final double v(long j4) {
        return ((j4 >>> 11) * ((double) 2048)) + (j4 & 2047);
    }

    public static final String w(int i6, long j4) {
        if (j4 >= 0) {
            AbstractC0872a.w(i6);
            String string = Long.toString(j4, i6);
            o.g(string, "toString(...)");
            return string;
        }
        long j6 = i6;
        long j7 = ((j4 >>> 1) / j6) << 1;
        long j8 = j4 - (j7 * j6);
        if (j8 >= j6) {
            j8 -= j6;
            j7++;
        }
        AbstractC0872a.w(i6);
        String string2 = Long.toString(j7, i6);
        o.g(string2, "toString(...)");
        AbstractC0872a.w(i6);
        String string3 = Long.toString(j8, i6);
        o.g(string3, "toString(...)");
        return string2.concat(string3);
    }

    public abstract Typeface f(Context context, y1.e eVar, Resources resources);

    public abstract Typeface g(Context context, l[] lVarArr, int i6);

    public Typeface h(Context context, List list, int i6) {
        throw new IllegalStateException("createFromFontInfoWithFallback must only be called on API 29+");
    }

    public Typeface i(Context context, InputStream inputStream) {
        File fileH = AbstractC2613d.h(context);
        if (fileH == null) {
            return null;
        }
        try {
            if (AbstractC2613d.g(inputStream, fileH)) {
                return Typeface.createFromFile(fileH.getPath());
            }
            return null;
        } catch (RuntimeException unused) {
            return null;
        } finally {
            fileH.delete();
        }
    }

    public Typeface j(Context context, Resources resources, int i6, String str) {
        File fileH = AbstractC2613d.h(context);
        if (fileH == null) {
            return null;
        }
        try {
            if (AbstractC2613d.f(fileH, resources, i6)) {
                return Typeface.createFromFile(fileH.getPath());
            }
            return null;
        } catch (RuntimeException unused) {
            return null;
        } finally {
            fileH.delete();
        }
    }

    public l m(l[] lVarArr, int i6) {
        new C1134i(29);
        int i7 = (i6 & 1) == 0 ? RCHTTPStatusCodes.BAD_REQUEST : ColorExtractionConstants.MAXIMUM_BRIGHTNESS_THRESHOLD;
        boolean z6 = (i6 & 2) != 0;
        l lVar = null;
        int i8 = Integer.MAX_VALUE;
        for (l lVar2 : lVarArr) {
            int iAbs = (Math.abs(lVar2.f694c - i7) * 2) + (lVar2.f695d == z6 ? 0 : 1);
            if (lVar == null || i8 > iAbs) {
                lVar = lVar2;
                i8 = iAbs;
            }
        }
        return lVar;
    }
}
