package F0;

import B0.RunnableC0014a;
import B0.S;
import C3.AbstractC0055q;
import C3.G;
import C3.W;
import L0.C;
import L0.C0147b;
import L0.C0164t;
import L0.C0169y;
import L0.X;
import L0.Y;
import L0.a0;
import L0.e0;
import L0.n0;
import T0.F;
import T0.z;
import android.net.Uri;
import android.os.Handler;
import android.os.SystemClock;
import android.util.Pair;
import android.util.SparseArray;
import android.util.SparseIntArray;
import com.google.android.gms.internal.measurement.B1;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
import n4.u0;
import u0.C1575k;
import u0.C1578n;
import u0.C1579o;
import u0.D;
import u0.E;
import u0.T;
import x0.AbstractC1709a;
import x0.v;

/* JADX INFO: loaded from: classes.dex */
public final class q implements P0.h, P0.k, e0, T0.o, a0 {

    /* JADX INFO: renamed from: o0, reason: collision with root package name */
    public static final Set f2366o0 = Collections.unmodifiableSet(new HashSet(Arrays.asList(1, 2, 5)));

    /* JADX INFO: renamed from: A, reason: collision with root package name */
    public final E0.e f2367A;

    /* JADX INFO: renamed from: B, reason: collision with root package name */
    public final int f2368B;

    /* JADX INFO: renamed from: C, reason: collision with root package name */
    public final B1 f2369C;
    public final ArrayList D;

    /* JADX INFO: renamed from: E, reason: collision with root package name */
    public final List f2370E;

    /* JADX INFO: renamed from: F, reason: collision with root package name */
    public final n f2371F;

    /* JADX INFO: renamed from: G, reason: collision with root package name */
    public final n f2372G;
    public final Handler H;

    /* JADX INFO: renamed from: I, reason: collision with root package name */
    public final ArrayList f2373I;

    /* JADX INFO: renamed from: J, reason: collision with root package name */
    public final Map f2374J;

    /* JADX INFO: renamed from: K, reason: collision with root package name */
    public M0.a f2375K;

    /* JADX INFO: renamed from: L, reason: collision with root package name */
    public p[] f2376L;

    /* JADX INFO: renamed from: M, reason: collision with root package name */
    public int[] f2377M;

    /* JADX INFO: renamed from: N, reason: collision with root package name */
    public final HashSet f2378N;

    /* JADX INFO: renamed from: O, reason: collision with root package name */
    public final SparseIntArray f2379O;

    /* JADX INFO: renamed from: P, reason: collision with root package name */
    public o f2380P;

    /* JADX INFO: renamed from: Q, reason: collision with root package name */
    public int f2381Q;

    /* JADX INFO: renamed from: R, reason: collision with root package name */
    public int f2382R;

    /* JADX INFO: renamed from: S, reason: collision with root package name */
    public boolean f2383S;

    /* JADX INFO: renamed from: T, reason: collision with root package name */
    public boolean f2384T;

    /* JADX INFO: renamed from: U, reason: collision with root package name */
    public int f2385U;

    /* JADX INFO: renamed from: V, reason: collision with root package name */
    public C1579o f2386V;

    /* JADX INFO: renamed from: W, reason: collision with root package name */
    public C1579o f2387W;
    public boolean X;

    /* JADX INFO: renamed from: Y, reason: collision with root package name */
    public n0 f2388Y;

    /* JADX INFO: renamed from: Z, reason: collision with root package name */
    public Set f2389Z;

    /* JADX INFO: renamed from: a0, reason: collision with root package name */
    public int[] f2390a0;

    /* JADX INFO: renamed from: b0, reason: collision with root package name */
    public int f2391b0;

    /* JADX INFO: renamed from: c0, reason: collision with root package name */
    public boolean f2392c0;

    /* JADX INFO: renamed from: d0, reason: collision with root package name */
    public boolean[] f2393d0;

    /* JADX INFO: renamed from: e0, reason: collision with root package name */
    public boolean[] f2394e0;

    /* JADX INFO: renamed from: f0, reason: collision with root package name */
    public long f2395f0;

    /* JADX INFO: renamed from: g0, reason: collision with root package name */
    public long f2396g0;

    /* JADX INFO: renamed from: h0, reason: collision with root package name */
    public boolean f2397h0;

    /* JADX INFO: renamed from: i0, reason: collision with root package name */
    public boolean f2398i0;

    /* JADX INFO: renamed from: j0, reason: collision with root package name */
    public boolean f2399j0;

    /* JADX INFO: renamed from: k0, reason: collision with root package name */
    public boolean f2400k0;

    /* JADX INFO: renamed from: l0, reason: collision with root package name */
    public long f2401l0;

    /* JADX INFO: renamed from: m0, reason: collision with root package name */
    public C1575k f2402m0;

    /* JADX INFO: renamed from: n0, reason: collision with root package name */
    public j f2403n0;

    /* JADX INFO: renamed from: q, reason: collision with root package name */
    public final String f2404q;

    /* JADX INFO: renamed from: r, reason: collision with root package name */
    public final int f2405r;

    /* JADX INFO: renamed from: s, reason: collision with root package name */
    public final K4.c f2406s;

    /* JADX INFO: renamed from: t, reason: collision with root package name */
    public final i f2407t;

    /* JADX INFO: renamed from: u, reason: collision with root package name */
    public final P0.e f2408u;

    /* JADX INFO: renamed from: v, reason: collision with root package name */
    public final C1579o f2409v;

    /* JADX INFO: renamed from: w, reason: collision with root package name */
    public final E0.h f2410w;

    /* JADX INFO: renamed from: x, reason: collision with root package name */
    public final E0.e f2411x;

    /* JADX INFO: renamed from: y, reason: collision with root package name */
    public final C4.f f2412y;

    /* JADX INFO: renamed from: z, reason: collision with root package name */
    public final P0.m f2413z = new P0.m("Loader:HlsSampleStreamWrapper");

