package ua;

import android.app.Activity;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.database.SQLException;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.BitmapShader;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffXfermode;
import android.graphics.Shader;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import androidx.emoji2.text.l0;
import androidx.media3.common.MimeTypes;
import androidx.media3.common.util.Consumer;
import androidx.media3.common.util.ParsableByteArray;
import androidx.media3.exoplayer.audio.n;
import androidx.privacysandbox.ads.adservices.java.topics.TopicsManagerFutures$Api33Ext4JavaImpl;
import androidx.privacysandbox.ads.adservices.topics.TopicsManagerImplCommon;
import androidx.room.a0;
import androidx.room.w0;
import com.google.android.gms.measurement.internal.c2;
import com.google.firebase.components.DependencyCycleException;
import com.google.firebase.messaging.v;
import io.flutter.plugins.sharedpreferences.Messages$FlutterError;
import java.io.Closeable;
import java.io.File;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.io.Serializable;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.zip.ZipException;
import kotlin.coroutines.Continuation;
import kotlin.coroutines.EmptyCoroutineContext;
import kotlin.coroutines.intrinsics.CoroutineSingletons;
import kotlin.time.DurationUnit;
import l2.e0;
import n2.o;
import w8.k;
import xyz.netfly.MyApplication;
import xyz.netfly.ui.live.epg.q;
import xyz.stream.api.database.l;
import xyz.stream.api.database.p;

/* JADX INFO: loaded from: classes2.dex */
public abstract class b {

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

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public static bd.c f33388b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public static Paint f33389c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public static int f33390d;

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

    public static boolean A(int i10) {
        return i10 >= 2;
    }

    public static void B(Context context) {
        Context applicationContext;
        PackageManager packageManager;
        ApplicationInfo applicationInfo;
        Bundle bundle;
        int i10 = 0;
        if (c2.i(context).getBoolean("proxy_notification_initialized", false)) {
            return;
        }
        try {
            applicationContext = context.getApplicationContext();
            packageManager = applicationContext.getPackageManager();
        } catch (PackageManager.NameNotFoundException unused) {
        }
        boolean z10 = (packageManager == null || (applicationInfo = packageManager.getApplicationInfo(applicationContext.getPackageName(), 128)) == null || (bundle = applicationInfo.metaData) == null || !bundle.containsKey("firebase_messaging_notification_delegation_enabled")) ? true : applicationInfo.metaData.getBoolean("firebase_messaging_notification_delegation_enabled");
        if (Build.VERSION.SDK_INT >= 29) {
            new v(context, z10, new w8.i(), i10).run();
        } else {
            k.e(null);
        }
    }

    public static final boolean C(char c6) {
        return Character.isWhitespace(c6) || Character.isSpaceChar(c6);
    }

    public static int D(int i10) {
        if (i10 < 0) {
            return i10;
        }
        if (i10 < 3) {
            return i10 + 1;
        }
        if (i10 < 1073741824) {
            return (int) ((i10 / 0.75f) + 1.0f);
        }
        return Integer.MAX_VALUE;
    }

    public static kotlin.coroutines.h E(kotlin.coroutines.f fVar, kotlin.coroutines.g gVar) {
        nb.g.i(gVar, "key");
        return nb.g.c(fVar.getKey(), gVar) ? EmptyCoroutineContext.f29221a : fVar;
    }

    public static void F(n2.g gVar, int i10, Consumer consumer) {
        long jB = gVar.b(i10);
        List listC = gVar.c(jB);
        if (listC.isEmpty()) {
            return;
        }
        if (i10 == gVar.d() - 1) {
            throw new IllegalStateException();
        }
        long jB2 = gVar.b(i10 + 1) - gVar.b(i10);
        if (jB2 > 0) {
            consumer.accept(new n2.b(listC, jB, jB2));
        }
    }

    public static long G(int i10, int i11, ParsableByteArray parsableByteArray) {
        parsableByteArray.setPosition(i10);
        if (parsableByteArray.bytesLeft() < 5) {
            return -9223372036854775807L;
        }
        int i12 = parsableByteArray.readInt();
        if ((8388608 & i12) != 0 || ((2096896 & i12) >> 8) != i11 || (i12 & 32) == 0 || parsableByteArray.readUnsignedByte() < 7 || parsableByteArray.bytesLeft() < 7 || (parsableByteArray.readUnsignedByte() & 16) != 16) {
            return -9223372036854775807L;
        }
        byte[] bArr = new byte[6];
        parsableByteArray.readBytes(bArr, 0, 6);
        return ((255 & ((long) bArr[4])) >> 7) | ((((long) bArr[0]) & 255) << 25) | ((((long) bArr[1]) & 255) << 17) | ((((long) bArr[2]) & 255) << 9) | ((((long) bArr[3]) & 255) << 1);
    }

