package defpackage;

import java.util.AbstractList;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.IdentityHashMap;

/* renamed from: ᵙˉᵟᵫ, reason: contains not printable characters */
/* loaded from: classes3.dex */
public final class C2577 implements InterfaceC3757, InterfaceC1727 {

    /* renamed from: ˀᵗᵝᵭ, reason: contains not printable characters */
    public InterfaceC1727 f10004;

    /* renamed from: ˎˑː, reason: contains not printable characters */
    public C0351 f10005;

    /* renamed from: ˑᵥˁ, reason: contains not printable characters */
    public InterfaceC3757[] f10006;

    /* renamed from: ᵡˎ, reason: contains not printable characters */
    public C0052 f10007;

    /* renamed from: ᵢˇᵭ, reason: contains not printable characters */
    public final boolean[] f10009;

    /* renamed from: ᵧᵾˀˈ, reason: contains not printable characters */
    public final InterfaceC3757[] f10011;

    /* renamed from: ᵾᵬ, reason: contains not printable characters */
    public final ˉːᵡ f10012;

    /* renamed from: ᵿʗᵝʽ, reason: contains not printable characters */
    public final IdentityHashMap f10013;

    /* renamed from: ᵤᵙᵷ, reason: contains not printable characters */
    public final ArrayList f10010 = new ArrayList();

    /* renamed from: ᵡⁱᵥ, reason: contains not printable characters */
    public final HashMap f10008 = new HashMap();

    public C2577(ˉːᵡ r6, long[] jArr, InterfaceC3757... interfaceC3757Arr) {
        this.f10012 = r6;
        this.f10011 = interfaceC3757Arr;
        r6.getClass();
        C4421 c4421 = AbstractC2692.f10429;
        C4471 c4471 = C4471.f16684;
        this.f10005 = new C0351(c4471, c4471);
        this.f10013 = new IdentityHashMap();
        this.f10006 = new InterfaceC3757[0];
        this.f10009 = new boolean[interfaceC3757Arr.length];
        for (int i = 0; i < interfaceC3757Arr.length; i++) {
            long j = jArr[i];
            if (j != 0) {
                this.f10009[i] = true;
                this.f10011[i] = new C0299(interfaceC3757Arr[i], j);
            }
        }
    }

    @Override // defpackage.InterfaceC4532
    /* renamed from: ˇʼʤˎ */
    public final void mo1661(InterfaceC5211 interfaceC5211) {
        InterfaceC1727 interfaceC1727 = this.f10004;
        interfaceC1727.getClass();
        interfaceC1727.mo1661(this);
    }