    /* JADX WARN: Type inference failed for: r1v12, types: [F0.n] */
    /* JADX WARN: Type inference failed for: r1v13, types: [F0.n] */
    public q(String str, int i, K4.c cVar, i iVar, Map map, P0.e eVar, long j8, C1579o c1579o, E0.h hVar, E0.e eVar2, C4.f fVar, E0.e eVar3, int i5) {
        this.f2404q = str;
        this.f2405r = i;
        this.f2406s = cVar;
        this.f2407t = iVar;
        this.f2374J = map;
        this.f2408u = eVar;
        this.f2409v = c1579o;
        this.f2410w = hVar;
        this.f2411x = eVar2;
        this.f2412y = fVar;
        this.f2367A = eVar3;
        this.f2368B = i5;
        B1 b12 = new B1();
        b12.f9559b = null;
        b12.f9558a = false;
        b12.f9560c = null;
        this.f2369C = b12;
        this.f2377M = new int[0];
        Set set = f2366o0;
        this.f2378N = new HashSet(set.size());
        this.f2379O = new SparseIntArray(set.size());
        this.f2376L = new p[0];
        this.f2394e0 = new boolean[0];
        this.f2393d0 = new boolean[0];
        ArrayList arrayList = new ArrayList();
        this.D = arrayList;
        this.f2370E = Collections.unmodifiableList(arrayList);
        this.f2373I = new ArrayList();
        final int i8 = 0;
        this.f2371F = new Runnable(this) { // from class: F0.n

            /* JADX INFO: renamed from: r, reason: collision with root package name */
            public final /* synthetic */ q f2357r;

            {
                this.f2357r = this;
            }

            @Override // java.lang.Runnable
            public final void run() {
                switch (i8) {
                    case u0.f15495q /* 0 */:
                        this.f2357r.E();
                        break;
                    default:
                        q qVar = this.f2357r;
                        qVar.f2383S = true;
                        qVar.E();
                        break;
                }
            }
        };
        final int i9 = 1;
        this.f2372G = new Runnable(this) { // from class: F0.n

            /* JADX INFO: renamed from: r, reason: collision with root package name */
            public final /* synthetic */ q f2357r;

            {
                this.f2357r = this;
            }

            @Override // java.lang.Runnable
            public final void run() {
                switch (i9) {
                    case u0.f15495q /* 0 */:
                        this.f2357r.E();
                        break;
                    default:
                        q qVar = this.f2357r;
                        qVar.f2383S = true;
                        qVar.E();
                        break;
                }
            }
        };
        this.H = v.n(null);
        this.f2395f0 = j8;
        this.f2396g0 = j8;
    }

    public static int C(int i) {
        if (i == 1) {
            return 2;
        }
        if (i != 2) {
            return i != 3 ? 0 : 1;
        }
        return 3;
    }

    public static T0.l x(int i, int i5) {
        AbstractC1709a.B("HlsSampleStreamWrapper", "Unmapped track with id " + i + " of type " + i5);
        return new T0.l();
    }

    public static C1579o z(C1579o c1579o, C1579o c1579o2, boolean z8) {
        String strD;
        String strU;
        if (c1579o == null) {
            return c1579o2;
        }
        String str = c1579o2.f17358n;
        int iH = E.h(str);
        String str2 = c1579o.f17355k;
        if (v.t(iH, str2) == 1) {
            strU = v.u(iH, str2);
            strD = E.d(strU);
        } else {
            String strB = E.b(str2, str);
            strD = str;
            strU = strB;
        }
        C1578n c1578nA = c1579o2.a();
        c1578nA.f17309a = c1579o.f17346a;
        c1578nA.f17310b = c1579o.f17347b;
        c1578nA.f17311c = G.k(c1579o.f17348c);
        c1578nA.f17312d = c1579o.f17349d;
        c1578nA.f17313e = c1579o.f17350e;
        c1578nA.f17314f = c1579o.f17351f;
        c1578nA.f17316h = z8 ? c1579o.f17353h : -1;
        c1578nA.i = z8 ? c1579o.i : -1;
        c1578nA.f17317j = strU;
        if (iH == 2) {
            c1578nA.f17327t = c1579o.f17365u;
            c1578nA.f17328u = c1579o.f17366v;
            c1578nA.f17329v = c1579o.f17367w;
        }
        if (strD != null) {
            c1578nA.f17320m = E.m(strD);
        }
        int i = c1579o.D;
        if (i != -1 && iH == 1) {
            c1578nA.f17301C = i;
        }
        D dB = c1579o.f17356l;
        if (dB != null) {
            D d8 = c1579o2.f17356l;
            if (d8 != null) {
                dB = d8.b(dB);
            }
            c1578nA.f17318k = dB;
        }
        return new C1579o(c1578nA);
    }