    public static xd.a H(xd.c cVar, int i10) {
        nb.g.i(cVar, "<this>");
        boolean z10 = i10 > 0;
        Integer numValueOf = Integer.valueOf(i10);
        nb.g.i(numValueOf, "step");
        if (z10) {
            if (cVar.f34809c <= 0) {
                i10 = -i10;
            }
            return new xd.a(cVar.f34807a, cVar.f34808b, i10);
        }
        throw new IllegalArgumentException("Step must be positive, was: " + numValueOf + '.');
    }

    public static final void I(int i10, String str) {
        StringBuilder sb = new StringBuilder();
        sb.append("Error code: " + i10);
        if (str != null) {
            sb.append(", message: ".concat(str));
        }
        throw new SQLException(sb.toString());
    }

    public static byte[] J(com.google.firebase.messaging.e eVar) throws IOException {
        ArrayDeque arrayDeque = new ArrayDeque(20);
        int iMin = Math.min(8192, Math.max(128, Integer.highestOneBit(0) * 2));
        int i10 = 0;
        while (i10 < 2147483639) {
            int iMin2 = Math.min(iMin, 2147483639 - i10);
            byte[] bArr = new byte[iMin2];
            arrayDeque.add(bArr);
            int i11 = 0;
            while (i11 < iMin2) {
                int i12 = eVar.read(bArr, i11, iMin2 - i11);
                if (i12 == -1) {
                    return j(arrayDeque, i10);
                }
                i11 += i12;
                i10 += i12;
            }
            long j10 = ((long) iMin) * ((long) (iMin < 4096 ? 4 : 2));
            iMin = j10 > 2147483647L ? Integer.MAX_VALUE : j10 < -2147483648L ? Integer.MIN_VALUE : (int) j10;
        }
        if (eVar.read() == -1) {
            return j(arrayDeque, 2147483639);
        }
        throw new OutOfMemoryError("input is too large to fit in a byte array");
    }

