package L0;

import java.util.ArrayList;
import x0.AbstractC1709a;

/* JADX INFO: renamed from: L0.h, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes.dex */
public final class C0153h extends p0 {

    /* JADX INFO: renamed from: l, reason: collision with root package name */
    public final long f3827l;

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    public final boolean f3828m;

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

    /* JADX INFO: renamed from: o, reason: collision with root package name */
    public final u0.Q f3830o;

    /* JADX INFO: renamed from: p, reason: collision with root package name */
    public C0151f f3831p;

    /* JADX INFO: renamed from: q, reason: collision with root package name */
    public C0152g f3832q;

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

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

    public C0153h(C0150e c0150e) {
        super(c0150e.f3804a);
        this.f3827l = c0150e.f3805b;
        this.f3828m = c0150e.f3806c;
        this.f3829n = new ArrayList();
        this.f3830o = new u0.Q();
    }

    public final void B(u0.S s8) {
        long j8;
        u0.Q q8 = this.f3830o;
        s8.n(0, q8);
        long j9 = q8.f17198p;
        C0151f c0151f = this.f3831p;
        ArrayList arrayList = this.f3829n;
        long j10 = this.f3827l;
        if (c0151f == null || arrayList.isEmpty()) {
            this.f3833r = j9;
            this.f3834s = j10 != Long.MIN_VALUE ? j9 + j10 : Long.MIN_VALUE;
            int size = arrayList.size();
            for (int i = 0; i < size; i++) {
                C0149d c0149d = (C0149d) arrayList.get(i);
                long j11 = this.f3833r;
                long j12 = this.f3834s;
                c0149d.f3801u = j11;
                c0149d.f3802v = j12;
            }
            j8 = 0;
        } else {
            j8 = this.f3833r - j9;
            j10 = j10 == Long.MIN_VALUE ? Long.MIN_VALUE : this.f3834s - j9;
        }
        try {
            C0151f c0151f2 = new C0151f(s8, j8, j10);
            this.f3831p = c0151f2;
            l(c0151f2);
        } catch (C0152g e8) {
            this.f3832q = e8;
            for (int i5 = 0; i5 < arrayList.size(); i5++) {
                ((C0149d) arrayList.get(i5)).f3803w = this.f3832q;
            }
        }
    }

    @Override // L0.AbstractC0146a
    public final A a(C c3, P0.e eVar, long j8) {
        C0149d c0149d = new C0149d(this.f3891k.a(c3, eVar, j8), this.f3828m, this.f3833r, this.f3834s);
        this.f3829n.add(c0149d);
        return c0149d;
    }

    @Override // L0.AbstractC0157l, L0.AbstractC0146a
    public final void i() throws C0152g {
        C0152g c0152g = this.f3832q;
        if (c0152g != null) {
            throw c0152g;
        }
        super.i();
    }

    @Override // L0.AbstractC0146a
    public final void m(A a3) {
        ArrayList arrayList = this.f3829n;
        AbstractC1709a.j(arrayList.remove(a3));
        this.f3891k.m(((C0149d) a3).f3797q);
        if (arrayList.isEmpty()) {
            C0151f c0151f = this.f3831p;
            c0151f.getClass();
            B(c0151f.f3900b);
        }
    }

    @Override // L0.AbstractC0157l, L0.AbstractC0146a
    public final void o() {
        super.o();
        this.f3832q = null;
        this.f3831p = null;
    }

    @Override // L0.p0
    public final void y(u0.S s8) {
        if (this.f3832q != null) {
            return;
        }
        B(s8);
    }
}