    /* JADX WARN: Removed duplicated region for block: B:50:0x00d9  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void A(int i) {
        ArrayList arrayList;
        AbstractC1709a.j(!this.f2413z.b());
        int i5 = i;
        loop0: while (true) {
            arrayList = this.D;
            if (i5 >= arrayList.size()) {
                i5 = -1;
                break;
            }
            int i8 = i5;
            while (true) {
                if (i8 >= arrayList.size()) {
                    j jVar = (j) arrayList.get(i5);
                    for (int i9 = 0; i9 < this.f2376L.length; i9++) {
                        if (this.f2376L[i9].q() > jVar.e(i9)) {
                            break;
                        }
                    }
                    break loop0;
                }
                if (((j) arrayList.get(i8)).f2308n) {
                    break;
                } else {
                    i8++;
                }
            }
            i5++;
        }
        if (i5 == -1) {
            return;
        }
        long j8 = B().f4147h;
        j jVar2 = (j) arrayList.get(i5);
        int size = arrayList.size();
        int i10 = v.f18553a;
        if (i5 < 0 || size > arrayList.size() || i5 > size) {
            throw new IllegalArgumentException();
        }
        if (i5 != size) {
            arrayList.subList(i5, size).clear();
        }
        for (int i11 = 0; i11 < this.f2376L.length; i11++) {
            int iE = jVar2.e(i11);
            p pVar = this.f2376L[i11];
            long jK = pVar.k(iE);
            Y y8 = pVar.f3769a;
            AbstractC1709a.d(jK <= y8.f3753g);
            y8.f3753g = jK;
            int i12 = y8.f3748b;
            if (jK != 0) {
                X x8 = y8.f3750d;
                if (jK == x8.f3743q) {
                    y8.a(y8.f3750d);
                    X x9 = new X(y8.f3753g, i12);
                    y8.f3750d = x9;
                    y8.f3751e = x9;
                    y8.f3752f = x9;
                } else {
                    while (y8.f3753g > x8.f3744r) {
                        x8 = (X) x8.f3746t;
                    }
                    X x10 = (X) x8.f3746t;
                    x10.getClass();
                    y8.a(x10);
                    X x11 = new X(x8.f3744r, i12);
                    x8.f3746t = x11;
                    if (y8.f3753g == x8.f3744r) {
                        x8 = x11;
                    }
                    y8.f3752f = x8;
                    if (y8.f3751e == x10) {
                        y8.f3751e = x11;
                    }
                }
            }
        }
        if (arrayList.isEmpty()) {
            this.f2396g0 = this.f2395f0;
        } else {
            ((j) AbstractC0055q.h(arrayList)).f2303J = true;
        }
        this.f2399j0 = false;
        int i13 = this.f2381Q;
        long j9 = jVar2.f4146g;
        E0.e eVar = this.f2367A;
        C0169y c0169y = new C0169y(1, i13, null, 3, null, v.W(j9), v.W(j8));
        C c3 = eVar.f1972b;
        c3.getClass();
        eVar.a(new E2.a(eVar, c3, c0169y, 4));
    }

    public final j B() {
        return (j) this.D.get(r0.size() - 1);
    }

    public final boolean D() {
        return this.f2396g0 != -9223372036854775807L;
    }

    /* JADX WARN: Multi-variable type inference failed */
    public final void E() {
        int i;
        int i5 = 0;
        if (!this.X && this.f2390a0 == null && this.f2383S) {
            for (p pVar : this.f2376L) {
                if (pVar.t() == null) {
                    return;
                }
            }
            n0 n0Var = this.f2388Y;
            if (n0Var != null) {
                int i8 = n0Var.f3883a;
                int[] iArr = new int[i8];
                this.f2390a0 = iArr;
                Arrays.fill(iArr, -1);
                for (int i9 = 0; i9 < i8; i9++) {
                    int i10 = 0;
                    while (true) {
                        p[] pVarArr = this.f2376L;
                        if (i10 < pVarArr.length) {
                            C1579o c1579oT = pVarArr[i10].t();
                            AbstractC1709a.k(c1579oT);
                            C1579o c1579o = this.f2388Y.a(i9).f17203d[0];
                            String str = c1579o.f17358n;
                            String str2 = c1579oT.f17358n;
                            int iH = E.h(str2);
                            if (iH != 3) {
                                if (iH == E.h(str)) {
                                    break;
                                } else {
                                    i10++;
                                }
                            } else if (Objects.equals(str2, str) && (!("application/cea-608".equals(str2) || "application/cea-708".equals(str2)) || c1579oT.f17340I == c1579o.f17340I)) {
                                break;
                            } else {
                                i10++;
                            }
                        }
                    }
                    this.f2390a0[i9] = i10;
                }
                ArrayList arrayList = this.f2373I;
                int size = arrayList.size();
                while (i5 < size) {
                    Object obj = arrayList.get(i5);
                    i5++;
                    ((m) obj).a();
                }
                return;
            }
            int length = this.f2376L.length;
            int i11 = 0;
            int i12 = -1;
            int i13 = -2;
            while (true) {
                if (i11 >= length) {
                    break;
                }
                C1579o c1579oT2 = this.f2376L[i11].t();
                AbstractC1709a.k(c1579oT2);
                String str3 = c1579oT2.f17358n;
                int i14 = E.l(str3) ? 2 : E.i(str3) ? 1 : E.k(str3) ? 3 : -2;
                if (C(i14) > C(i13)) {
                    i12 = i11;
                    i13 = i14;
                } else if (i14 == i13 && i12 != -1) {
                    i12 = -1;
                }
                i11++;
            }
            T t6 = this.f2407t.f2284h;
            int i15 = t6.f17200a;
            this.f2391b0 = -1;
            this.f2390a0 = new int[length];
            for (int i16 = 0; i16 < length; i16++) {
                this.f2390a0[i16] = i16;
            }
            T[] tArr = new T[length];
            int i17 = 0;
            while (i17 < length) {
                C1579o c1579oT3 = this.f2376L[i17].t();
                AbstractC1709a.k(c1579oT3);
                String str4 = this.f2404q;
                C1579o c1579o2 = this.f2409v;
                if (i17 == i12) {
                    C1579o[] c1579oArr = new C1579o[i15];
                    for (int i18 = i5; i18 < i15; i18++) {
                        C1579o c1579oD = t6.f17203d[i18];
                        if (i13 == 1 && c1579o2 != null) {
                            c1579oD = c1579oD.d(c1579o2);
                        }
                        c1579oArr[i18] = i15 == 1 ? c1579oT3.d(c1579oD) : z(c1579oD, c1579oT3, true);
                    }
                    tArr[i17] = new T(str4, c1579oArr);
                    this.f2391b0 = i17;
                    i = 0;
                } else {
                    if (i13 != 2 || !E.i(c1579oT3.f17358n)) {
                        c1579o2 = null;
                    }
                    StringBuilder sb = new StringBuilder();
                    sb.append(str4);
                    sb.append(":muxed:");
                    sb.append(i17 < i12 ? i17 : i17 - 1);
                    i = 0;
                    tArr[i17] = new T(sb.toString(), z(c1579o2, c1579oT3, false));
                }
                i17++;
                i5 = i;
            }
            int i19 = i5;
            this.f2388Y = y(tArr);
            AbstractC1709a.j(this.f2389Z == null ? 1 : i19);
            this.f2389Z = Collections.EMPTY_SET;
            this.f2384T = true;
            this.f2406s.H();
        }
    }

    public final void F() throws IOException {
        IOException iOException;
        IOException iOException2;
        P0.m mVar = this.f2413z;
        IOException iOException3 = mVar.f5306c;
        if (iOException3 != null) {
            throw iOException3;
        }
        P0.i iVar = mVar.f5305b;
        if (iVar != null && (iOException2 = iVar.f5295u) != null && iVar.f5296v > iVar.f5291q) {
            throw iOException2;
        }
        i iVar2 = this.f2407t;
        C0147b c0147b = iVar2.f2289n;
        if (c0147b != null) {
            throw c0147b;
        }
        Uri uri = iVar2.f2290o;
        if (uri == null || !iVar2.f2294s) {
            return;
        }
        G0.b bVar = (G0.b) iVar2.f2283g.f2761t.get(uri);
        P0.m mVar2 = bVar.f2745r;
        IOException iOException4 = mVar2.f5306c;
        if (iOException4 != null) {
            throw iOException4;
        }
        P0.i iVar3 = mVar2.f5305b;
        if (iVar3 != null && (iOException = iVar3.f5295u) != null && iVar3.f5296v > iVar3.f5291q) {
            throw iOException;
        }
        IOException iOException5 = bVar.f2753z;
        if (iOException5 != null) {
            throw iOException5;
        }
    }

    public final void G(T[] tArr, int... iArr) {
        this.f2388Y = y(tArr);
        this.f2389Z = new HashSet();
        for (int i : iArr) {
            this.f2389Z.add(this.f2388Y.a(i));
        }
        this.f2391b0 = 0;
        this.H.post(new RunnableC0014a(9, this.f2406s));
        this.f2384T = true;
    }

    public final void H() {
        for (p pVar : this.f2376L) {
            pVar.z(this.f2397h0);
        }
        this.f2397h0 = false;
    }