    /* JADX WARN: Removed duplicated region for block: B:21:0x0052  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public static void K(n2.g gVar, o oVar, Consumer consumer) {
        int iA;
        boolean z10;
        long j10 = oVar.f30783a;
        if (j10 == -9223372036854775807L) {
            iA = 0;
        } else {
            iA = gVar.a(j10);
            if (iA == -1) {
                iA = gVar.d();
            }
            if (iA > 0 && gVar.b(iA - 1) == j10) {
                iA--;
            }
        }
        if (j10 == -9223372036854775807L || iA >= gVar.d()) {
            z10 = false;
        } else {
            List listC = gVar.c(j10);
            long jB = gVar.b(iA);
            if (!listC.isEmpty()) {
                long j11 = oVar.f30783a;
                if (j11 < jB) {
                    consumer.accept(new n2.b(listC, j11, jB - j11));
                    z10 = true;
                }
            }
        }
        for (int i10 = iA; i10 < gVar.d(); i10++) {
            F(gVar, i10, consumer);
        }
        if (oVar.f30784b) {
            if (z10) {
                iA--;
            }
            for (int i11 = 0; i11 < iA; i11++) {
                F(gVar, i11, consumer);
            }
            if (z10) {
                consumer.accept(new n2.b(gVar.c(j10), gVar.b(iA), j10 - gVar.b(iA)));
            }
        }
    }

    public static final Map L(Map map) {
        nb.g.i(map, "<this>");
        Map.Entry entry = (Map.Entry) map.entrySet().iterator().next();
        Map mapSingletonMap = Collections.singletonMap(entry.getKey(), entry.getValue());
        nb.g.h(mapSingletonMap, "with(entries.iterator().…ingletonMap(key, value) }");
        return mapSingletonMap;
    }

    public static xd.c M(int i10, int i11) {
        if (i11 > Integer.MIN_VALUE) {
            return new xd.c(i10, i11 - 1, 1);
        }
        xd.c cVar = xd.c.f34814d;
        return xd.c.f34814d;
    }

    public static ArrayList N(Throwable th) {
        ArrayList arrayList = new ArrayList(3);
        if (th instanceof Messages$FlutterError) {
            Messages$FlutterError messages$FlutterError = (Messages$FlutterError) th;
            arrayList.add(messages$FlutterError.code);
            arrayList.add(messages$FlutterError.getMessage());
            arrayList.add(messages$FlutterError.details);
        } else {
            arrayList.add(th.toString());
            arrayList.add(th.getClass().getSimpleName());
            arrayList.add("Cause: " + th.getCause() + ", Stacktrace: " + Log.getStackTraceString(th));
        }
        return arrayList;
    }

    public static kotlinx.coroutines.o a() {
        kotlinx.coroutines.o oVar = new kotlinx.coroutines.o(true);
        oVar.K(null);
        return oVar;
    }

    public static void b(Canvas canvas, Context context, int i10, int i11) {
        if (f33389c == null) {
            Bitmap bitmapDecodeResource = BitmapFactory.decodeResource(context.getResources(), q6.a.blue_noise);
            Bitmap bitmapCreateBitmap = Bitmap.createBitmap(bitmapDecodeResource.getWidth(), bitmapDecodeResource.getHeight(), Bitmap.Config.ARGB_8888);
            Canvas canvas2 = new Canvas(bitmapCreateBitmap);
            Paint paint = new Paint();
            paint.setAlpha(38);
            canvas2.drawBitmap(bitmapDecodeResource, 0.0f, 0.0f, paint);
            Paint paint2 = new Paint();
            f33389c = paint2;
            paint2.setAntiAlias(true);
            f33389c.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_ATOP));
            Paint paint3 = f33389c;
            Shader.TileMode tileMode = Shader.TileMode.REPEAT;
            paint3.setShader(new BitmapShader(bitmapCreateBitmap, tileMode, tileMode));
        }
        canvas.drawRect(0.0f, 0.0f, i10, i11, f33389c);
    }

    public static int c(l2.h hVar, boolean z10) {
        int i10 = z10 ? hVar.f29997c : hVar.f29996b;
        int i11 = z10 ? hVar.f29996b : hVar.f29997c;
        byte[][] bArr = (byte[][]) hVar.f29998d;
        int i12 = 0;
        for (int i13 = 0; i13 < i10; i13++) {
            byte b10 = -1;
            int i14 = 0;
            for (int i15 = 0; i15 < i11; i15++) {
                byte b11 = z10 ? bArr[i13][i15] : bArr[i15][i13];
                if (b11 == b10) {
                    i14++;
                } else {
                    if (i14 >= 5) {
                        i12 += i14 - 2;
                    }
                    i14 = 1;
                    b10 = b11;
                }
            }
            if (i14 >= 5) {
                i12 = (i14 - 2) + i12;
            }
        }
        return i12;
    }

    public static String d(byte[] bArr) {
        StringBuilder sb = new StringBuilder(bArr.length * 2);
        for (byte b10 : bArr) {
            sb.append(String.format("%02x", Byte.valueOf(b10)));
        }
        return sb.toString();
    }

    public static void e(int i10) {
        if (new xd.c(2, 36, 1).f(i10)) {
            return;
        }
        StringBuilder sbQ = defpackage.e.q("radix ", i10, " was not in valid range ");
        sbQ.append(new xd.c(2, 36, 1));
        throw new IllegalArgumentException(sbQ.toString());
    }

    public static void f(boolean z10) {
        kotlinx.coroutines.flow.h.e(new File(MyApplication.f34822a.getCacheDir().getAbsolutePath()));
        q qVarO = q.o();
        synchronized (qVarO.f35388l) {
            ((LinkedHashMap) qVarO.f35390n).clear();
        }
        qVarO.f35377a.execute(new xyz.netfly.ads.h(qVarO, 13));
        re.a.u().getClass();
        xyz.stream.api.database.q qVarA = xyz.stream.api.database.q.a();
        qVarA.getClass();
        qVarA.f35846d.execute(new p(qVarA, null, 0));
        l lVarA = l.a();
        lVarA.getClass();
        lVarA.f35828a.execute(new xyz.stream.api.database.h(lVarA, 2));
        xyz.stream.api.d dVarB = xyz.stream.api.d.b();
        dVarB.getClass();
        try {
            File file = dVarB.f35767a;
            if (file != null && file.exists()) {
                dVarB.f35767a.delete();
            }
            File file2 = dVarB.f35768b;
            if (file2 != null && file2.exists()) {
                dVarB.f35768b.delete();
            }
        } catch (Exception e10) {
            u.a.g(e10, new StringBuilder("clearFiles error: "));
        }
        xyz.stream.api.f.b().getClass();
        try {
            File file3 = new File(xyz.stream.utils.e.d().f36112a.getFilesDir(), "cms_config.json");
            if (file3.exists() && !file3.delete()) {
                xyz.stream.utils.h.c("Failed to delete CMS config file");
            }
            File file4 = new File(xyz.stream.utils.e.d().f36112a.getFilesDir(), "cms_genre.json");
            if (file4.exists() && !file4.delete()) {
                xyz.stream.utils.h.c("Failed to delete genre config file");
            }
        } catch (Exception e11) {
            u.a.g(e11, new StringBuilder("Error clearing CMS config file: "));
        }
        if (z10) {
            q.o().f35391o = xyz.stream.api.database.q.a().e(MyApplication.f34822a);
            re.a.u().f(true, null);
            xyz.stream.api.o.f().j();
            xyz.stream.api.d.b().a();
        }
    }

    public static final void g(Closeable closeable, Throwable th) throws IOException {
        if (closeable != null) {
            if (th == null) {
                closeable.close();
                return;
            }
            try {
                closeable.close();
            } catch (Throwable th2) {
                kotlin.a.a(th, th2);
            }
        }
    }

    public static final void h(k3.c cVar, Throwable th) throws Exception {
        if (cVar != null) {
            if (th == null) {
                cVar.close();
                return;
            }
            try {
                cVar.close();
            } catch (Throwable th2) {
                kotlin.a.a(th, th2);
            }
        }
    }

    public static long i(long j10) {
        if (j10 < -4611686018427387903L) {
            return -4611686018427387903L;
        }
        if (j10 > 4611686018427387903L) {
            return 4611686018427387903L;
        }
        return j10;
    }

    public static byte[] j(ArrayDeque arrayDeque, int i10) {
        if (arrayDeque.isEmpty()) {
            return new byte[0];
        }
        byte[] bArr = (byte[]) arrayDeque.remove();
        if (bArr.length == i10) {
            return bArr;
        }
        int length = i10 - bArr.length;
        byte[] bArrCopyOf = Arrays.copyOf(bArr, i10);
        while (length > 0) {
            byte[] bArr2 = (byte[]) arrayDeque.remove();
            int iMin = Math.min(length, bArr2.length);
            System.arraycopy(bArr2, 0, bArrCopyOf, i10 - length, iMin);
            length -= iMin;
        }
        return bArrCopyOf;
    }

    public static int k(int i10, int i11) {
        int i12 = i10 - i11;
        if (i12 > i11) {
            i12 = i11;
            i11 = i12;
        }
        int i13 = 1;
        int i14 = 1;
        while (i10 > i11) {
            i13 *= i10;
            if (i14 <= i12) {
                i13 /= i14;
                i14++;
            }
            i10--;
        }
        while (i14 <= i12) {
            i13 /= i14;
            i14++;
        }
        return i13;
    }

    public static int l(Comparable comparable, Comparable comparable2) {
        if (comparable == comparable2) {
            return 0;
        }
        if (comparable == null) {
            return -1;
        }
        if (comparable2 == null) {
            return 1;
        }
        return comparable.compareTo(comparable2);
    }

    public static final long m(long j10, DurationUnit durationUnit, DurationUnit durationUnit2) {
        nb.g.i(durationUnit, "sourceUnit");
        nb.g.i(durationUnit2, "targetUnit");
        return durationUnit2.getTimeUnit().convert(j10, durationUnit.getTimeUnit());
    }

    /* JADX WARN: Multi-variable type inference failed */
    public static long[] n(Serializable serializable) {
        if (!(serializable instanceof int[])) {
            if (serializable instanceof long[]) {
                return (long[]) serializable;
            }
            return null;
        }
        int[] iArr = (int[]) serializable;
        long[] jArr = new long[iArr.length];
        for (int i10 = 0; i10 < iArr.length; i10++) {
            jArr[i10] = iArr[i10];
        }
        return jArr;
    }