    @Override // defpackage.InterfaceC3757
    /* renamed from: ˎˏʜʾ */
    public final long mo1662(InterfaceC5264[] interfaceC5264Arr, boolean[] zArr, InterfaceC0772[] interfaceC0772Arr, boolean[] zArr2, long j) {
        IdentityHashMap identityHashMap;
        int[] iArr;
        int[] iArr2 = new int[interfaceC5264Arr.length];
        int[] iArr3 = new int[interfaceC5264Arr.length];
        int i = 0;
        int i2 = 0;
        while (true) {
            int length = interfaceC5264Arr.length;
            identityHashMap = this.f10013;
            if (i2 >= length) {
                break;
            }
            InterfaceC0772 interfaceC0772 = interfaceC0772Arr[i2];
            Integer num = interfaceC0772 == null ? null : (Integer) identityHashMap.get(interfaceC0772);
            iArr2[i2] = num == null ? -1 : num.intValue();
            InterfaceC5264 interfaceC5264 = interfaceC5264Arr[i2];
            if (interfaceC5264 != null) {
                String str = interfaceC5264.mo5375().f15078;
                iArr3[i2] = Integer.parseInt(str.substring(0, str.indexOf(":")));
            } else {
                iArr3[i2] = -1;
            }
            i2++;
        }
        identityHashMap.clear();
        int length2 = interfaceC5264Arr.length;
        InterfaceC0772[] interfaceC0772Arr2 = new InterfaceC0772[length2];
        InterfaceC0772[] interfaceC0772Arr3 = new InterfaceC0772[interfaceC5264Arr.length];
        InterfaceC5264[] interfaceC5264Arr2 = new InterfaceC5264[interfaceC5264Arr.length];
        InterfaceC3757[] interfaceC3757Arr = this.f10011;
        ArrayList arrayList = new ArrayList(interfaceC3757Arr.length);
        long j2 = j;
        int i3 = 0;
        while (i3 < interfaceC3757Arr.length) {
            int i4 = i;
            while (i4 < interfaceC5264Arr.length) {
                interfaceC0772Arr3[i4] = iArr2[i4] == i3 ? interfaceC0772Arr[i4] : null;
                if (iArr3[i4] == i3) {
                    InterfaceC5264 interfaceC52642 = interfaceC5264Arr[i4];
                    interfaceC52642.getClass();
                    iArr = iArr2;
                    C4010 c4010 = (C4010) this.f10008.get(interfaceC52642.mo5375());
                    c4010.getClass();
                    interfaceC5264Arr2[i4] = new C5052(interfaceC52642, c4010);
                } else {
                    iArr = iArr2;
                    interfaceC5264Arr2[i4] = null;
                }
                i4++;
                iArr2 = iArr;
            }
            int[] iArr4 = iArr2;
            InterfaceC3757[] interfaceC3757Arr2 = interfaceC3757Arr;
            int i5 = i3;
            long jMo1662 = interfaceC3757Arr2[i3].mo1662(interfaceC5264Arr2, zArr, interfaceC0772Arr3, zArr2, j2);
            if (i5 == 0) {
                j2 = jMo1662;
            } else if (jMo1662 != j2) {
                ᵹˉᵞ.ᵳٴᵶ("Children enabled at different positions.");
                return 0L;
            }
            boolean z = false;
            for (int i6 = 0; i6 < interfaceC5264Arr.length; i6++) {
                if (iArr3[i6] == i5) {
                    InterfaceC0772 interfaceC07722 = interfaceC0772Arr3[i6];
                    interfaceC07722.getClass();
                    interfaceC0772Arr2[i6] = interfaceC0772Arr3[i6];
                    identityHashMap.put(interfaceC07722, Integer.valueOf(i5));
                    z = true;
                } else if (iArr4[i6] == i5) {
                    ᵛᵾˏ.ᵿʗᵝʽ(interfaceC0772Arr3[i6] == null);
                }
            }
            if (z) {
                arrayList.add(interfaceC3757Arr2[i5]);
            }
            i3 = i5 + 1;
            interfaceC3757Arr = interfaceC3757Arr2;
            iArr2 = iArr4;
            i = 0;
        }
        int i7 = i;
        System.arraycopy(interfaceC0772Arr2, i7, interfaceC0772Arr, i7, length2);
        this.f10006 = (InterfaceC3757[]) arrayList.toArray(new InterfaceC3757[i7]);
        AbstractList abstractList = ˀʾˀᵛ.ᵮᵠـˌ(arrayList, new C2834(14));
        this.f10012.getClass();
        this.f10005 = new C0351(arrayList, abstractList);
        return j2;
    }

    @Override // defpackage.InterfaceC3757
    /* renamed from: ˏᵙ */
    public final long mo1663(long j, C4110 c4110) {
        InterfaceC3757[] interfaceC3757Arr = this.f10006;
        return (interfaceC3757Arr.length > 0 ? interfaceC3757Arr[0] : this.f10011[0]).mo1663(j, c4110);
    }

    @Override // defpackage.InterfaceC5211
    /* renamed from: ˑᵱ */
    public final void mo1664(long j) {
        this.f10005.mo1664(j);
    }

    @Override // defpackage.InterfaceC3757
    /* renamed from: ᵝᵵᵺ */
    public final void mo1665() {
        for (InterfaceC3757 interfaceC3757 : this.f10011) {
            interfaceC3757.mo1665();
        }
    }