    public final boolean I(long j8, boolean z8) {
        j jVar;
        boolean z9;
        this.f2395f0 = j8;
        if (D()) {
            this.f2396g0 = j8;
            return true;
        }
        boolean z10 = this.f2407t.f2291p;
        ArrayList arrayList = this.D;
        if (z10) {
            for (int i = 0; i < arrayList.size(); i++) {
                jVar = (j) arrayList.get(i);
                if (jVar.f4146g == j8) {
                    break;
                }
            }
            jVar = null;
        } else {
            jVar = null;
        }
        if (this.f2383S && !z8) {
            int length = this.f2376L.length;
            for (int i5 = 0; i5 < length; i5++) {
                p pVar = this.f2376L[i5];
                if (!(jVar != null ? pVar.B(jVar.e(i5)) : pVar.C(j8, false)) && (this.f2394e0[i5] || !this.f2392c0)) {
                    z9 = false;
                    break;
                }
            }
            z9 = true;
            if (z9) {
                return false;
            }
        }
        this.f2396g0 = j8;
        this.f2399j0 = false;
        arrayList.clear();
        P0.m mVar = this.f2413z;
        if (!mVar.b()) {
            mVar.f5306c = null;
            H();
            return true;
        }
        if (this.f2383S) {
            for (p pVar2 : this.f2376L) {
                pVar2.j();
            }
        }
        mVar.a();
        return true;
    }

    @Override // L0.e0
    public final boolean a() {
        return this.f2413z.b();
    }

    @Override // P0.h
    public final void e(P0.j jVar, long j8, long j9, int i) {
        C0164t c0164t;
        M0.a aVar = (M0.a) jVar;
        if (i == 0) {
            long j10 = aVar.f4140a;
            c0164t = new C0164t(aVar.f4141b);
        } else {
            long j11 = aVar.f4140a;
            Uri uri = aVar.i.f19183s;
            c0164t = new C0164t(j9);
        }
        C0164t c0164t2 = c0164t;
        int i5 = aVar.f4142c;
        this.f2367A.e(c0164t2, i5, this.f2405r, aVar.f4143d, aVar.f4144e, aVar.f4145f, aVar.f4146g, aVar.f4147h, i);
    }