    public static final void o(int i10, int i11) {
        if (i10 <= i11) {
            return;
        }
        throw new IndexOutOfBoundsException("toIndex (" + i10 + ") is greater than size (" + i11 + ").");
    }

    public static boolean p(File file) {
        if (!file.isDirectory()) {
            file.delete();
            return true;
        }
        File[] fileArrListFiles = file.listFiles();
        if (fileArrListFiles == null) {
            return false;
        }
        boolean z10 = true;
        for (File file2 : fileArrListFiles) {
            z10 = p(file2) && z10;
        }
        return z10;
    }

    public static void q(ArrayList arrayList) {
        HashMap map = new HashMap(arrayList.size());
        Iterator it = arrayList.iterator();
        while (true) {
            int i10 = 0;
            if (!it.hasNext()) {
                Iterator it2 = map.values().iterator();
                while (it2.hasNext()) {
                    for (com.google.firebase.components.i iVar : (Set) it2.next()) {
                        for (com.google.firebase.components.k kVar : iVar.f24020a.f24004c) {
                            if (kVar.f24027c == 0) {
                                Set<com.google.firebase.components.i> set = (Set) map.get(new com.google.firebase.components.j(kVar.f24025a, kVar.f24026b == 2));
                                if (set != null) {
                                    for (com.google.firebase.components.i iVar2 : set) {
                                        iVar.f24021b.add(iVar2);
                                        iVar2.f24022c.add(iVar);
                                    }
                                }
                            }
                        }
                    }
                }
                HashSet<com.google.firebase.components.i> hashSet = new HashSet();
                Iterator it3 = map.values().iterator();
                while (it3.hasNext()) {
                    hashSet.addAll((Set) it3.next());
                }
                HashSet hashSet2 = new HashSet();
                for (com.google.firebase.components.i iVar3 : hashSet) {
                    if (iVar3.f24022c.isEmpty()) {
                        hashSet2.add(iVar3);
                    }
                }
                while (!hashSet2.isEmpty()) {
                    com.google.firebase.components.i iVar4 = (com.google.firebase.components.i) hashSet2.iterator().next();
                    hashSet2.remove(iVar4);
                    i10++;
                    for (com.google.firebase.components.i iVar5 : iVar4.f24021b) {
                        iVar5.f24022c.remove(iVar4);
                        if (iVar5.f24022c.isEmpty()) {
                            hashSet2.add(iVar5);
                        }
                    }
                }
                if (i10 == arrayList.size()) {
                    return;
                }
                ArrayList arrayList2 = new ArrayList();
                for (com.google.firebase.components.i iVar6 : hashSet) {
                    if (!iVar6.f24022c.isEmpty() && !iVar6.f24021b.isEmpty()) {
                        arrayList2.add(iVar6.f24020a);
                    }
                }
                throw new DependencyCycleException(arrayList2);
            }
            com.google.firebase.components.a aVar = (com.google.firebase.components.a) it.next();
            com.google.firebase.components.i iVar7 = new com.google.firebase.components.i(aVar);
            for (com.google.firebase.components.p pVar : aVar.f24003b) {
                boolean z10 = !(aVar.f24006e == 0);
                com.google.firebase.components.j jVar = new com.google.firebase.components.j(pVar, z10);
                if (!map.containsKey(jVar)) {
                    map.put(jVar, new HashSet());
                }
                Set set2 = (Set) map.get(jVar);
                if (!set2.isEmpty() && !z10) {
                    throw new IllegalArgumentException(String.format("Multiple components provide %s.", pVar));
                }
                set2.add(iVar7);
            }
        }
    }