    @Override // defpackage.InterfaceC3757
    /* renamed from: ᵡʠ */
    public final C0052 mo1666() {
        C0052 c0052 = this.f10007;
        c0052.getClass();
        return c0052;
    }

    @Override // defpackage.InterfaceC1727
    /* renamed from: ᵥᵯˎ */
    public final void mo1667(InterfaceC3757 interfaceC3757) {
        ArrayList arrayList = this.f10010;
        arrayList.remove(interfaceC3757);
        if (arrayList.isEmpty()) {
            InterfaceC3757[] interfaceC3757Arr = this.f10011;
            int i = 0;
            for (InterfaceC3757 interfaceC37572 : interfaceC3757Arr) {
                i += interfaceC37572.mo1666().f1231;
            }
            C4010[] c4010Arr = new C4010[i];
            int i2 = 0;
            for (int i3 = 0; i3 < interfaceC3757Arr.length; i3++) {
                C0052 c0052Mo1666 = interfaceC3757Arr[i3].mo1666();
                int i4 = c0052Mo1666.f1231;
                int i5 = 0;
                while (i5 < i4) {
                    C4010 c4010M1103 = c0052Mo1666.m1103(i5);
                    int i6 = c4010M1103.f15077;
                    C3446[] c3446Arr = new C3446[i6];
                    int i7 = 0;
                    while (i7 < i6) {
                        C3446 c3446 = c4010M1103.f15079[i7];
                        C2153 c2153M7829 = c3446.m7829();
                        String str = c3446.f12928;
                        InterfaceC3757[] interfaceC3757Arr2 = interfaceC3757Arr;
                        StringBuilder sb = new StringBuilder();
                        sb.append(i3);
                        sb.append(":");
                        String str2 = c3446.f12922;
                        if (str2 == null) {
                            str2 = "";
                        }
                        sb.append(str2);
                        c2153M7829.f8512 = sb.toString();
                        if (str != null) {
                            c2153M7829.f8494 = i3 + ":" + str;
                        }
                        c3446Arr[i7] = new C3446(c2153M7829);
                        i7++;
                        interfaceC3757Arr = interfaceC3757Arr2;
                    }
                    InterfaceC3757[] interfaceC3757Arr3 = interfaceC3757Arr;
                    C4010 c4010 = new C4010(i3 + ":" + c4010M1103.f15078, c3446Arr);
                    this.f10008.put(c4010, c4010M1103);
                    c4010Arr[i2] = c4010;
                    i5++;
                    i2++;
                    interfaceC3757Arr = interfaceC3757Arr3;
                }
            }
            this.f10007 = new C0052(c4010Arr);
            InterfaceC1727 interfaceC1727 = this.f10004;
            interfaceC1727.getClass();
            interfaceC1727.mo1667(this);
        }
    }

    @Override // defpackage.InterfaceC5211
    /* renamed from: ᵨᵳʝ */
    public final long mo1668() {
        return this.f10005.mo1668();
    }