    /* JADX WARN: Removed duplicated region for block: B:116:0x0277  */
    /* JADX WARN: Removed duplicated region for block: B:120:0x0283  */
    /* JADX WARN: Removed duplicated region for block: B:157:0x02e6 A[ADDED_TO_REGION] */
    /* JADX WARN: Removed duplicated region for block: B:159:0x02ea  */
    /* JADX WARN: Removed duplicated region for block: B:161:0x0300  */
    /* JADX WARN: Removed duplicated region for block: B:162:0x0307  */
    /* JADX WARN: Removed duplicated region for block: B:164:0x0315  */
    /* JADX WARN: Removed duplicated region for block: B:165:0x0317  */
    /* JADX WARN: Removed duplicated region for block: B:168:0x032d  */
    /* JADX WARN: Removed duplicated region for block: B:169:0x0332  */
    /* JADX WARN: Removed duplicated region for block: B:172:0x0352  */
    /* JADX WARN: Removed duplicated region for block: B:173:0x0355  */
    /* JADX WARN: Removed duplicated region for block: B:175:0x0359  */
    /* JADX WARN: Removed duplicated region for block: B:176:0x0363  */
    /* JADX WARN: Removed duplicated region for block: B:179:0x0368  */
    /* JADX WARN: Removed duplicated region for block: B:180:0x0375  */
    /* JADX WARN: Removed duplicated region for block: B:183:0x037d  */
    /* JADX WARN: Removed duplicated region for block: B:194:0x03c1  */
    /* JADX WARN: Removed duplicated region for block: B:197:0x03d4  */
    /* JADX WARN: Removed duplicated region for block: B:224:0x041c  */
    /* JADX WARN: Removed duplicated region for block: B:227:0x0442  */
    /* JADX WARN: Type inference fix 'apply assigned field type' failed
    java.lang.UnsupportedOperationException: ArgType.getObject(), call class: class jadx.core.dex.instructions.args.ArgType$PrimitiveArg
    	at jadx.core.dex.instructions.args.ArgType.getObject(ArgType.java:593)
    	at jadx.core.dex.attributes.nodes.ClassTypeVarsAttr.getTypeVarsMapFor(ClassTypeVarsAttr.java:35)
    	at jadx.core.dex.nodes.utils.TypeUtils.replaceClassGenerics(TypeUtils.java:177)
    	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.insertExplicitUseCast(FixTypesVisitor.java:397)
    	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.tryFieldTypeWithNewCasts(FixTypesVisitor.java:359)
    	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.applyFieldType(FixTypesVisitor.java:309)
    	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.visit(FixTypesVisitor.java:94)
     */
    @Override // L0.e0
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final boolean f(B0.T t6) {
        long jMax;
        List list;
        long j8;
        B1 b12;
        int i;
        long j9;
        B1 b13;
        int iIntValue;
        long j10;
        int i5;
        int i8;
        h hVar;
        h hVar2;
        e eVarD;
        int i9;
        boolean z8;
        boolean z9;
        byte[] bArr;
        boolean z10;
        byte[] bArrD;
        long j11;
        z0.h aVar;
        G0.h hVar3;
        B1 b14;
        z0.k kVar;
        z0.h hVar4;
        boolean z11;
        h1.h hVar5;
        b bVar;
        x0.o oVar;
        x0.t tVar;
        byte[] bArrD2;
        z0.h aVar2;
        String str;
        if (!this.f2399j0) {
            P0.m mVar = this.f2413z;
            if (!mVar.b()) {
                if (mVar.f5306c != null) {
                    return false;
                }
                if (D()) {
                    list = Collections.EMPTY_LIST;
                    jMax = this.f2396g0;
                    for (p pVar : this.f2376L) {
                        pVar.f3787t = this.f2396g0;
                    }
                } else {
                    j jVarB = B();
                    jMax = jVarB.H ? jVarB.f4147h : Math.max(this.f2395f0, jVarB.f4146g);
                    list = this.f2370E;
                }
                List list2 = list;
                B1 b15 = this.f2369C;
                b15.f9559b = null;
                b15.f9558a = false;
                b15.f9560c = null;
                boolean z12 = this.f2384T || !list2.isEmpty();
                i iVar = this.f2407t;
                j jVar = list2.isEmpty() ? null : (j) AbstractC0055q.h(list2);
                int iA = jVar == null ? -1 : iVar.f2284h.a(jVar.f4143d);
                long j12 = t6.f660a;
                long jMax2 = jMax - j12;
                int i10 = iA;
                long j13 = iVar.f2293r;
                long jMax3 = j13 != -9223372036854775807L ? j13 - j12 : -9223372036854775807L;
                if (jVar == null || iVar.f2291p) {
                    j8 = -9223372036854775807L;
                    b12 = b15;
                } else {
                    j8 = -9223372036854775807L;
                    b12 = b15;
                    long j14 = jVar.f4147h - jVar.f4146g;
                    jMax2 = Math.max(0L, jMax2 - j14);
                    if (jMax3 != -9223372036854775807L) {
                        jMax3 = Math.max(0L, jMax3 - j14);
                    }
                }
                M0.c[] cVarArrA = iVar.a(jVar, jMax);
                i iVar2 = iVar;
                long j15 = jMax;
                j jVar2 = jVar;
                iVar.f2292q.s(j12, jMax2, jMax3, list2, cVarArrA);
                int iA2 = iVar2.f2292q.a();
                boolean z13 = i10 != iA2;
                Uri[] uriArr = iVar2.f2281e;
                Uri uri = uriArr[iA2];
                G0.c cVar = iVar2.f2283g;
                if (cVar.c(uri)) {
                    G0.k kVarA = cVar.a(uri, true);
                    kVarA.getClass();
                    iVar2.f2291p = kVarA.f2846c;
                    boolean z14 = kVarA.f2818o;
                    long j16 = kVarA.f2812h;
                    if (z14) {
                        i = i10;
                        j9 = j8;
                    } else {
                        i = i10;
                        j9 = (kVarA.f2824u + j16) - cVar.D;
                        iVar2 = iVar2;
                    }
                    iVar2.f2293r = j9;
                    long j17 = j16 - cVar.D;
                    b13 = b12;
                    Pair pairC = iVar2.c(jVar2, z13, kVarA, j17, j15);
                    long jLongValue = ((Long) pairC.first).longValue();
                    int iIntValue2 = ((Integer) pairC.second).intValue();
                    if (jLongValue >= kVarA.f2814k || jVar2 == null || !z13) {
                        iIntValue = iIntValue2;
                        j10 = j17;
                        i5 = iA2;
                        i8 = i;
                    } else {
                        uri = uriArr[i];
                        kVarA = cVar.a(uri, true);
                        kVarA.getClass();
                        long j18 = kVarA.f2812h - cVar.D;
                        Pair pairC2 = iVar2.c(jVar2, false, kVarA, j18, j15);
                        jLongValue = ((Long) pairC2.first).longValue();
                        iIntValue = ((Integer) pairC2.second).intValue();
                        j10 = j18;
                        i8 = i;
                        i5 = i8;
                    }
                    long j19 = jLongValue;
                    if (i5 != i8 && i8 != -1) {
                        G0.b bVar2 = (G0.b) cVar.f2761t.get(uriArr[i8]);
                        if (bVar2 != null) {
                            bVar2.f2742A = false;
                        }
                    }
                    long j20 = kVarA.f2814k;
                    if (j19 < j20) {
                        iVar2.f2289n = new C0147b();
                    } else {
                        long j21 = j10;
                        int i11 = (int) (j19 - j20);
                        G g8 = kVarA.f2821r;
                        int size = g8.size();
                        G g9 = kVarA.f2822s;
                        if (i11 == size) {
                            if (iIntValue == -1) {
                                iIntValue = 0;
                            }
                            if (iIntValue < g9.size()) {
                                hVar2 = new h((G0.i) g9.get(iIntValue), j19, iIntValue);
                                hVar = hVar2;
                            }
                        } else {
                            G0.h hVar6 = (G0.h) g8.get(i11);
                            if (iIntValue == -1) {
                                hVar = new h(hVar6, j19, -1);
                            } else if (iIntValue < hVar6.f2791C.size()) {
                                hVar2 = new h((G0.i) hVar6.f2791C.get(iIntValue), j19, iIntValue);
                                hVar = hVar2;
                            } else {
                                int i12 = i11 + 1;
                                hVar = i12 < g8.size() ? new h((G0.i) g8.get(i12), j19 + 1, -1) : !g9.isEmpty() ? new h((G0.i) g9.get(0), j19 + 1, 0) : null;
                            }
                        }
                        if (hVar != null) {
                            iVar2.f2294s = false;
                            iVar2.f2290o = null;
                            SystemClock.elapsedRealtime();
                            G0.i iVar3 = hVar.f2273a;
                            G0.h hVar7 = iVar3.f2794r;
                            String str2 = kVarA.f2844a;
                            Uri uriZ = (hVar7 != null || (str = hVar7.f2799w) == null) ? null : AbstractC1709a.z(str2, str);
                            eVarD = iVar2.d(uriZ, i5, true);
                            b13.f9559b = eVarD;
                            if (eVarD == null) {
                                String str3 = iVar3.f2799w;
                                Uri uriZ2 = str3 == null ? null : AbstractC1709a.z(str2, str3);
                                e eVarD2 = iVar2.d(uriZ2, i5, false);
                                b13.f9559b = eVarD2;
                                if (eVarD2 == null) {
                                    long j22 = iVar3.f2797u;
                                    if (jVar2 == null) {
                                        AtomicInteger atomicInteger = j.f2295L;
                                    } else {
                                        if (!uri.equals(jVar2.f2307m) || !jVar2.H) {
                                            long j23 = j21 + j22;
                                            boolean z15 = iVar3 instanceof G0.f;
                                            boolean z16 = kVarA.f2846c;
                                            if (z15 ? ((G0.f) iVar3).f2785B || (hVar.f2275c == 0 && z16) : z16) {
                                                i9 = i5;
                                                if (j23 < jVar2.f4147h) {
                                                }
                                                boolean z17 = hVar.f2276d;
                                                if (z8 || !z17) {
                                                    C1579o c1579o = iVar2.f2282f[i9];
                                                    int iF = iVar2.f2292q.f();
                                                    Object objL = iVar2.f2292q.l();
                                                    boolean z18 = iVar2.f2287l;
                                                    K4.c cVar2 = iVar2.f2285j;
                                                    if (uriZ2 != null) {
                                                        cVar2.getClass();
                                                        z9 = z17;
                                                        bArr = null;
                                                    } else {
                                                        z9 = z17;
                                                        bArr = (byte[]) ((d) cVar2.f3604r).get(uriZ2);
                                                    }
                                                    byte[] bArr2 = uriZ != null ? null : (byte[]) ((d) cVar2.f3604r).get(uriZ);
                                                    AtomicInteger atomicInteger2 = j.f2295L;
                                                    Map map = Collections.EMPTY_MAP;
                                                    Uri uriZ3 = AbstractC1709a.z(str2, iVar3.f2793q);
                                                    int i13 = !z9 ? 8 : 0;
                                                    AbstractC1709a.l(uriZ3, "The uri must be set.");
                                                    z0.k kVar2 = new z0.k(uriZ3, 1, null, map, iVar3.f2801y, iVar3.f2802z, i13);
                                                    z10 = bArr == null;
                                                    if (z10) {
                                                        bArrD = null;
                                                    } else {
                                                        String str4 = iVar3.f2800x;
                                                        str4.getClass();
                                                        bArrD = j.d(str4);
                                                    }
                                                    z0.h hVar8 = iVar2.f2278b;
                                                    if (bArr == null) {
                                                        bArrD.getClass();
                                                        j11 = j22;
                                                        aVar = new a(hVar8, bArr, bArrD);
                                                    } else {
                                                        j11 = j22;
                                                        aVar = hVar8;
                                                    }
                                                    hVar3 = iVar3.f2794r;
                                                    if (hVar3 == null) {
                                                        boolean z19 = bArr2 != null;
                                                        if (z19) {
                                                            String str5 = hVar3.f2800x;
                                                            str5.getClass();
                                                            bArrD2 = j.d(str5);
                                                        } else {
                                                            bArrD2 = null;
                                                        }
                                                        Uri uriZ4 = AbstractC1709a.z(str2, hVar3.f2793q);
                                                        AbstractC1709a.l(uriZ4, "The uri must be set.");
                                                        b14 = b13;
                                                        z0.k kVar3 = new z0.k(uriZ4, 1, null, map, hVar3.f2801y, hVar3.f2802z, 0);
                                                        if (bArr2 != null) {
                                                            bArrD2.getClass();
                                                            aVar2 = new a(hVar8, bArr2, bArrD2);
                                                        } else {
                                                            aVar2 = hVar8;
                                                        }
                                                        hVar4 = aVar2;
                                                        z11 = z19;
                                                        kVar = kVar3;
                                                    } else {
                                                        b14 = b13;
                                                        kVar = null;
                                                        hVar4 = null;
                                                        z11 = false;
                                                    }
                                                    long j24 = j21 + j11;
                                                    long j25 = j24 + iVar3.f2795s;
                                                    int i14 = kVarA.f2813j + iVar3.f2796t;
                                                    if (jVar2 == null) {
                                                        z0.k kVar4 = jVar2.f2311q;
                                                        b bVar3 = ((kVar == kVar4 || (kVar != null && kVar4 != null && kVar.f19138a.equals(kVar4.f19138a) && (kVar.f19142e > kVar4.f19142e ? 1 : (kVar.f19142e == kVar4.f19142e ? 0 : -1)) == 0)) && (uri.equals(jVar2.f2307m) && jVar2.H) && !jVar2.f2303J && jVar2.f2306l == i14) ? jVar2.f2298C : null;
                                                        hVar5 = jVar2.f2319y;
                                                        oVar = jVar2.f2320z;
                                                        bVar = bVar3;
                                                    } else {
                                                        hVar5 = new h1.h(null);
                                                        bVar = null;
                                                        oVar = new x0.o(10);
                                                    }
                                                    h1.h hVar9 = hVar5;
                                                    boolean z20 = !z9;
                                                    SparseArray sparseArray = (SparseArray) iVar2.f2280d.f3604r;
                                                    tVar = (x0.t) sparseArray.get(i14);
                                                    if (tVar == null) {
                                                        tVar = new x0.t(9223372036854775806L);
                                                        sparseArray.put(i14, tVar);
                                                    }
                                                    j jVar3 = new j(iVar2.f2277a, aVar, kVar2, c1579o, z10, hVar4, kVar, z11, uri, iVar2.i, iF, objL, j24, j25, hVar.f2274b, hVar.f2275c, z20, i14, iVar3.f2792A, z18, tVar, iVar3.f2798v, bVar, hVar9, oVar, z8, iVar2.f2286k);
                                                    b13 = b14;
                                                    b13.f9559b = jVar3;
                                                }
                                            } else {
                                                i9 = i5;
                                            }
                                            z8 = true;
                                            boolean z172 = hVar.f2276d;
                                            if (z8) {
                                                C1579o c1579o2 = iVar2.f2282f[i9];
                                                int iF2 = iVar2.f2292q.f();
                                                Object objL2 = iVar2.f2292q.l();
                                                boolean z182 = iVar2.f2287l;
                                                K4.c cVar22 = iVar2.f2285j;
                                                if (uriZ2 != null) {
                                                }
                                                if (uriZ != null) {
                                                }
                                                AtomicInteger atomicInteger22 = j.f2295L;
                                                Map map2 = Collections.EMPTY_MAP;
                                                Uri uriZ32 = AbstractC1709a.z(str2, iVar3.f2793q);
                                                if (!z9) {
                                                }
                                                AbstractC1709a.l(uriZ32, "The uri must be set.");
                                                z0.k kVar22 = new z0.k(uriZ32, 1, null, map2, iVar3.f2801y, iVar3.f2802z, i13);
                                                if (bArr == null) {
                                                }
                                                if (z10) {
                                                }
                                                z0.h hVar82 = iVar2.f2278b;
                                                if (bArr == null) {
                                                }
                                                hVar3 = iVar3.f2794r;
                                                if (hVar3 == null) {
                                                }
                                                long j242 = j21 + j11;
                                                long j252 = j242 + iVar3.f2795s;
                                                int i142 = kVarA.f2813j + iVar3.f2796t;
                                                if (jVar2 == null) {
                                                }
                                                h1.h hVar92 = hVar5;
                                                boolean z202 = !z9;
                                                SparseArray sparseArray2 = (SparseArray) iVar2.f2280d.f3604r;
                                                tVar = (x0.t) sparseArray2.get(i142);
                                                if (tVar == null) {
                                                }
                                                j jVar32 = new j(iVar2.f2277a, aVar, kVar22, c1579o2, z10, hVar4, kVar, z11, uri, iVar2.i, iF2, objL2, j242, j252, hVar.f2274b, hVar.f2275c, z202, i142, iVar3.f2792A, z182, tVar, iVar3.f2798v, bVar, hVar92, oVar, z8, iVar2.f2286k);
                                                b13 = b14;
                                                b13.f9559b = jVar32;
                                            }
                                        }
                                        z8 = false;
                                        boolean z1722 = hVar.f2276d;
                                        if (z8) {
                                        }
                                    }
                                    i9 = i5;
                                    z8 = false;
                                    boolean z17222 = hVar.f2276d;
                                    if (z8) {
                                    }
                                }
                            }
                        } else if (!kVarA.f2818o) {
                            b13.f9560c = uri;
                            iVar2.f2294s &= uri.equals(iVar2.f2290o);
                            iVar2.f2290o = uri;
                        } else if (z12 || g8.isEmpty()) {
                            b13.f9558a = true;
                        } else {
                            hVar = new h((G0.i) AbstractC0055q.h(g8), (j20 + ((long) g8.size())) - 1, -1);
                            iVar2.f2294s = false;
                            iVar2.f2290o = null;
                            SystemClock.elapsedRealtime();
                            G0.i iVar32 = hVar.f2273a;
                            G0.h hVar72 = iVar32.f2794r;
                            String str22 = kVarA.f2844a;
                            if (hVar72 != null) {
                                eVarD = iVar2.d(uriZ, i5, true);
                                b13.f9559b = eVarD;
                                if (eVarD == null) {
                                }
                            }
                        }
                    }
                } else {
                    B1 b16 = b12;
                    b16.f9560c = uri;
                    iVar2.f2294s &= uri.equals(iVar2.f2290o);
                    iVar2.f2290o = uri;
                    b13 = b16;
                }
                boolean z21 = b13.f9558a;
                M0.a aVar3 = (M0.a) b13.f9559b;
                Uri uri2 = (Uri) b13.f9560c;
                if (z21) {
                    this.f2396g0 = j8;
                    this.f2399j0 = true;
                    return true;
                }
                if (aVar3 == null) {
                    if (uri2 == null) {
                        return false;
                    }
                    ((G0.b) ((k) this.f2406s.f3604r).f2333r.f2761t.get(uri2)).c(true);
                    return false;
                }
                if (aVar3 instanceof j) {
                    j jVar4 = (j) aVar3;
                    this.f2403n0 = jVar4;
                    this.f2386V = jVar4.f4143d;
                    this.f2396g0 = -9223372036854775807L;
                    this.D.add(jVar4);
                    C3.D dJ = G.j();
                    for (p pVar2 : this.f2376L) {
                        dJ.a(Integer.valueOf(pVar2.f3784q + pVar2.f3783p));
                    }
                    W wG = dJ.g();
                    jVar4.D = this;
                    jVar4.f2302I = wG;
                    for (p pVar3 : this.f2376L) {
                        pVar3.getClass();
                        pVar3.f3765C = jVar4.f2305k;
                        if (jVar4.f2308n) {
                            pVar3.f3768G = true;
                        }
                    }
                }
                this.f2375K = aVar3;
                mVar.d(aVar3, this, this.f2412y.o(aVar3.f4142c));
                return true;
            }
        }
        return false;
    }