    public static final boolean r(char c6, char c10, boolean z10) {
        if (c6 == c10) {
            return true;
        }
        if (!z10) {
            return false;
        }
        char upperCase = Character.toUpperCase(c6);
        char upperCase2 = Character.toUpperCase(c10);
        return upperCase == upperCase2 || Character.toLowerCase(upperCase) == Character.toLowerCase(upperCase2);
    }

    public static final Object s(a0 a0Var, String str, Continuation continuation) {
        Object objD = a0Var.d(str, new w0(0), continuation);
        return objD == CoroutineSingletons.f29226a ? objD : kd.e.f29109a;
    }

    public static final void t(String str, k3.a aVar) throws Exception {
        nb.g.i(aVar, "<this>");
        nb.g.i(str, "sql");
        k3.c cVarJ = aVar.J(str);
        try {
            cVarJ.G();
            h(cVarJ, null);
        } finally {
        }
    }

    public static l0 u(RandomAccessFile randomAccessFile) throws IOException {
        long length = randomAccessFile.length();
        long j10 = length - 22;
        if (j10 < 0) {
            throw new ZipException("File too short to be a zip file: " + randomAccessFile.length());
        }
        long j11 = length - 65558;
        long j12 = j11 >= 0 ? j11 : 0L;
        int iReverseBytes = Integer.reverseBytes(101010256);
        do {
            randomAccessFile.seek(j10);
            if (randomAccessFile.readInt() == iReverseBytes) {
                randomAccessFile.skipBytes(2);
                randomAccessFile.skipBytes(2);
                randomAccessFile.skipBytes(2);
                randomAccessFile.skipBytes(2);
                l0 l0Var = new l0(2);
                l0Var.f2248c = ((long) Integer.reverseBytes(randomAccessFile.readInt())) & 4294967295L;
                l0Var.f2247b = ((long) Integer.reverseBytes(randomAccessFile.readInt())) & 4294967295L;
                return l0Var;
            }
            j10--;
        } while (j10 >= j12);
        throw new ZipException("End Of Central Directory signature not found");
    }