    /* JADX WARN: Code restructure failed: missing block: B:19:0x003f, code lost:
    
        r7 = r10;
     */
    @Override // defpackage.InterfaceC3757
    /* renamed from: ᵪʩ */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public final long mo1669() {
        /*
            r18 = this;
            r0 = r18
            ᵨᵮᵪ[] r1 = r0.f10006
            int r2 = r1.length
            r3 = -9223372036854775807(0x8000000000000001, double:-4.9E-324)
            r5 = 0
            r7 = r3
            r6 = r5
        Ld:
            if (r6 >= r2) goto L66
            r9 = r1[r6]
            long r10 = r9.mo1669()
            int r12 = (r10 > r3 ? 1 : (r10 == r3 ? 0 : -1))
            r13 = 0
            java.lang.String r15 = "Unexpected child seekToUs result."
            if (r12 == 0) goto L4e
            int r12 = (r7 > r3 ? 1 : (r7 == r3 ? 0 : -1))
            if (r12 != 0) goto L41
            ᵨᵮᵪ[] r7 = r0.f10006
            int r8 = r7.length
            r12 = r5
        L25:
            r16 = r3
            if (r12 >= r8) goto L3f
            r3 = r7[r12]
            if (r3 != r9) goto L2e
            goto L3f
        L2e:
            long r3 = r3.mo1672(r10)
            int r3 = (r3 > r10 ? 1 : (r3 == r10 ? 0 : -1))
            if (r3 != 0) goto L3b
            int r12 = r12 + 1
            r3 = r16
            goto L25
        L3b:
            ᵹˉᵞ.ᵳٴᵶ(r15)
            return r13
        L3f:
            r7 = r10
            goto L61
        L41:
            r16 = r3
            int r3 = (r10 > r7 ? 1 : (r10 == r7 ? 0 : -1))
            if (r3 != 0) goto L48
            goto L61
        L48:
            java.lang.String r0 = "Conflicting discontinuities."
            ᵹˉᵞ.ᵳٴᵶ(r0)
            return r13
        L4e:
            r16 = r3
            int r3 = (r7 > r16 ? 1 : (r7 == r16 ? 0 : -1))
            if (r3 == 0) goto L61
            long r3 = r9.mo1672(r7)
            int r3 = (r3 > r7 ? 1 : (r3 == r7 ? 0 : -1))
            if (r3 != 0) goto L5d
            goto L61
        L5d:
            ᵹˉᵞ.ᵳٴᵶ(r15)
            return r13
        L61:
            int r6 = r6 + 1
            r3 = r16
            goto Ld
        L66:
            return r7
        */
        throw new UnsupportedOperationException("Method not decompiled: defpackage.C2577.mo1669():long");
    }

    @Override // defpackage.InterfaceC5211
    /* renamed from: ᵯٴᵦ */
    public final boolean mo1670() {
        return this.f10005.mo1670();
    }

    @Override // defpackage.InterfaceC3757
    /* renamed from: ᵳٴᵶ */
    public final void mo1671(InterfaceC1727 interfaceC1727, long j) {
        this.f10004 = interfaceC1727;
        ArrayList arrayList = this.f10010;
        InterfaceC3757[] interfaceC3757Arr = this.f10011;
        Collections.addAll(arrayList, interfaceC3757Arr);
        for (InterfaceC3757 interfaceC3757 : interfaceC3757Arr) {
            interfaceC3757.mo1671(this, j);
        }
    }

    @Override // defpackage.InterfaceC3757
    /* renamed from: ᵶᵷᵕ */
    public final long mo1672(long j) {
        long jMo1672 = this.f10006[0].mo1672(j);
        int i = 1;
        while (true) {
            InterfaceC3757[] interfaceC3757Arr = this.f10006;
            if (i >= interfaceC3757Arr.length) {
                return jMo1672;
            }
            if (interfaceC3757Arr[i].mo1672(jMo1672) != jMo1672) {
                ᵹˉᵞ.ᵳٴᵶ("Unexpected child seekToUs result.");
                return 0L;
            }
            i++;
        }
    }

    @Override // defpackage.InterfaceC5211
    /* renamed from: ᵸʓᵠ */
    public final boolean mo1673(C5196 c5196) {
        ArrayList arrayList = this.f10010;
        if (arrayList.isEmpty()) {
            return this.f10005.mo1673(c5196);
        }
        int size = arrayList.size();
        for (int i = 0; i < size; i++) {
            ((InterfaceC3757) arrayList.get(i)).mo1673(c5196);
        }
        return false;
    }

    @Override // defpackage.InterfaceC3757
    /* renamed from: ᵸˑ */
    public final void mo1674(long j) {
        for (InterfaceC3757 interfaceC3757 : this.f10006) {
            interfaceC3757.mo1674(j);
        }
    }

    @Override // defpackage.InterfaceC5211
    /* renamed from: ᵹᵝᵶ */
    public final long mo1675() {
        return this.f10005.mo1675();
    }
}