    /* JADX WARN: Multi-variable type inference failed */
    @Override // P0.h
    public final void g(P0.j jVar, long j8, long j9) {
        M0.a aVar = (M0.a) jVar;
        this.f2375K = null;
        i iVar = this.f2407t;
        if (aVar instanceof e) {
            e eVar = (e) aVar;
            iVar.f2288m = eVar.f2265j;
            Uri uri = eVar.f4141b.f19138a;
            byte[] bArr = eVar.f2267l;
            bArr.getClass();
            K4.c cVar = iVar.f2285j;
            cVar.getClass();
            uri.getClass();
        }
        long j10 = aVar.f4140a;
        Uri uri2 = aVar.i.f19183s;
        C0164t c0164t = new C0164t(j9);
        this.f2412y.getClass();
        this.f2367A.c(c0164t, aVar.f4142c, this.f2405r, aVar.f4143d, aVar.f4144e, aVar.f4145f, aVar.f4146g, aVar.f4147h);
        if (this.f2384T) {
            this.f2406s.s(this);
            return;
        }
        S s8 = new S();
        s8.f657a = this.f2395f0;
        f(new B0.T(s8));
    }

    @Override // T0.o
    public final void h() {
        this.f2400k0 = true;
        this.H.post(this.f2372G);
    }