    public static final TopicsManagerFutures$Api33Ext4JavaImpl v(Context context) {
        TopicsManagerImplCommon dVar;
        nb.g.i(context, "context");
        if (com.bumptech.glide.i.g() >= 5) {
            Object systemService = context.getSystemService((Class<Object>) n.n());
            nb.g.h(systemService, "context.getSystemService…opicsManager::class.java)");
            dVar = new androidx.privacysandbox.ads.adservices.topics.e(n.k(systemService));
        } else if (com.bumptech.glide.i.g() == 4) {
            Object systemService2 = context.getSystemService((Class<Object>) n.n());
            nb.g.h(systemService2, "context.getSystemService…opicsManager::class.java)");
            dVar = new androidx.privacysandbox.ads.adservices.topics.d(n.k(systemService2));
        } else {
            dVar = null;
        }
        if (dVar != null) {
            return new TopicsManagerFutures$Api33Ext4JavaImpl(dVar);
        }
        return null;
    }

    public static kotlin.coroutines.f w(kotlin.coroutines.f fVar, kotlin.coroutines.g gVar) {
        nb.g.i(gVar, "key");
        if (nb.g.c(fVar.getKey(), gVar)) {
            return fVar;
        }
        return null;
    }

    public static String x(List list) {
        Iterator it = list.iterator();
        boolean z10 = false;
        String str = null;
        while (it.hasNext()) {
            String str2 = ((e0) it.next()).f29980a.f29955g.sampleMimeType;
            if (MimeTypes.isVideo(str2)) {
                return MimeTypes.VIDEO_MP4;
            }
            if (MimeTypes.isAudio(str2)) {
                z10 = true;
            } else if (MimeTypes.isImage(str2)) {
                if (Objects.equals(str2, MimeTypes.IMAGE_HEIC)) {
                    str = MimeTypes.IMAGE_HEIF;
                } else if (Objects.equals(str2, MimeTypes.IMAGE_AVIF)) {
                    str = MimeTypes.IMAGE_AVIF;
                }
            }
        }
        return z10 ? MimeTypes.AUDIO_MP4 : str != null ? str : MimeTypes.APPLICATION_MP4;
    }

    public static int y(int[] iArr, int i10, boolean z10) {
        int[] iArr2 = iArr;
        int i11 = 0;
        for (int i12 : iArr2) {
            i11 += i12;
        }
        int length = iArr2.length;
        int i13 = 0;
        int i14 = 0;
        int i15 = 0;
        while (true) {
            int i16 = length - 1;
            if (i13 >= i16) {
                return i14;
            }
            int i17 = 1 << i13;
            i15 |= i17;
            int i18 = 1;
            while (i18 < iArr2[i13]) {
                int i19 = i11 - i18;
                int i20 = length - i13;
                int i21 = i20 - 2;
                int iK = k(i19 - 1, i21);
                if (z10 && i15 == 0) {
                    int i22 = i20 - 1;
                    if (i19 - i22 >= i22) {
                        iK -= k(i19 - i20, i21);
                    }
                }
                if (i20 - 1 > 1) {
                    int iK2 = 0;
                    for (int i23 = i19 - i21; i23 > i10; i23--) {
                        iK2 += k((i19 - i23) - 1, i20 - 3);
                    }
                    iK -= (i16 - i13) * iK2;
                } else if (i19 > i10) {
                    iK--;
                }
                i14 += iK;
                i18++;
                i15 &= ~i17;
                iArr2 = iArr;
            }
            i11 -= i18;
            i13++;
            iArr2 = iArr;
        }
    }

    public static boolean z(int i10) {
        return i10 >= 1;
    }
}