    @Override // P0.k
    public final void i() {
        for (p pVar : this.f2376L) {
            pVar.z(true);
            K4.c cVar = pVar.f3776h;
            if (cVar != null) {
                cVar.J(pVar.f3773e);
                pVar.f3776h = null;
                pVar.f3775g = null;
            }
        }
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Type inference failed for: r0v1, types: [java.lang.Object[]] */
    /* JADX WARN: Type inference failed for: r1v15, types: [F0.p[]] */
    /* JADX WARN: Type inference failed for: r2v1, types: [F0.p[]] */
    /* JADX WARN: Type inference failed for: r6v0 */
    /* JADX WARN: Type inference failed for: r6v1 */
    /* JADX WARN: Type inference failed for: r6v2 */
    /* JADX WARN: Type inference failed for: r6v3, types: [T0.F] */
    /* JADX WARN: Type inference failed for: r6v4, types: [F0.p, L0.b0] */
    /* JADX WARN: Type inference failed for: r6v5, types: [T0.l] */
    /* JADX WARN: Type inference failed for: r6v6 */
    /* JADX WARN: Type inference failed for: r6v7 */
    @Override // T0.o
    public final F j(int i, int i5) {
        Integer numValueOf = Integer.valueOf(i5);
        Set set = f2366o0;
        boolean zContains = set.contains(numValueOf);
        HashSet hashSet = this.f2378N;
        SparseIntArray sparseIntArray = this.f2379O;
        ?? pVar = 0;
        pVar = 0;
        if (zContains) {
            AbstractC1709a.d(set.contains(Integer.valueOf(i5)));
            int i8 = sparseIntArray.get(i5, -1);
            if (i8 != -1) {
                if (hashSet.add(Integer.valueOf(i5))) {
                    this.f2377M[i8] = i;
                }
                pVar = this.f2377M[i8] == i ? this.f2376L[i8] : x(i, i5);
            }
        } else {
            int i9 = 0;
            while (true) {
                ?? r22 = this.f2376L;
                if (i9 >= r22.length) {
                    break;
                }
                if (this.f2377M[i9] == i) {
                    pVar = r22[i9];
                    break;
                }
                i9++;
            }
        }
        if (pVar == 0) {
            if (this.f2400k0) {
                return x(i, i5);
            }
            int length = this.f2376L.length;
            boolean z8 = i5 == 1 || i5 == 2;
            pVar = new p(this.f2408u, this.f2410w, this.f2411x, this.f2374J);
            pVar.f3787t = this.f2395f0;
            if (z8) {
                pVar.f2365I = this.f2402m0;
                pVar.f3793z = true;
            }
            long j8 = this.f2401l0;
            if (pVar.f3767F != j8) {
                pVar.f3767F = j8;
                pVar.f3793z = true;
            }
            if (this.f2403n0 != null) {
                pVar.f3765C = r2.f2305k;
            }
            pVar.f3774f = this;
            int i10 = length + 1;
            int[] iArrCopyOf = Arrays.copyOf(this.f2377M, i10);
            this.f2377M = iArrCopyOf;
            iArrCopyOf[length] = i;
            p[] pVarArr = this.f2376L;
            int i11 = v.f18553a;
            ?? CopyOf = Arrays.copyOf(pVarArr, pVarArr.length + 1);
            CopyOf[pVarArr.length] = pVar;
            this.f2376L = (p[]) CopyOf;
            boolean[] zArrCopyOf = Arrays.copyOf(this.f2394e0, i10);
            this.f2394e0 = zArrCopyOf;
            zArrCopyOf[length] = z8;
            this.f2392c0 |= z8;
            hashSet.add(Integer.valueOf(i5));
            sparseIntArray.append(i5, length);
            if (C(i5) > C(this.f2381Q)) {
                this.f2382R = length;
                this.f2381Q = i5;
            }
            this.f2393d0 = Arrays.copyOf(this.f2393d0, i10);
        }
        if (i5 != 5) {
            return pVar;
        }
        if (this.f2380P == null) {
            this.f2380P = new o(pVar, this.f2368B);
        }
        return this.f2380P;
    }

    @Override // L0.e0
    public final long k() {
        if (this.f2399j0) {
            return Long.MIN_VALUE;
        }
        if (D()) {
            return this.f2396g0;
        }
        long jMax = this.f2395f0;
        j jVarB = B();
        if (!jVarB.H) {
            ArrayList arrayList = this.D;
            jVarB = arrayList.size() > 1 ? (j) arrayList.get(arrayList.size() - 2) : null;
        }
        if (jVarB != null) {
            jMax = Math.max(jMax, jVarB.f4147h);
        }
        if (this.f2383S) {
            for (p pVar : this.f2376L) {
                jMax = Math.max(jMax, pVar.n());
            }
        }
        return jMax;
    }

    @Override // L0.a0
    public final void m() {
        this.H.post(this.f2371F);
    }

    @Override // P0.h
    public final B1.f n(P0.j jVar, long j8, long j9, IOException iOException, int i) {
        boolean zP;
        B1.f fVar;
        int i5;
        M0.a aVar = (M0.a) jVar;
        boolean z8 = aVar instanceof j;
        if (z8 && !((j) aVar).f2304K && (iOException instanceof z0.t) && ((i5 = ((z0.t) iOException).f19172t) == 410 || i5 == 404)) {
            return P0.m.f5301d;
        }
        long j10 = aVar.i.f19182r;
        Uri uri = aVar.i.f19183s;
        C0164t c0164t = new C0164t(j9);
        v.W(aVar.f4146g);
        v.W(aVar.f4147h);
        B7.a aVar2 = new B7.a(i, 4, iOException);
        i iVar = this.f2407t;
        A7.a aVarI = u0.i(iVar.f2292q);
        this.f2412y.getClass();
        B1.f fVarN = C4.f.n(aVarI, aVar2);
        if (fVarN == null || fVarN.f961a != 2) {
            zP = false;
        } else {
            O0.s sVar = iVar.f2292q;
            zP = sVar.p(fVarN.f962b, sVar.t(iVar.f2284h.a(aVar.f4143d)));
        }
        if (zP) {
            if (z8 && j10 == 0) {
                ArrayList arrayList = this.D;
                AbstractC1709a.j(((j) arrayList.remove(arrayList.size() - 1)) == aVar);
                if (arrayList.isEmpty()) {
                    this.f2396g0 = this.f2395f0;
                } else {
                    ((j) AbstractC0055q.h(arrayList)).f2303J = true;
                }
            }
            fVar = P0.m.f5302e;
        } else {
            long jP = C4.f.p(aVar2);
            fVar = jP != -9223372036854775807L ? new B1.f(0, jP, false) : P0.m.f5303f;
        }
        B1.f fVar2 = fVar;
        int i8 = fVar2.f961a;
        boolean z9 = i8 == 0 || i8 == 1;
        this.f2367A.d(c0164t, aVar.f4142c, this.f2405r, aVar.f4143d, aVar.f4144e, aVar.f4145f, aVar.f4146g, aVar.f4147h, iOException, !z9);
        if (!z9) {
            this.f2375K = null;
        }
        if (zP) {
            if (!this.f2384T) {
                S s8 = new S();
                s8.f657a = this.f2395f0;
                f(new B0.T(s8));
                return fVar2;
            }
            this.f2406s.s(this);
        }
        return fVar2;
    }

    @Override // L0.e0
    public final long r() {
        if (D()) {
            return this.f2396g0;
        }
        if (this.f2399j0) {
            return Long.MIN_VALUE;
        }
        return B().f4147h;
    }

    @Override // P0.h
    public final void s(P0.j jVar, long j8, long j9, boolean z8) {
        M0.a aVar = (M0.a) jVar;
        this.f2375K = null;
        long j10 = aVar.f4140a;
        Uri uri = aVar.i.f19183s;
        C0164t c0164t = new C0164t(j9);
        this.f2412y.getClass();
        this.f2367A.b(c0164t, aVar.f4142c, this.f2405r, aVar.f4143d, aVar.f4144e, aVar.f4145f, aVar.f4146g, aVar.f4147h);
        if (z8) {
            return;
        }
        if (D() || this.f2385U == 0) {
            H();
        }
        if (this.f2385U > 0) {
            this.f2406s.s(this);
        }
    }

    @Override // L0.e0
    public final void u(long j8) {
        P0.m mVar = this.f2413z;
        if (mVar.f5306c == null && !D()) {
            boolean zB = mVar.b();
            i iVar = this.f2407t;
            List list = this.f2370E;
            if (zB) {
                this.f2375K.getClass();
                if (iVar.f2289n != null ? false : iVar.f2292q.c(j8, this.f2375K, list)) {
                    mVar.a();
                    return;
                }
                return;
            }
            int size = list.size();
            while (size > 0 && iVar.b((j) list.get(size - 1)) == 2) {
                size--;
            }
            if (size < list.size()) {
                A(size);
            }
            int size2 = (iVar.f2289n != null || iVar.f2292q.length() < 2) ? list.size() : iVar.f2292q.n(j8, list);
            if (size2 < this.D.size()) {
                A(size2);
            }
        }
    }

    public final void w() {
        AbstractC1709a.j(this.f2384T);
        this.f2388Y.getClass();
        this.f2389Z.getClass();
    }

    public final n0 y(T[] tArr) {
        for (int i = 0; i < tArr.length; i++) {
            T t6 = tArr[i];
            C1579o[] c1579oArr = new C1579o[t6.f17200a];
            for (int i5 = 0; i5 < t6.f17200a; i5++) {
                C1579o c1579o = t6.f17203d[i5];
                int iO = this.f2410w.o(c1579o);
                C1578n c1578nA = c1579o.a();
                c1578nA.f17308L = iO;
                c1579oArr[i5] = new C1579o(c1578nA);
            }
            tArr[i] = new T(t6.f17201b, c1579oArr);
        }
        return new n0(tArr);
    }

    @Override // T0.o
    public final void v(z zVar) {
    }
}
