package G0;

import A1.y;
import C3.A;
import C3.AbstractC0055q;
import C3.G;
import android.net.Uri;
import android.text.TextUtils;
import android.util.Base64;
import d5.AbstractC0844a;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
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.List;
import java.util.Map;
import java.util.TreeMap;
import java.util.UUID;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import u0.AbstractC1569e;
import u0.C1574j;
import u0.C1575k;
import u0.C1578n;
import u0.C1579o;
import u0.D;
import u0.E;
import u0.F;
import x0.AbstractC1709a;
import x0.v;

/* JADX INFO: loaded from: classes.dex */
public final class q implements P0.n {

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

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

    /* JADX INFO: renamed from: s, reason: collision with root package name */
    public static final Pattern f2896s = Pattern.compile("AVERAGE-BANDWIDTH=(\\d+)\\b");

    /* JADX INFO: renamed from: t, reason: collision with root package name */
    public static final Pattern f2898t = Pattern.compile("VIDEO=\"(.+?)\"");

    /* JADX INFO: renamed from: u, reason: collision with root package name */
    public static final Pattern f2900u = Pattern.compile("AUDIO=\"(.+?)\"");

    /* JADX INFO: renamed from: v, reason: collision with root package name */
    public static final Pattern f2902v = Pattern.compile("SUBTITLES=\"(.+?)\"");

    /* JADX INFO: renamed from: w, reason: collision with root package name */
    public static final Pattern f2904w = Pattern.compile("CLOSED-CAPTIONS=\"(.+?)\"");

    /* JADX INFO: renamed from: x, reason: collision with root package name */
    public static final Pattern f2906x = Pattern.compile("[^-]BANDWIDTH=(\\d+)\\b");

    /* JADX INFO: renamed from: y, reason: collision with root package name */
    public static final Pattern f2908y = Pattern.compile("CHANNELS=\"(.+?)\"");

    /* JADX INFO: renamed from: z, reason: collision with root package name */
    public static final Pattern f2910z = Pattern.compile("VIDEO-RANGE=(SDR|PQ|HLG)");

    /* JADX INFO: renamed from: A, reason: collision with root package name */
    public static final Pattern f2847A = Pattern.compile("CODECS=\"(.+?)\"");

    /* JADX INFO: renamed from: B, reason: collision with root package name */
    public static final Pattern f2849B = Pattern.compile("SUPPLEMENTAL-CODECS=\"(.+?)\"");

    /* JADX INFO: renamed from: C, reason: collision with root package name */
    public static final Pattern f2851C = Pattern.compile("RESOLUTION=(\\d+x\\d+)");
    public static final Pattern D = Pattern.compile("FRAME-RATE=([\\d\\.]+)\\b");

    /* JADX INFO: renamed from: E, reason: collision with root package name */
    public static final Pattern f2854E = Pattern.compile("#EXT-X-TARGETDURATION:(\\d+)\\b");

    /* JADX INFO: renamed from: F, reason: collision with root package name */
    public static final Pattern f2856F = Pattern.compile("DURATION=([\\d\\.]+)\\b");

    /* JADX INFO: renamed from: G, reason: collision with root package name */
    public static final Pattern f2858G = Pattern.compile("[:,]DURATION=([\\d\\.]+)\\b");
    public static final Pattern H = Pattern.compile("PART-TARGET=([\\d\\.]+)\\b");

    /* JADX INFO: renamed from: I, reason: collision with root package name */
    public static final Pattern f2861I = Pattern.compile("#EXT-X-VERSION:(\\d+)\\b");

    /* JADX INFO: renamed from: J, reason: collision with root package name */
    public static final Pattern f2863J = Pattern.compile("#EXT-X-PLAYLIST-TYPE:(.+)\\b");

    /* JADX INFO: renamed from: K, reason: collision with root package name */
    public static final Pattern f2864K = Pattern.compile("CAN-SKIP-UNTIL=([\\d\\.]+)\\b");

    /* JADX INFO: renamed from: L, reason: collision with root package name */
    public static final Pattern f2865L = a("CAN-SKIP-DATERANGES");

    /* JADX INFO: renamed from: M, reason: collision with root package name */
    public static final Pattern f2866M = Pattern.compile("SKIPPED-SEGMENTS=(\\d+)\\b");

    /* JADX INFO: renamed from: N, reason: collision with root package name */
    public static final Pattern f2867N = Pattern.compile("[:|,]HOLD-BACK=([\\d\\.]+)\\b");

    /* JADX INFO: renamed from: O, reason: collision with root package name */
    public static final Pattern f2868O = Pattern.compile("PART-HOLD-BACK=([\\d\\.]+)\\b");

    /* JADX INFO: renamed from: P, reason: collision with root package name */
    public static final Pattern f2869P = a("CAN-BLOCK-RELOAD");

    /* JADX INFO: renamed from: Q, reason: collision with root package name */
    public static final Pattern f2870Q = Pattern.compile("#EXT-X-MEDIA-SEQUENCE:(\\d+)\\b");

    /* JADX INFO: renamed from: R, reason: collision with root package name */
    public static final Pattern f2871R = Pattern.compile("#EXTINF:([\\d\\.]+)\\b");

    /* JADX INFO: renamed from: S, reason: collision with root package name */
    public static final Pattern f2872S = Pattern.compile("#EXTINF:[\\d\\.]+\\b,(.+)");

    /* JADX INFO: renamed from: T, reason: collision with root package name */
    public static final Pattern f2873T = Pattern.compile("LAST-MSN=(\\d+)\\b");

    /* JADX INFO: renamed from: U, reason: collision with root package name */
    public static final Pattern f2874U = Pattern.compile("LAST-PART=(\\d+)\\b");

    /* JADX INFO: renamed from: V, reason: collision with root package name */
    public static final Pattern f2875V = Pattern.compile("TIME-OFFSET=(-?[\\d\\.]+)\\b");

    /* JADX INFO: renamed from: W, reason: collision with root package name */
    public static final Pattern f2876W = Pattern.compile("#EXT-X-BYTERANGE:(\\d+(?:@\\d+)?)\\b");
    public static final Pattern X = Pattern.compile("BYTERANGE=\"(\\d+(?:@\\d+)?)\\b\"");

    /* JADX INFO: renamed from: Y, reason: collision with root package name */
    public static final Pattern f2877Y = Pattern.compile("BYTERANGE-START=(\\d+)\\b");

    /* JADX INFO: renamed from: Z, reason: collision with root package name */
    public static final Pattern f2878Z = Pattern.compile("BYTERANGE-LENGTH=(\\d+)\\b");

    /* JADX INFO: renamed from: a0, reason: collision with root package name */
    public static final Pattern f2879a0 = Pattern.compile("METHOD=(NONE|AES-128|SAMPLE-AES|SAMPLE-AES-CENC|SAMPLE-AES-CTR)\\s*(?:,|$)");

    /* JADX INFO: renamed from: b0, reason: collision with root package name */
    public static final Pattern f2880b0 = Pattern.compile("KEYFORMAT=\"(.+?)\"");

    /* JADX INFO: renamed from: c0, reason: collision with root package name */
    public static final Pattern f2881c0 = Pattern.compile("KEYFORMATVERSIONS=\"(.+?)\"");

    /* JADX INFO: renamed from: d0, reason: collision with root package name */
    public static final Pattern f2882d0 = Pattern.compile("URI=\"(.+?)\"");

    /* JADX INFO: renamed from: e0, reason: collision with root package name */
    public static final Pattern f2883e0 = Pattern.compile("IV=([^,.*]+)");

    /* JADX INFO: renamed from: f0, reason: collision with root package name */
    public static final Pattern f2884f0 = Pattern.compile("TYPE=(AUDIO|VIDEO|SUBTITLES|CLOSED-CAPTIONS)");

    /* JADX INFO: renamed from: g0, reason: collision with root package name */
    public static final Pattern f2885g0 = Pattern.compile("TYPE=(PART|MAP)");

    /* JADX INFO: renamed from: h0, reason: collision with root package name */
    public static final Pattern f2886h0 = Pattern.compile("LANGUAGE=\"(.+?)\"");

    /* JADX INFO: renamed from: i0, reason: collision with root package name */
    public static final Pattern f2887i0 = Pattern.compile("NAME=\"(.+?)\"");

    /* JADX INFO: renamed from: j0, reason: collision with root package name */
    public static final Pattern f2888j0 = Pattern.compile("GROUP-ID=\"(.+?)\"");

    /* JADX INFO: renamed from: k0, reason: collision with root package name */
    public static final Pattern f2889k0 = Pattern.compile("CHARACTERISTICS=\"(.+?)\"");

    /* JADX INFO: renamed from: l0, reason: collision with root package name */
    public static final Pattern f2890l0 = Pattern.compile("INSTREAM-ID=\"((?:CC|SERVICE)\\d+)\"");

    /* JADX INFO: renamed from: m0, reason: collision with root package name */
    public static final Pattern f2891m0 = a("AUTOSELECT");

    /* JADX INFO: renamed from: n0, reason: collision with root package name */
    public static final Pattern f2892n0 = a("DEFAULT");

    /* JADX INFO: renamed from: o0, reason: collision with root package name */
    public static final Pattern f2893o0 = a("FORCED");

    /* JADX INFO: renamed from: p0, reason: collision with root package name */
    public static final Pattern f2894p0 = a("INDEPENDENT");
    public static final Pattern q0 = a("GAP");

    /* JADX INFO: renamed from: r0, reason: collision with root package name */
    public static final Pattern f2895r0 = a("PRECISE");

    /* JADX INFO: renamed from: s0, reason: collision with root package name */
    public static final Pattern f2897s0 = Pattern.compile("VALUE=\"(.+?)\"");

    /* JADX INFO: renamed from: t0, reason: collision with root package name */
    public static final Pattern f2899t0 = Pattern.compile("IMPORT=\"(.+?)\"");

    /* JADX INFO: renamed from: u0, reason: collision with root package name */
    public static final Pattern f2901u0 = Pattern.compile("[:,]ID=\"(.+?)\"");

    /* JADX INFO: renamed from: v0, reason: collision with root package name */
    public static final Pattern f2903v0 = Pattern.compile("CLASS=\"(.+?)\"");

    /* JADX INFO: renamed from: w0, reason: collision with root package name */
    public static final Pattern f2905w0 = Pattern.compile("START-DATE=\"(.+?)\"");

    /* JADX INFO: renamed from: x0, reason: collision with root package name */
    public static final Pattern f2907x0 = Pattern.compile("CUE=\"(.+?)\"");

    /* JADX INFO: renamed from: y0, reason: collision with root package name */
    public static final Pattern f2909y0 = Pattern.compile("END-DATE=\"(.+?)\"");

    /* JADX INFO: renamed from: z0, reason: collision with root package name */
    public static final Pattern f2911z0 = Pattern.compile("PLANNED-DURATION=([\\d\\.]+)\\b");

    /* JADX INFO: renamed from: A0, reason: collision with root package name */
    public static final Pattern f2848A0 = a("END-ON-NEXT");

    /* JADX INFO: renamed from: B0, reason: collision with root package name */
    public static final Pattern f2850B0 = Pattern.compile("X-ASSET-URI=\"(.+?)\"");

    /* JADX INFO: renamed from: C0, reason: collision with root package name */
    public static final Pattern f2852C0 = Pattern.compile("X-ASSET-LIST=\"(.+?)\"");

    /* JADX INFO: renamed from: D0, reason: collision with root package name */
    public static final Pattern f2853D0 = Pattern.compile("X-RESUME-OFFSET=(-?[\\d\\.]+)\\b");

    /* JADX INFO: renamed from: E0, reason: collision with root package name */
    public static final Pattern f2855E0 = Pattern.compile("X-PLAYOUT-LIMIT=([\\d\\.]+)\\b");

    /* JADX INFO: renamed from: F0, reason: collision with root package name */
    public static final Pattern f2857F0 = Pattern.compile("X-SNAP=\"(.+?)\"");

    /* JADX INFO: renamed from: G0, reason: collision with root package name */
    public static final Pattern f2859G0 = Pattern.compile("X-RESTRICT=\"(.+?)\"");

    /* JADX INFO: renamed from: H0, reason: collision with root package name */
    public static final Pattern f2860H0 = Pattern.compile("\\{\\$([a-zA-Z0-9\\-_]+)\\}");

    /* JADX INFO: renamed from: I0, reason: collision with root package name */
    public static final Pattern f2862I0 = Pattern.compile("\\b(X-[A-Z0-9-]+)=");

    public q(n nVar, k kVar) {
        this.f2912q = nVar;
        this.f2913r = kVar;
    }

    public static Pattern a(String str) {
        return Pattern.compile(str.concat("=(NO|YES)"));
    }

    public static C1575k b(String str, C1574j[] c1574jArr) {
        C1574j[] c1574jArr2 = new C1574j[c1574jArr.length];
        for (int i = 0; i < c1574jArr.length; i++) {
            C1574j c1574j = c1574jArr[i];
            c1574jArr2[i] = new C1574j(c1574j.f17290r, c1574j.f17291s, c1574j.f17292t, null);
        }
        return new C1575k(str, true, c1574jArr2);
    }

    public static C1574j c(String str, String str2, HashMap map) throws F {
        String strI = i(str, f2881c0, "1", map);
        boolean zEquals = "urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed".equals(str2);
        Pattern pattern = f2882d0;
        if (zEquals) {
            String strJ = j(str, pattern, map);
            return new C1574j(AbstractC1569e.f17275d, null, "video/mp4", Base64.decode(strJ.substring(strJ.indexOf(44)), 0));
        }
        if ("com.widevine".equals(str2)) {
            UUID uuid = AbstractC1569e.f17275d;
            int i = v.f18553a;
            return new C1574j(uuid, null, "hls", str.getBytes(StandardCharsets.UTF_8));
        }
        if (!"com.microsoft.playready".equals(str2) || !"1".equals(strI)) {
            return null;
        }
        String strJ2 = j(str, pattern, map);
        byte[] bArrDecode = Base64.decode(strJ2.substring(strJ2.indexOf(44)), 0);
        UUID uuid2 = AbstractC1569e.f17276e;
        int length = (bArrDecode != null ? bArrDecode.length : 0) + 32;
        ByteBuffer byteBufferAllocate = ByteBuffer.allocate(length);
        byteBufferAllocate.putInt(length);
        byteBufferAllocate.putInt(1886614376);
        byteBufferAllocate.putInt(0);
        byteBufferAllocate.putLong(uuid2.getMostSignificantBits());
        byteBufferAllocate.putLong(uuid2.getLeastSignificantBits());
        if (bArrDecode == null || bArrDecode.length == 0) {
            byteBufferAllocate.putInt(0);
        } else {
            byteBufferAllocate.putInt(bArrDecode.length);
            byteBufferAllocate.put(bArrDecode);
        }
        return new C1574j(uuid2, null, "video/mp4", byteBufferAllocate.array());
    }

    /* JADX WARN: Can't fix incorrect switch cases order, some code will duplicate */
    /* JADX WARN: Code restructure failed: missing block: B:274:0x07c1, code lost:
    
        r29 = r5;
     */
    /* JADX WARN: Code restructure failed: missing block: B:276:0x07c5, code lost:
    
        r29 = r5;
     */
    /* JADX WARN: Code restructure failed: missing block: B:280:0x07d3, code lost:
    
        r29 = r5;
     */
    /* JADX WARN: Code restructure failed: missing block: B:284:0x07e0, code lost:
    
        r29 = r5;
     */
    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Removed duplicated region for block: B:275:0x07c3 A[PHI: r29
      0x07c3: PHI (r29v19 int) = (r29v15 int), (r29v16 int), (r29v17 int), (r29v20 int) binds: [B:285:0x07e8, B:281:0x07db, B:277:0x07cd, B:274:0x07c1] A[DONT_GENERATE, DONT_INLINE]] */
    /* JADX WARN: Removed duplicated region for block: B:337:0x0907  */
    /* JADX WARN: Removed duplicated region for block: B:381:0x0a11  */
    /* JADX WARN: Removed duplicated region for block: B:419:0x0ada  */
    /* JADX WARN: Removed duplicated region for block: B:421:0x0af5  */
    /* JADX WARN: Removed duplicated region for block: B:424:0x0b23  */
    /* JADX WARN: Removed duplicated region for block: B:425:0x0b26  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public static k d(n nVar, k kVar, y yVar, String str) throws F, p {
        ArrayList arrayList;
        TreeMap treeMap;
        String str2;
        C1575k c1575k;
        String str3;
        f fVar;
        long j8;
        String str4;
        int i;
        ArrayList arrayList2;
        j jVar;
        int i5;
        h hVar;
        int i8;
        ArrayList arrayList3;
        h hVar2;
        int i9;
        C1575k c1575kB;
        h hVar3;
        int i10;
        String str5;
        String str6;
        long j9;
        long j10;
        long j11;
        boolean z8;
        long j12;
        String str7;
        String str8;
        ArrayList arrayList4;
        String strGroup;
        ArrayList arrayList5;
        ArrayList arrayList6;
        TreeMap treeMap2;
        String str9;
        d dVar;
        int iF;
        String strTrim;
        int i11;
        long j13;
        C1575k c1575kB2;
        C1575k c1575k2;
        C1575k c1575kB3;
        C1575k c1575k3;
        int i12;
        n nVar2 = nVar;
        k kVar2 = kVar;
        boolean z9 = nVar2.f2846c;
        HashMap map = new HashMap();
        HashMap map2 = new HashMap();
        ArrayList arrayList7 = new ArrayList();
        ArrayList arrayList8 = new ArrayList();
        ArrayList arrayList9 = new ArrayList();
        ArrayList arrayList10 = new ArrayList();
        ArrayList arrayList11 = new ArrayList();
        j jVar2 = new j(-9223372036854775807L, false, -9223372036854775807L, -9223372036854775807L, false);
        TreeMap treeMap3 = new TreeMap();
        int i13 = 0;
        String str10 = "";
        boolean z10 = z9;
        String strI = "";
        long j14 = -9223372036854775807L;
        long j15 = -9223372036854775807L;
        long j16 = -9223372036854775807L;
        long j17 = 0;
        long jL = 0;
        long j18 = 0;
        long j19 = 0;
        long j20 = 0;
        long jLongValue = 0;
        long j21 = 0;
        boolean zF = false;
        int i14 = 0;
        boolean z11 = false;
        int i15 = 0;
        int i16 = 0;
        boolean z12 = false;
        int i17 = 0;
        long j22 = -1;
        int i18 = 1;
        C1575k c1575k4 = null;
        h hVar4 = null;
        C1575k c1575k5 = null;
        String strJ = null;
        String str11 = null;
        f fVar2 = null;
        int i19 = 4;
        String str12 = null;
        long j23 = 0;
        boolean z13 = false;
        while (yVar.u()) {
            String strW = yVar.w();
            if (strW.startsWith("#EXT")) {
                arrayList10.add(strW);
            }
            if (strW.startsWith("#EXT-X-PLAYLIST-TYPE")) {
                String strJ2 = j(strW, f2863J, map);
                if ("VOD".equals(strJ2)) {
                    i15 = 1;
                } else if ("EVENT".equals(strJ2)) {
                    i15 = 2;
                }
            } else if (strW.equals("#EXT-X-I-FRAMES-ONLY")) {
                z12 = true;
            } else if (strW.startsWith("#EXT-X-START")) {
                j14 = (long) (Double.parseDouble(j(strW, f2875V, Collections.EMPTY_MAP)) * 1000000.0d);
                zF = f(strW, f2895r0);
            } else if (strW.startsWith("#EXT-X-SERVER-CONTROL")) {
                boolean z14 = zF;
                double dG = g(strW, f2864K, -9.223372036854776E18d);
                long j24 = dG == -9.223372036854776E18d ? -9223372036854775807L : (long) (dG * 1000000.0d);
                boolean zF2 = f(strW, f2865L);
                double dG2 = g(strW, f2867N, -9.223372036854776E18d);
                long j25 = dG2 == -9.223372036854776E18d ? -9223372036854775807L : (long) (dG2 * 1000000.0d);
                double dG3 = g(strW, f2868O, -9.223372036854776E18d);
                zF = z14;
                jVar2 = new j(j24, zF2, j25, dG3 == -9.223372036854776E18d ? -9223372036854775807L : (long) (dG3 * 1000000.0d), f(strW, f2869P));
            } else {
                boolean z15 = zF;
                if (strW.startsWith("#EXT-X-PART-INF")) {
                    j16 = (long) (Double.parseDouble(j(strW, H, Collections.EMPTY_MAP)) * 1000000.0d);
                    zF = z15;
                } else {
                    boolean zStartsWith = strW.startsWith("#EXT-X-MAP");
                    Pattern pattern = X;
                    Pattern pattern2 = f2882d0;
                    if (zStartsWith) {
                        String strJ3 = j(strW, pattern2, map);
                        String strI2 = i(strW, pattern, null, map);
                        if (strI2 != null) {
                            int i20 = v.f18553a;
                            String[] strArrSplit = strI2.split("@", -1);
                            j22 = Long.parseLong(strArrSplit[i13]);
                            if (strArrSplit.length > 1) {
                                j19 = Long.parseLong(strArrSplit[1]);
                            }
                        }
                        long j26 = j22;
                        if (j26 == -1) {
                            j19 = 0;
                        }
                        if (strJ != null && str11 == null) {
                            throw F.b("The encryption IV attribute must be present when an initialization segment is encrypted with METHOD=AES-128.");
                        }
                        String str13 = strJ;
                        h hVar5 = new h(strJ3, j19, j26, str13, str11);
                        strJ = str13;
                        String str14 = str11;
                        if (j26 != -1) {
                            j19 += j26;
                        }
                        j22 = -1;
                        hVar4 = hVar5;
                        zF = z15;
                        str11 = str14;
                    } else {
                        ArrayList arrayList12 = arrayList10;
                        String str15 = str11;
                        ArrayList arrayList13 = arrayList11;
                        if (strW.startsWith("#EXT-X-TARGETDURATION")) {
                            j15 = ((long) Integer.parseInt(j(strW, f2854E, Collections.EMPTY_MAP))) * 1000000;
                        } else if (strW.startsWith("#EXT-X-MEDIA-SEQUENCE")) {
                            j18 = Long.parseLong(j(strW, f2870Q, Collections.EMPTY_MAP));
                            j23 = j18;
                        } else if (strW.startsWith("#EXT-X-VERSION")) {
                            i18 = Integer.parseInt(j(strW, f2861I, Collections.EMPTY_MAP));
                        } else {
                            if (strW.startsWith("#EXT-X-DEFINE")) {
                                String strI3 = i(strW, f2899t0, null, map);
                                if (strI3 != null) {
                                    String str16 = (String) nVar2.f2842j.get(strI3);
                                    if (str16 != null) {
                                        map.put(strI3, str16);
                                    }
                                } else {
                                    map.put(j(strW, f2887i0, map), j(strW, f2897s0, map));
                                }
                                arrayList = arrayList8;
                                treeMap = treeMap3;
                                str2 = str10;
                                c1575k = c1575k5;
                                str3 = strJ;
                                fVar = fVar2;
                                j8 = j22;
                                str4 = str12;
                                i = i17;
                                arrayList2 = arrayList13;
                                jVar = jVar2;
                                i5 = i13;
                            } else if (strW.startsWith("#EXTINF")) {
                                jLongValue = new BigDecimal(j(strW, f2871R, Collections.EMPTY_MAP)).multiply(new BigDecimal(1000000L)).longValue();
                                strI = i(strW, f2872S, str10, map);
                            } else {
                                if (strW.startsWith("#EXT-X-SKIP")) {
                                    int i21 = Integer.parseInt(j(strW, f2866M, Collections.EMPTY_MAP));
                                    AbstractC1709a.j((kVar2 == null || !arrayList7.isEmpty()) ? i13 : 1);
                                    int i22 = v.f18553a;
                                    int i23 = (int) (j23 - kVar2.f2814k);
                                    int i24 = i21 + i23;
                                    if (i23 >= 0) {
                                        G g8 = kVar2.f2821r;
                                        if (i24 <= g8.size()) {
                                            long j27 = j20;
                                            str11 = str15;
                                            while (i23 < i24) {
                                                h hVar6 = (h) g8.get(i23);
                                                if (j23 != kVar2.f2814k) {
                                                    int i25 = (kVar2.f2813j - i14) + hVar6.f2796t;
                                                    ArrayList arrayList14 = new ArrayList();
                                                    int i26 = i13;
                                                    long j28 = j27;
                                                    while (true) {
                                                        G g9 = hVar6.f2791C;
                                                        if (i26 < g9.size()) {
                                                            f fVar3 = (f) g9.get(i26);
                                                            arrayList14.add(new f(fVar3.f2793q, fVar3.f2794r, fVar3.f2795s, i25, j28, fVar3.f2798v, fVar3.f2799w, fVar3.f2800x, fVar3.f2801y, fVar3.f2802z, fVar3.f2792A, fVar3.f2785B, fVar3.f2786C));
                                                            j28 += fVar3.f2795s;
                                                            i26++;
                                                            i24 = i24;
                                                        } else {
                                                            i12 = i24;
                                                            hVar6 = new h(hVar6.f2793q, hVar6.f2794r, hVar6.f2790B, hVar6.f2795s, i25, j27, hVar6.f2798v, hVar6.f2799w, hVar6.f2800x, hVar6.f2801y, hVar6.f2802z, hVar6.f2792A, arrayList14);
                                                        }
                                                    }
                                                } else {
                                                    i12 = i24;
                                                }
                                                arrayList7.add(hVar6);
                                                j27 += hVar6.f2795s;
                                                long j29 = hVar6.f2802z;
                                                if (j29 != -1) {
                                                    j19 = hVar6.f2801y + j29;
                                                }
                                                String str17 = hVar6.f2800x;
                                                if (str17 == null || !str17.equals(Long.toHexString(j18))) {
                                                    str11 = str17;
                                                }
                                                j18++;
                                                i23++;
                                                i16 = hVar6.f2796t;
                                                hVar4 = hVar6.f2794r;
                                                c1575k4 = hVar6.f2798v;
                                                strJ = hVar6.f2799w;
                                                i24 = i12;
                                                j17 = j27;
                                                kVar2 = kVar;
                                            }
                                            nVar2 = nVar;
                                            kVar2 = kVar;
                                            zF = z15;
                                            arrayList10 = arrayList12;
                                            arrayList11 = arrayList13;
                                            j20 = j27;
                                        }
                                    }
                                    throw new p();
                                }
                                if (strW.startsWith("#EXT-X-KEY")) {
                                    String strJ4 = j(strW, f2879a0, map);
                                    String strI4 = i(strW, f2880b0, "identity", map);
                                    if ("NONE".equals(strJ4)) {
                                        treeMap3.clear();
                                        c1575k4 = null;
                                        strJ = null;
                                        str11 = null;
                                    } else {
                                        String strI5 = i(strW, f2883e0, null, map);
                                        if (!"identity".equals(strI4)) {
                                            String str18 = str12;
                                            str12 = str18 == null ? ("SAMPLE-AES-CENC".equals(strJ4) || "SAMPLE-AES-CTR".equals(strJ4)) ? "cenc" : "cbcs" : str18;
                                            C1574j c1574jC = c(strW, strI4, map);
                                            if (c1574jC != null) {
                                                treeMap3.put(strI4, c1574jC);
                                                str11 = strI5;
                                                c1575k4 = null;
                                            }
                                            strJ = null;
                                        } else if ("AES-128".equals(strJ4)) {
                                            strJ = j(strW, pattern2, map);
                                            str11 = strI5;
                                        }
                                        str11 = strI5;
                                        strJ = null;
                                    }
                                    nVar2 = nVar;
                                    kVar2 = kVar;
                                    zF = z15;
                                    arrayList10 = arrayList12;
                                    arrayList11 = arrayList13;
                                } else {
                                    str4 = str12;
                                    if (strW.startsWith("#EXT-X-BYTERANGE")) {
                                        String strJ5 = j(strW, f2876W, map);
                                        int i27 = v.f18553a;
                                        String[] strArrSplit2 = strJ5.split("@", -1);
                                        j22 = Long.parseLong(strArrSplit2[i13]);
                                        if (strArrSplit2.length > 1) {
                                            j19 = Long.parseLong(strArrSplit2[1]);
                                        }
                                    } else if (strW.startsWith("#EXT-X-DISCONTINUITY-SEQUENCE")) {
                                        i14 = Integer.parseInt(strW.substring(strW.indexOf(58) + 1));
                                        nVar2 = nVar;
                                        kVar2 = kVar;
                                        str12 = str4;
                                        z11 = true;
                                    } else if (strW.equals("#EXT-X-DISCONTINUITY")) {
                                        i16++;
                                    } else {
                                        if (strW.startsWith("#EXT-X-PROGRAM-DATE-TIME")) {
                                            if (jL == 0) {
                                                jL = v.L(v.O(strW.substring(strW.indexOf(58) + 1))) - j20;
                                            }
                                        } else if (strW.equals("#EXT-X-GAP")) {
                                            nVar2 = nVar;
                                            kVar2 = kVar;
                                            str12 = str4;
                                            zF = z15;
                                            str11 = str15;
                                            arrayList10 = arrayList12;
                                            arrayList11 = arrayList13;
                                            i17 = 1;
                                        } else if (strW.equals("#EXT-X-INDEPENDENT-SEGMENTS")) {
                                            nVar2 = nVar;
                                            kVar2 = kVar;
                                            str12 = str4;
                                            zF = z15;
                                            str11 = str15;
                                            arrayList10 = arrayList12;
                                            arrayList11 = arrayList13;
                                            z10 = true;
                                        } else if (strW.equals("#EXT-X-ENDLIST")) {
                                            nVar2 = nVar;
                                            kVar2 = kVar;
                                            str12 = str4;
                                            zF = z15;
                                            str11 = str15;
                                            arrayList10 = arrayList12;
                                            arrayList11 = arrayList13;
                                            z13 = true;
                                        } else if (strW.startsWith("#EXT-X-RENDITION-REPORT")) {
                                            long jH = h(strW, f2873T);
                                            Matcher matcher = f2874U.matcher(strW);
                                            if (matcher.find()) {
                                                String strGroup2 = matcher.group(1);
                                                strGroup2.getClass();
                                                i8 = Integer.parseInt(strGroup2);
                                            } else {
                                                i8 = -1;
                                            }
                                            arrayList9.add(new g(Uri.parse(AbstractC1709a.y(str, j(strW, pattern2, map))), jH, i8));
                                        } else {
                                            if (strW.startsWith("#EXT-X-PRELOAD-HINT")) {
                                                fVar = fVar2;
                                                if (fVar == null && "PART".equals(j(strW, f2885g0, map))) {
                                                    C1575k c1575k6 = c1575k5;
                                                    h hVar7 = hVar4;
                                                    String strJ6 = j(strW, pattern2, map);
                                                    long jH2 = h(strW, f2877Y);
                                                    long jH3 = h(strW, f2878Z);
                                                    String hexString = strJ == null ? null : str15 != null ? str15 : Long.toHexString(j18);
                                                    if (c1575k4 != null || treeMap3.isEmpty()) {
                                                        c1575kB3 = c1575k6;
                                                        c1575k3 = c1575k4;
                                                    } else {
                                                        C1574j[] c1574jArr = (C1574j[]) treeMap3.values().toArray(new C1574j[i13]);
                                                        C1575k c1575k7 = new C1575k(str4, true, c1574jArr);
                                                        c1575kB3 = c1575k6 == null ? b(str4, c1574jArr) : c1575k6;
                                                        c1575k3 = c1575k7;
                                                    }
                                                    if (jH2 == -1 || jH3 != -1) {
                                                        long j30 = j17;
                                                        j17 = j30;
                                                        fVar2 = new f(strJ6, hVar7, 0L, i16, j30, c1575k3, strJ, hexString, jH2 != -1 ? jH2 : 0L, jH3, false, false, true);
                                                    } else {
                                                        fVar2 = fVar;
                                                    }
                                                    nVar2 = nVar;
                                                    str12 = str4;
                                                    hVar4 = hVar7;
                                                    c1575k4 = c1575k3;
                                                    zF = z15;
                                                    str11 = str15;
                                                    arrayList10 = arrayList12;
                                                    arrayList11 = arrayList13;
                                                    i13 = 0;
                                                    c1575k5 = c1575kB3;
                                                    kVar2 = kVar;
                                                } else {
                                                    arrayList = arrayList8;
                                                    jVar = jVar2;
                                                    treeMap = treeMap3;
                                                    str2 = str10;
                                                    i5 = i13;
                                                    hVar = hVar4;
                                                    c1575k = c1575k5;
                                                    str3 = strJ;
                                                    j8 = j22;
                                                    i = i17;
                                                    arrayList2 = arrayList13;
                                                }
                                            } else {
                                                c1575k = c1575k5;
                                                fVar = fVar2;
                                                h hVar8 = hVar4;
                                                if (strW.startsWith("#EXT-X-PART")) {
                                                    String hexString2 = strJ == null ? null : str15 != null ? str15 : Long.toHexString(j18);
                                                    String strJ7 = j(strW, pattern2, map);
                                                    long j31 = (long) (Double.parseDouble(j(strW, f2856F, Collections.EMPTY_MAP)) * 1000000.0d);
                                                    boolean zF3 = f(strW, f2894p0) | (z10 && arrayList8.isEmpty());
                                                    boolean zF4 = f(strW, q0);
                                                    String strI6 = i(strW, pattern, null, map);
                                                    if (strI6 != null) {
                                                        int i28 = v.f18553a;
                                                        String[] strArrSplit3 = strI6.split("@", -1);
                                                        long j32 = Long.parseLong(strArrSplit3[0]);
                                                        if (strArrSplit3.length > 1) {
                                                            j21 = Long.parseLong(strArrSplit3[1]);
                                                        }
                                                        j13 = j32;
                                                    } else {
                                                        j13 = -1;
                                                    }
                                                    long j33 = j13 == -1 ? 0L : j21;
                                                    if (c1575k4 != null || treeMap3.isEmpty()) {
                                                        c1575kB2 = c1575k;
                                                        c1575k2 = c1575k4;
                                                    } else {
                                                        C1574j[] c1574jArr2 = (C1574j[]) treeMap3.values().toArray(new C1574j[0]);
                                                        C1575k c1575k8 = new C1575k(str4, true, c1574jArr2);
                                                        c1575kB2 = c1575k == null ? b(str4, c1574jArr2) : c1575k;
                                                        c1575k2 = c1575k8;
                                                    }
                                                    long j34 = j17;
                                                    arrayList8.add(new f(strJ7, hVar8, j31, i16, j34, c1575k2, strJ, hexString2, j33, j13, zF4, zF3, false));
                                                    j17 = j34 + j31;
                                                    if (j13 != -1) {
                                                        j33 += j13;
                                                    }
                                                    j21 = j33;
                                                    kVar2 = kVar;
                                                    fVar2 = fVar;
                                                    c1575k5 = c1575kB2;
                                                    hVar4 = hVar8;
                                                    str12 = str4;
                                                    c1575k4 = c1575k2;
                                                    zF = z15;
                                                    str11 = str15;
                                                    arrayList10 = arrayList12;
                                                    arrayList11 = arrayList13;
                                                    i13 = 0;
                                                    nVar2 = nVar;
                                                } else {
                                                    if (strW.startsWith("#EXT-X-DATERANGE") && i(strW, f2903v0, str10, map).equals("com.apple.hls.interstitial")) {
                                                        String strJ8 = j(strW, f2901u0, map);
                                                        String strI7 = i(strW, f2850B0, null, map);
                                                        Uri uri = strI7 != null ? Uri.parse(strI7) : null;
                                                        String strI8 = i(strW, f2852C0, null, map);
                                                        Uri uri2 = strI8 != null ? Uri.parse(strI8) : null;
                                                        long jL2 = v.L(v.O(j(strW, f2905w0, map)));
                                                        String strI9 = i(strW, f2909y0, null, map);
                                                        long jL3 = strI9 != null ? v.L(v.O(strI9)) : -9223372036854775807L;
                                                        ArrayList arrayList15 = new ArrayList();
                                                        String strI10 = i(strW, f2907x0, null, map);
                                                        hVar = hVar8;
                                                        if (strI10 != null) {
                                                            String[] strArrSplit4 = strI10.split(",", -1);
                                                            int length = strArrSplit4.length;
                                                            int i29 = 0;
                                                            while (i29 < length) {
                                                                int i30 = length;
                                                                strTrim = strArrSplit4[i29].trim();
                                                                strTrim.getClass();
                                                                switch (strTrim) {
                                                                    case "PRE":
                                                                    case "ONCE":
                                                                    case "POST":
                                                                        arrayList15.add(strTrim);
                                                                        break;
                                                                }
                                                                i29 = i11 + 1;
                                                                length = i30;
                                                            }
                                                        }
                                                        j jVar3 = jVar2;
                                                        double dG4 = g(strW, f2858G, -1.0d);
                                                        long j35 = dG4 >= 0.0d ? (long) (dG4 * 1000000.0d) : -9223372036854775807L;
                                                        double dG5 = g(strW, f2911z0, -1.0d);
                                                        long j36 = dG5 >= 0.0d ? (long) (dG5 * 1000000.0d) : -9223372036854775807L;
                                                        boolean zF5 = f(strW, f2848A0);
                                                        double dG6 = g(strW, f2853D0, Double.MIN_VALUE);
                                                        long j37 = dG6 != Double.MIN_VALUE ? (long) (dG6 * 1000000.0d) : -9223372036854775807L;
                                                        double dG7 = g(strW, f2855E0, -1.0d);
                                                        long j38 = dG7 >= 0.0d ? (long) (dG7 * 1000000.0d) : -9223372036854775807L;
                                                        ArrayList arrayList16 = new ArrayList();
                                                        String strI11 = i(strW, f2857F0, null, map);
                                                        if (strI11 != null) {
                                                            String[] strArrSplit5 = strI11.split(",", -1);
                                                            int length2 = strArrSplit5.length;
                                                            arrayList4 = arrayList15;
                                                            int i31 = 0;
                                                            while (i31 < length2) {
                                                                int i32 = i31;
                                                                String strTrim2 = strArrSplit5[i31].trim();
                                                                strTrim2.getClass();
                                                                j jVar4 = jVar3;
                                                                if (strTrim2.equals("IN") || strTrim2.equals("OUT")) {
                                                                    arrayList16.add(strTrim2);
                                                                }
                                                                i31 = i32 + 1;
                                                                jVar3 = jVar4;
                                                            }
                                                        } else {
                                                            arrayList4 = arrayList15;
                                                        }
                                                        jVar = jVar3;
                                                        ArrayList arrayList17 = new ArrayList();
                                                        String strI12 = i(strW, f2859G0, null, map);
                                                        if (strI12 != null) {
                                                            String[] strArrSplit6 = strI12.split(",", -1);
                                                            int length3 = strArrSplit6.length;
                                                            int i33 = 0;
                                                            while (i33 < length3) {
                                                                String strTrim3 = strArrSplit6[i33].trim();
                                                                strTrim3.getClass();
                                                                String[] strArr = strArrSplit6;
                                                                if (strTrim3.equals("JUMP") || strTrim3.equals("SKIP")) {
                                                                    arrayList17.add(strTrim3);
                                                                }
                                                                i33++;
                                                                strArrSplit6 = strArr;
                                                            }
                                                        }
                                                        int i34 = i19;
                                                        AbstractC0055q.c(i34, "initialCapacity");
                                                        Object[] objArrCopyOf = new Object[i34];
                                                        String strSubstring = strW.substring(17);
                                                        Matcher matcher2 = f2862I0.matcher(strSubstring);
                                                        int i35 = 0;
                                                        while (matcher2.find()) {
                                                            strGroup = matcher2.group();
                                                            strGroup.getClass();
                                                            ArrayList arrayList18 = arrayList17;
                                                            switch (strGroup) {
                                                                case "X-SNAP=":
                                                                case "X-PLAYOUT-LIMIT=":
                                                                case "X-ASSET-LIST=":
                                                                case "X-RESTRICT=":
                                                                case "X-RESUME-OFFSET=":
                                                                case "X-ASSET-URI=":
                                                                    arrayList5 = arrayList16;
                                                                    arrayList6 = arrayList8;
                                                                    treeMap2 = treeMap3;
                                                                    str9 = str10;
                                                                    break;
                                                                default:
                                                                    arrayList5 = arrayList16;
                                                                    String strSubstring2 = strGroup.substring(0, strGroup.length() - 1);
                                                                    String strL = AbstractC0844a.l(strSubstring2, "=");
                                                                    int length4 = strL.length() + strSubstring.indexOf(strL);
                                                                    arrayList6 = arrayList8;
                                                                    String strSubstring3 = strSubstring.substring(length4, (strSubstring.length() == length4 + 1 ? 1 : 2) + length4);
                                                                    if (!strSubstring3.startsWith("\"")) {
                                                                        if (strSubstring3.equals("0x") || strSubstring3.equals("0X")) {
                                                                            treeMap2 = treeMap3;
                                                                            str9 = str10;
                                                                            dVar = new d(1, strSubstring2, j(strSubstring, Pattern.compile(strSubstring2 + "=(0[xX][A-F0-9]+)"), map));
                                                                            int i36 = i35 + 1;
                                                                            iF = A.f(objArrCopyOf.length, i36);
                                                                            if (iF > objArrCopyOf.length) {
                                                                                objArrCopyOf = Arrays.copyOf(objArrCopyOf, iF);
                                                                            }
                                                                            objArrCopyOf[i35] = dVar;
                                                                            i35 = i36;
                                                                        } else {
                                                                            treeMap2 = treeMap3;
                                                                            str9 = str10;
                                                                            dVar = new d(strSubstring2, Double.parseDouble(j(strSubstring, Pattern.compile(strSubstring2 + "=([\\d\\.]+)\\b"), Collections.EMPTY_MAP)));
                                                                        }
                                                                        break;
                                                                    } else {
                                                                        dVar = new d(0, strSubstring2, j(strSubstring, Pattern.compile(strSubstring2 + "=\"(.+?)\""), map));
                                                                        treeMap2 = treeMap3;
                                                                        str9 = str10;
                                                                    }
                                                                    int i362 = i35 + 1;
                                                                    iF = A.f(objArrCopyOf.length, i362);
                                                                    if (iF > objArrCopyOf.length) {
                                                                    }
                                                                    objArrCopyOf[i35] = dVar;
                                                                    i35 = i362;
                                                                    break;
                                                            }
                                                            treeMap3 = treeMap2;
                                                            arrayList8 = arrayList6;
                                                            arrayList16 = arrayList5;
                                                            arrayList17 = arrayList18;
                                                            str10 = str9;
                                                        }
                                                        ArrayList arrayList19 = arrayList17;
                                                        ArrayList arrayList20 = arrayList16;
                                                        arrayList3 = arrayList8;
                                                        treeMap = treeMap3;
                                                        str2 = str10;
                                                        if ((uri2 != null || uri == null) && (uri2 == null || uri != null)) {
                                                            arrayList2 = arrayList13;
                                                        } else {
                                                            arrayList2 = arrayList13;
                                                            arrayList2.add(new e(strJ8, uri, uri2, jL2, jL3, j35, j36, arrayList4, zF5, j37, j38, arrayList20, arrayList19, G.i(i35, objArrCopyOf)));
                                                        }
                                                    } else {
                                                        hVar = hVar8;
                                                        arrayList3 = arrayList8;
                                                        jVar = jVar2;
                                                        treeMap = treeMap3;
                                                        str2 = str10;
                                                        arrayList2 = arrayList13;
                                                        if (!strW.startsWith("#")) {
                                                            String hexString3 = strJ == null ? null : str15 != null ? str15 : Long.toHexString(j18);
                                                            long j39 = j18 + 1;
                                                            String strK = k(strW, map);
                                                            h hVar9 = (h) map2.get(strK);
                                                            if (j22 == -1) {
                                                                hVar2 = hVar9;
                                                                j19 = 0;
                                                            } else {
                                                                if (z12 && hVar == null && hVar9 == null) {
                                                                    hVar9 = new h(strK, 0L, j19, null, null);
                                                                    map2.put(strK, hVar9);
                                                                }
                                                                hVar2 = hVar9;
                                                            }
                                                            if (c1575k4 != null || treeMap.isEmpty()) {
                                                                i9 = 0;
                                                            } else {
                                                                i9 = 0;
                                                                C1574j[] c1574jArr3 = (C1574j[]) treeMap.values().toArray(new C1574j[0]);
                                                                C1575k c1575k9 = new C1575k(str4, true, c1574jArr3);
                                                                if (c1575k == null) {
                                                                    c1575kB = b(str4, c1574jArr3);
                                                                    c1575k4 = c1575k9;
                                                                    if (hVar == null) {
                                                                        hVar3 = hVar;
                                                                        str8 = strK;
                                                                        i10 = i16;
                                                                        str5 = strJ;
                                                                        str6 = hexString3;
                                                                        j9 = j22;
                                                                        j10 = j19;
                                                                        j11 = j20;
                                                                        z8 = i17;
                                                                        j12 = jLongValue;
                                                                        str7 = strI;
                                                                    } else {
                                                                        hVar3 = hVar2;
                                                                        i10 = i16;
                                                                        str5 = strJ;
                                                                        str6 = hexString3;
                                                                        j9 = j22;
                                                                        j10 = j19;
                                                                        j11 = j20;
                                                                        z8 = i17;
                                                                        j12 = jLongValue;
                                                                        str7 = strI;
                                                                        str8 = strK;
                                                                    }
                                                                    C1575k c1575k10 = c1575k4;
                                                                    i16 = i10;
                                                                    arrayList7.add(new h(str8, hVar3, str7, j12, i10, j11, c1575k10, str5, str6, j10, j9, z8, arrayList3));
                                                                    j17 = j11 + j12;
                                                                    arrayList = new ArrayList();
                                                                    j19 = j22 == -1 ? j10 + j9 : j10;
                                                                    arrayList11 = arrayList2;
                                                                    c1575k5 = c1575kB;
                                                                    j18 = j39;
                                                                    treeMap3 = treeMap;
                                                                    i13 = i9;
                                                                    i17 = i13;
                                                                    j22 = -1;
                                                                    j20 = j17;
                                                                    c1575k4 = c1575k10;
                                                                    strJ = str5;
                                                                    jLongValue = 0;
                                                                    hVar4 = hVar;
                                                                    jVar2 = jVar;
                                                                    zF = z15;
                                                                    str11 = str15;
                                                                    str10 = str2;
                                                                    strI = str10;
                                                                    i19 = 4;
                                                                    kVar2 = kVar;
                                                                    fVar2 = fVar;
                                                                    arrayList8 = arrayList;
                                                                    str12 = str4;
                                                                    arrayList10 = arrayList12;
                                                                    nVar2 = nVar;
                                                                } else {
                                                                    c1575k4 = c1575k9;
                                                                }
                                                            }
                                                            c1575kB = c1575k;
                                                            if (hVar == null) {
                                                            }
                                                            C1575k c1575k102 = c1575k4;
                                                            i16 = i10;
                                                            arrayList7.add(new h(str8, hVar3, str7, j12, i10, j11, c1575k102, str5, str6, j10, j9, z8, arrayList3));
                                                            j17 = j11 + j12;
                                                            arrayList = new ArrayList();
                                                            if (j22 == -1) {
                                                            }
                                                            arrayList11 = arrayList2;
                                                            c1575k5 = c1575kB;
                                                            j18 = j39;
                                                            treeMap3 = treeMap;
                                                            i13 = i9;
                                                            i17 = i13;
                                                            j22 = -1;
                                                            j20 = j17;
                                                            c1575k4 = c1575k102;
                                                            strJ = str5;
                                                            jLongValue = 0;
                                                            hVar4 = hVar;
                                                            jVar2 = jVar;
                                                            zF = z15;
                                                            str11 = str15;
                                                            str10 = str2;
                                                            strI = str10;
                                                            i19 = 4;
                                                            kVar2 = kVar;
                                                            fVar2 = fVar;
                                                            arrayList8 = arrayList;
                                                            str12 = str4;
                                                            arrayList10 = arrayList12;
                                                            nVar2 = nVar;
                                                        }
                                                    }
                                                    str3 = strJ;
                                                    arrayList = arrayList3;
                                                    j8 = j22;
                                                    i = i17;
                                                    i5 = 0;
                                                }
                                            }
                                            arrayList11 = arrayList2;
                                            treeMap3 = treeMap;
                                            i13 = i5;
                                            c1575k5 = c1575k;
                                            strJ = str3;
                                            j22 = j8;
                                            i17 = i;
                                            hVar4 = hVar;
                                            jVar2 = jVar;
                                            zF = z15;
                                            str11 = str15;
                                            str10 = str2;
                                            i19 = 4;
                                            kVar2 = kVar;
                                            fVar2 = fVar;
                                            arrayList8 = arrayList;
                                            str12 = str4;
                                            arrayList10 = arrayList12;
                                            nVar2 = nVar;
                                        }
                                        arrayList = arrayList8;
                                        jVar = jVar2;
                                        treeMap = treeMap3;
                                        str2 = str10;
                                        i5 = i13;
                                        c1575k = c1575k5;
                                        str3 = strJ;
                                        fVar = fVar2;
                                        j8 = j22;
                                        i = i17;
                                        arrayList2 = arrayList13;
                                    }
                                    nVar2 = nVar;
                                    kVar2 = kVar;
                                    str12 = str4;
                                }
                            }
                            hVar = hVar4;
                            arrayList11 = arrayList2;
                            treeMap3 = treeMap;
                            i13 = i5;
                            c1575k5 = c1575k;
                            strJ = str3;
                            j22 = j8;
                            i17 = i;
                            hVar4 = hVar;
                            jVar2 = jVar;
                            zF = z15;
                            str11 = str15;
                            str10 = str2;
                            i19 = 4;
                            kVar2 = kVar;
                            fVar2 = fVar;
                            arrayList8 = arrayList;
                            str12 = str4;
                            arrayList10 = arrayList12;
                            nVar2 = nVar;
                        }
                        zF = z15;
                        str11 = str15;
                        arrayList10 = arrayList12;
                        arrayList11 = arrayList13;
                    }
                }
            }
        }
        boolean z16 = zF;
        ArrayList arrayList21 = arrayList8;
        ArrayList arrayList22 = arrayList10;
        ArrayList arrayList23 = arrayList11;
        j jVar5 = jVar2;
        int i37 = i13;
        C1575k c1575k11 = c1575k5;
        f fVar4 = fVar2;
        HashMap map3 = new HashMap();
        for (int i38 = i37; i38 < arrayList9.size(); i38++) {
            g gVar = (g) arrayList9.get(i38);
            long size = gVar.f2788b;
            if (size == -1) {
                size = (j23 + ((long) arrayList7.size())) - (arrayList21.isEmpty() ? 1L : 0L);
            }
            int size2 = gVar.f2789c;
            if (size2 == -1 && j16 != -9223372036854775807L) {
                size2 = (arrayList21.isEmpty() ? ((h) AbstractC0055q.h(arrayList7)).f2791C : arrayList21).size() - 1;
            }
            Uri uri3 = gVar.f2787a;
            map3.put(uri3, new g(uri3, size, size2));
        }
        if (fVar4 != null) {
            arrayList21.add(fVar4);
        }
        return new k(i15, str, arrayList22, j14, z16, jL, z11, i14, j23, i18, j15, j16, z10, z13, jL != 0 ? 1 : i37, c1575k11, arrayList7, arrayList21, jVar5, map3, arrayList23);
    }

    /* JADX WARN: Can't fix incorrect switch cases order, some code will duplicate */
    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Removed duplicated region for block: B:106:0x022c  */
    /* JADX WARN: Removed duplicated region for block: B:120:0x026a  */
    /* JADX WARN: Removed duplicated region for block: B:121:0x027e  */
    /* JADX WARN: Removed duplicated region for block: B:125:0x028b  */
    /* JADX WARN: Removed duplicated region for block: B:128:0x02a4  */
    /* JADX WARN: Removed duplicated region for block: B:192:0x04c6  */
    /* JADX WARN: Removed duplicated region for block: B:53:0x017d  */
    /* JADX WARN: Removed duplicated region for block: B:54:0x0181  */
    /* JADX WARN: Type inference failed for: r2v57 */
    /* JADX WARN: Type inference failed for: r2v58 */
    /* JADX WARN: Type inference failed for: r2v9 */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public static n e(y yVar, String str) throws IOException {
        String str2;
        String strJ;
        String strJ2;
        C1578n c1578n;
        int i;
        String str3;
        Uri uriZ;
        D d8;
        ArrayList arrayList;
        m mVar;
        String strD;
        ArrayList arrayList2;
        int i5;
        String str4;
        m mVar2;
        String strD2;
        m mVar3;
        HashMap map;
        ArrayList arrayList3;
        ArrayList arrayList4;
        int i8;
        ArrayList arrayList5;
        ArrayList arrayList6;
        ArrayList arrayList7;
        ArrayList arrayList8;
        int i9;
        String str5;
        String str6;
        String strU;
        String str7;
        String string;
        String str8;
        String strI;
        Uri uriZ2;
        String str9 = str;
        HashMap map2 = new HashMap();
        HashMap map3 = new HashMap();
        ArrayList arrayList9 = new ArrayList();
        ArrayList arrayList10 = new ArrayList();
        ArrayList arrayList11 = new ArrayList();
        ArrayList arrayList12 = new ArrayList();
        ArrayList arrayList13 = new ArrayList();
        ArrayList arrayList14 = new ArrayList();
        ArrayList arrayList15 = new ArrayList();
        ArrayList arrayList16 = new ArrayList();
        boolean z8 = false;
        boolean zContains = false;
        while (true) {
            boolean zU = yVar.u();
            Pattern pattern = f2882d0;
            Pattern pattern2 = f2887i0;
            String str10 = ",";
            if (!zU) {
                ArrayList arrayList17 = arrayList10;
                ArrayList arrayList18 = arrayList11;
                ArrayList arrayList19 = arrayList12;
                boolean z9 = z8;
                ArrayList arrayList20 = arrayList14;
                ArrayList arrayList21 = arrayList15;
                ArrayList arrayList22 = arrayList16;
                ArrayList arrayList23 = new ArrayList();
                HashSet hashSet = new HashSet();
                int i10 = 0;
                HashMap map4 = map2;
                while (i10 < arrayList9.size()) {
                    m mVar4 = (m) arrayList9.get(i10);
                    if (hashSet.add(mVar4.f2830a)) {
                        C1579o c1579o = mVar4.f2831b;
                        AbstractC1709a.j(c1579o.f17356l == null);
                        ArrayList arrayList24 = (ArrayList) map4.get(mVar4.f2830a);
                        arrayList24.getClass();
                        map = map4;
                        D d9 = new D(new F0.s(null, null, arrayList24));
                        C1578n c1578nA = c1579o.a();
                        c1578nA.f17318k = d9;
                        arrayList23.add(new m(mVar4.f2830a, new C1579o(c1578nA), mVar4.f2832c, mVar4.f2833d, mVar4.f2834e, mVar4.f2835f));
                    } else {
                        map = map4;
                    }
                    i10++;
                    map4 = map;
                }
                int i11 = 0;
                C1579o c1579o2 = null;
                List arrayList25 = null;
                while (i11 < arrayList20.size()) {
                    ArrayList arrayList26 = arrayList20;
                    str2 = (String) arrayList26.get(i11);
                    strJ = j(str2, f2888j0, map3);
                    strJ2 = j(str2, pattern2, map3);
                    c1578n = new C1578n();
                    Pattern pattern3 = pattern2;
                    StringBuilder sb = new StringBuilder();
                    sb.append(strJ);
                    ArrayList arrayList27 = arrayList23;
                    sb.append(":");
                    sb.append(strJ2);
                    c1578n.f17309a = sb.toString();
                    c1578n.f17310b = strJ2;
                    c1578n.f17319l = E.m("application/x-mpegURL");
                    boolean zF = f(str2, f2892n0);
                    ?? r22 = zF;
                    if (f(str2, f2893o0)) {
                        r22 = (zF ? 1 : 0) | 2;
                    }
                    int i12 = r22;
                    if (f(str2, f2891m0)) {
                        i12 = (r22 == true ? 1 : 0) | 4;
                    }
                    c1578n.f17313e = i12;
                    String strI2 = i(str2, f2889k0, null, map3);
                    if (TextUtils.isEmpty(strI2)) {
                        str3 = str10;
                        i = 0;
                    } else {
                        int i13 = v.f18553a;
                        String[] strArrSplit = strI2.split(str10, -1);
                        i = v.l(strArrSplit, "public.accessibility.describes-video") ? 512 : 0;
                        str3 = str10;
                        if (v.l(strArrSplit, "public.accessibility.transcribes-spoken-dialog")) {
                            i |= 4096;
                        }
                        if (v.l(strArrSplit, "public.accessibility.describes-music-and-sound")) {
                            i |= 1024;
                        }
                        if (v.l(strArrSplit, "public.easy-to-read")) {
                            i |= 8192;
                        }
                    }
                    c1578n.f17314f = i;
                    c1578n.f17312d = i(str2, f2886h0, null, map3);
                    String strI3 = i(str2, pattern, null, map3);
                    uriZ = strI3 == null ? null : AbstractC1709a.z(str9, strI3);
                    d8 = new D(new F0.s(strJ, strJ2, Collections.EMPTY_LIST));
                    switch (j(str2, f2884f0, map3)) {
                        case "SUBTITLES":
                            int i14 = 0;
                            while (true) {
                                if (i14 < arrayList9.size()) {
                                    mVar = (m) arrayList9.get(i14);
                                    if (!strJ.equals(mVar.f2834e)) {
                                        i14++;
                                    }
                                } else {
                                    mVar = null;
                                }
                            }
                            if (mVar != null) {
                                String strU2 = v.u(3, mVar.f2831b.f17355k);
                                c1578n.f17317j = strU2;
                                strD = E.d(strU2);
                            } else {
                                strD = null;
                            }
                            if (strD == null) {
                                strD = "text/vtt";
                            }
                            c1578n.f17320m = E.m(strD);
                            c1578n.f17318k = d8;
                            if (uriZ == null) {
                                arrayList = arrayList19;
                                AbstractC1709a.B("HlsPlaylistParser", "EXT-X-MEDIA tag with missing mandatory URI attribute: skipping");
                                break;
                            } else {
                                l lVar = new l(uriZ, new C1579o(c1578n), strJ2);
                                arrayList = arrayList19;
                                arrayList.add(lVar);
                                break;
                            }
                            break;
                        case "CLOSED-CAPTIONS":
                            arrayList2 = arrayList18;
                            String strJ3 = j(str2, f2890l0, map3);
                            if (strJ3.startsWith("CC")) {
                                i5 = Integer.parseInt(strJ3.substring(2));
                                str4 = "application/cea-608";
                            } else {
                                i5 = Integer.parseInt(strJ3.substring(7));
                                str4 = "application/cea-708";
                            }
                            if (arrayList25 == null) {
                                arrayList25 = new ArrayList();
                            }
                            c1578n.f17320m = E.m(str4);
                            c1578n.H = i5;
                            arrayList25.add(new C1579o(c1578n));
                            arrayList18 = arrayList2;
                            arrayList = arrayList19;
                            break;
                        case "AUDIO":
                            int i15 = 0;
                            while (true) {
                                if (i15 < arrayList9.size()) {
                                    mVar2 = (m) arrayList9.get(i15);
                                    int i16 = i15;
                                    if (!strJ.equals(mVar2.f2833d)) {
                                        i15 = i16 + 1;
                                    }
                                } else {
                                    mVar2 = null;
                                }
                            }
                            if (mVar2 != null) {
                                String strU3 = v.u(1, mVar2.f2831b.f17355k);
                                c1578n.f17317j = strU3;
                                strD2 = E.d(strU3);
                            } else {
                                strD2 = null;
                            }
                            m mVar5 = mVar2;
                            String strI4 = i(str2, f2908y, null, map3);
                            if (strI4 != null) {
                                int i17 = v.f18553a;
                                c1578n.f17301C = Integer.parseInt(strI4.split("/", 2)[0]);
                                if ("audio/eac3".equals(strD2) && strI4.endsWith("/JOC")) {
                                    c1578n.f17317j = "ec+3";
                                    strD2 = "audio/eac3-joc";
                                }
                            }
                            c1578n.f17320m = E.m(strD2);
                            if (uriZ != null) {
                                c1578n.f17318k = d8;
                                arrayList18.add(new l(uriZ, new C1579o(c1578n), strJ2));
                            } else {
                                arrayList2 = arrayList18;
                                if (mVar5 != null) {
                                    c1579o2 = new C1579o(c1578n);
                                    arrayList18 = arrayList2;
                                } else {
                                    arrayList18 = arrayList2;
                                }
                            }
                            arrayList = arrayList19;
                            break;
                        case "VIDEO":
                            int i18 = 0;
                            while (true) {
                                if (i18 < arrayList9.size()) {
                                    mVar3 = (m) arrayList9.get(i18);
                                    if (!strJ.equals(mVar3.f2832c)) {
                                        i18++;
                                    }
                                } else {
                                    mVar3 = null;
                                }
                            }
                            if (mVar3 != null) {
                                C1579o c1579o3 = mVar3.f2831b;
                                String strU4 = v.u(2, c1579o3.f17355k);
                                c1578n.f17317j = strU4;
                                c1578n.f17320m = E.m(E.d(strU4));
                                c1578n.f17327t = c1579o3.f17365u;
                                c1578n.f17328u = c1579o3.f17366v;
                                c1578n.f17329v = c1579o3.f17367w;
                            }
                            if (uriZ != null) {
                                c1578n.f17318k = d8;
                                arrayList17.add(new l(uriZ, new C1579o(c1578n), strJ2));
                            }
                            arrayList = arrayList19;
                            break;
                        default:
                            arrayList = arrayList19;
                            break;
                    }
                    i11++;
                    arrayList23 = arrayList27;
                    str9 = str;
                    arrayList19 = arrayList;
                    arrayList20 = arrayList26;
                    pattern2 = pattern3;
                    str10 = str3;
                }
                ArrayList arrayList28 = arrayList23;
                ArrayList arrayList29 = arrayList19;
                if (zContains) {
                    arrayList25 = Collections.EMPTY_LIST;
                }
                return new n(str, arrayList22, arrayList28, arrayList17, arrayList18, arrayList29, arrayList13, c1579o2, arrayList25, z9, map3, arrayList21);
            }
            String strW = yVar.w();
            boolean z10 = z8;
            if (strW.startsWith("#EXT")) {
                arrayList16.add(strW);
            }
            boolean zStartsWith = strW.startsWith("#EXT-X-I-FRAME-STREAM-INF");
            if (strW.startsWith("#EXT-X-DEFINE")) {
                map3.put(j(strW, pattern2, map3), j(strW, f2897s0, map3));
            } else if (strW.equals("#EXT-X-INDEPENDENT-SEGMENTS")) {
                arrayList7 = arrayList10;
                arrayList6 = arrayList11;
                arrayList5 = arrayList12;
                arrayList8 = arrayList14;
                arrayList3 = arrayList15;
                arrayList4 = arrayList16;
                z8 = true;
                arrayList15 = arrayList3;
                arrayList16 = arrayList4;
                arrayList12 = arrayList5;
                arrayList11 = arrayList6;
                arrayList10 = arrayList7;
                arrayList14 = arrayList8;
            } else if (strW.startsWith("#EXT-X-MEDIA")) {
                arrayList14.add(strW);
            } else if (strW.startsWith("#EXT-X-SESSION-KEY")) {
                C1574j c1574jC = c(strW, i(strW, f2880b0, "identity", map3), map3);
                if (c1574jC != null) {
                    String strJ4 = j(strW, f2879a0, map3);
                    arrayList15.add(new C1575k(("SAMPLE-AES-CENC".equals(strJ4) || "SAMPLE-AES-CTR".equals(strJ4)) ? "cenc" : "cbcs", true, c1574jC));
                }
            } else {
                if (strW.startsWith("#EXT-X-STREAM-INF") || zStartsWith) {
                    zContains |= strW.contains("CLOSED-CAPTIONS=NONE");
                    int i19 = zStartsWith ? 16384 : 0;
                    arrayList3 = arrayList15;
                    int i20 = Integer.parseInt(j(strW, f2906x, Collections.EMPTY_MAP));
                    Matcher matcher = f2896s.matcher(strW);
                    if (matcher.find()) {
                        arrayList4 = arrayList16;
                        String strGroup = matcher.group(1);
                        strGroup.getClass();
                        i8 = Integer.parseInt(strGroup);
                    } else {
                        arrayList4 = arrayList16;
                        i8 = -1;
                    }
                    arrayList5 = arrayList12;
                    String strI5 = i(strW, f2910z, null, map3);
                    arrayList6 = arrayList11;
                    String strI6 = i(strW, f2847A, null, map3);
                    arrayList7 = arrayList10;
                    String strI7 = i(strW, f2849B, null, map3);
                    if (strI7 != null) {
                        int i21 = v.f18553a;
                        String[] strArrSplit2 = strI7.split(",", 2)[0].split("/", -1);
                        str5 = strArrSplit2[0];
                        if (strArrSplit2.length > 1) {
                            str6 = strArrSplit2[1];
                            arrayList8 = arrayList14;
                            i9 = 2;
                            strU = v.u(i9, strI6);
                            ArrayList arrayList30 = E.f17152a;
                            if (strU != null) {
                                str7 = strI6;
                            } else {
                                if (strU.startsWith("dvhe")) {
                                    str7 = strI6;
                                } else {
                                    str7 = strI6;
                                    if (!strU.startsWith("dvh1") && (str5 == null || ((!str5.startsWith("dvhe") || !strU.startsWith("hev1")) && ((!str5.startsWith("dvh1") || !strU.startsWith("hvc1")) && ((!str5.startsWith("dvav") || !strU.startsWith("avc3")) && ((!str5.startsWith("dva1") || !strU.startsWith("avc1")) && (!str5.startsWith("dav1") || !strU.startsWith("av01")))))))) {
                                    }
                                    arrayList15 = arrayList3;
                                    arrayList16 = arrayList4;
                                    arrayList12 = arrayList5;
                                    arrayList11 = arrayList6;
                                    arrayList10 = arrayList7;
                                    arrayList14 = arrayList8;
                                }
                                if (str5 == null || (strI5 != null && str6 != null && ((!strI5.equals("PQ") || str6.equals("db1p")) && ((!strI5.equals("SDR") || str6.equals("db2g")) && (!strI5.equals("HLG") || str6.startsWith("db4")))))) {
                                    if (str5 == null) {
                                        str5 = strU;
                                    }
                                    String[] strArrV = v.V(str7);
                                    if (strArrV.length == 0) {
                                        string = null;
                                        if (string == null) {
                                            str8 = str5 + "," + string;
                                        } else {
                                            str8 = str5;
                                        }
                                    } else {
                                        StringBuilder sb2 = new StringBuilder();
                                        int length = strArrV.length;
                                        int i22 = 0;
                                        while (i22 < length) {
                                            String str11 = strArrV[i22];
                                            String[] strArr = strArrV;
                                            int i23 = length;
                                            if (2 != E.h(E.d(str11))) {
                                                if (sb2.length() > 0) {
                                                    sb2.append(",");
                                                }
                                                sb2.append(str11);
                                            }
                                            i22++;
                                            length = i23;
                                            strArrV = strArr;
                                        }
                                        if (sb2.length() > 0) {
                                            string = sb2.toString();
                                        }
                                        if (string == null) {
                                        }
                                    }
                                    arrayList15 = arrayList3;
                                    arrayList16 = arrayList4;
                                    arrayList12 = arrayList5;
                                    arrayList11 = arrayList6;
                                    arrayList10 = arrayList7;
                                    arrayList14 = arrayList8;
                                }
                                strI = i(strW, f2851C, null, map3);
                                if (strI != null) {
                                    String[] strArrSplit3 = strI.split("x", -1);
                                    int i24 = Integer.parseInt(strArrSplit3[0]);
                                    int i25 = Integer.parseInt(strArrSplit3[1]);
                                    if (i24 <= 0 || i25 <= 0) {
                                        i25 = -1;
                                        i24 = -1;
                                    }
                                    String strI8 = i(strW, D, null, map3);
                                    float f3 = strI8 != null ? Float.parseFloat(strI8) : -1.0f;
                                    String strI9 = i(strW, f2898t, null, map3);
                                    String strI10 = i(strW, f2900u, null, map3);
                                    String strI11 = i(strW, f2902v, null, map3);
                                    String strI12 = i(strW, f2904w, null, map3);
                                    if (zStartsWith) {
                                        uriZ2 = AbstractC1709a.z(str9, j(strW, pattern, map3));
                                    } else {
                                        if (!yVar.u()) {
                                            throw F.b("#EXT-X-STREAM-INF must be followed by another line");
                                        }
                                        uriZ2 = AbstractC1709a.z(str9, k(yVar.w(), map3));
                                    }
                                    Uri uri = uriZ2;
                                    C1578n c1578n2 = new C1578n();
                                    c1578n2.f17309a = Integer.toString(arrayList9.size());
                                    c1578n2.f17319l = E.m("application/x-mpegURL");
                                    c1578n2.f17317j = str8;
                                    c1578n2.f17316h = i8;
                                    c1578n2.i = i20;
                                    c1578n2.f17327t = i24;
                                    c1578n2.f17328u = i25;
                                    c1578n2.f17329v = f3;
                                    c1578n2.f17314f = i19;
                                    arrayList9.add(new m(uri, new C1579o(c1578n2), strI9, strI10, strI11, strI12));
                                    ArrayList arrayList31 = (ArrayList) map2.get(uri);
                                    if (arrayList31 == null) {
                                        arrayList31 = new ArrayList();
                                        map2.put(uri, arrayList31);
                                    }
                                    arrayList31.add(new F0.r(i8, i20, strI9, strI10, strI11, strI12));
                                }
                                arrayList15 = arrayList3;
                                arrayList16 = arrayList4;
                                arrayList12 = arrayList5;
                                arrayList11 = arrayList6;
                                arrayList10 = arrayList7;
                                arrayList14 = arrayList8;
                            }
                            str8 = str7;
                            strI = i(strW, f2851C, null, map3);
                            if (strI != null) {
                            }
                            arrayList15 = arrayList3;
                            arrayList16 = arrayList4;
                            arrayList12 = arrayList5;
                            arrayList11 = arrayList6;
                            arrayList10 = arrayList7;
                            arrayList14 = arrayList8;
                        } else {
                            arrayList8 = arrayList14;
                            i9 = 2;
                        }
                    } else {
                        arrayList8 = arrayList14;
                        i9 = 2;
                        str5 = null;
                    }
                    str6 = null;
                    strU = v.u(i9, strI6);
                    ArrayList arrayList302 = E.f17152a;
                    if (strU != null) {
                    }
                    str8 = str7;
                    strI = i(strW, f2851C, null, map3);
                    if (strI != null) {
                    }
                    arrayList15 = arrayList3;
                    arrayList16 = arrayList4;
                    arrayList12 = arrayList5;
                    arrayList11 = arrayList6;
                    arrayList10 = arrayList7;
                    arrayList14 = arrayList8;
                }
                z8 = z10;
                arrayList15 = arrayList3;
                arrayList16 = arrayList4;
                arrayList12 = arrayList5;
                arrayList11 = arrayList6;
                arrayList10 = arrayList7;
                arrayList14 = arrayList8;
            }
            arrayList7 = arrayList10;
            arrayList6 = arrayList11;
            arrayList5 = arrayList12;
            arrayList8 = arrayList14;
            arrayList3 = arrayList15;
            arrayList4 = arrayList16;
            z8 = z10;
            arrayList15 = arrayList3;
            arrayList16 = arrayList4;
            arrayList12 = arrayList5;
            arrayList11 = arrayList6;
            arrayList10 = arrayList7;
            arrayList14 = arrayList8;
        }
    }

    public static boolean f(String str, Pattern pattern) {
        Matcher matcher = pattern.matcher(str);
        if (matcher.find()) {
            return "YES".equals(matcher.group(1));
        }
        return false;
    }

    public static double g(String str, Pattern pattern, double d8) {
        Matcher matcher = pattern.matcher(str);
        if (!matcher.find()) {
            return d8;
        }
        String strGroup = matcher.group(1);
        strGroup.getClass();
        return Double.parseDouble(strGroup);
    }

    public static long h(String str, Pattern pattern) {
        Matcher matcher = pattern.matcher(str);
        if (!matcher.find()) {
            return -1L;
        }
        String strGroup = matcher.group(1);
        strGroup.getClass();
        return Long.parseLong(strGroup);
    }

    public static String i(String str, Pattern pattern, String str2, Map map) {
        Matcher matcher = pattern.matcher(str);
        if (matcher.find()) {
            str2 = matcher.group(1);
            str2.getClass();
        }
        return (map.isEmpty() || str2 == null) ? str2 : k(str2, map);
    }

    public static String j(String str, Pattern pattern, Map map) throws F {
        String strI = i(str, pattern, null, map);
        if (strI != null) {
            return strI;
        }
        throw F.b("Couldn't match " + pattern.pattern() + " in " + str);
    }

    public static String k(String str, Map map) {
        Matcher matcher = f2860H0.matcher(str);
        StringBuffer stringBuffer = new StringBuffer();
        while (matcher.find()) {
            String strGroup = matcher.group(1);
            if (map.containsKey(strGroup)) {
                matcher.appendReplacement(stringBuffer, Matcher.quoteReplacement((String) map.get(strGroup)));
            }
        }
        matcher.appendTail(stringBuffer);
        return stringBuffer.toString();
    }

    /* JADX WARN: Removed duplicated region for block: B:19:0x003f A[Catch: all -> 0x0095, TryCatch #0 {all -> 0x0095, blocks: (B:3:0x000f, B:5:0x0018, B:7:0x0020, B:10:0x0029, B:31:0x0068, B:33:0x006e, B:36:0x0079, B:38:0x0081, B:43:0x0097, B:45:0x009f, B:47:0x00a7, B:49:0x00af, B:51:0x00b7, B:53:0x00bf, B:55:0x00c7, B:57:0x00cf, B:60:0x00d8, B:61:0x00dc, B:66:0x00fe, B:67:0x0104, B:13:0x0030, B:15:0x0036, B:19:0x003f, B:22:0x0048, B:24:0x0051, B:26:0x0057, B:28:0x005d, B:29:0x0062), top: B:70:0x000f }] */
    /* JADX WARN: Removed duplicated region for block: B:89:0x004f A[SYNTHETIC] */
    @Override // P0.n
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final o w(Uri uri, z0.j jVar) throws F {
        int i;
        String strTrim;
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(jVar));
        ArrayDeque arrayDeque = new ArrayDeque();
        try {
            int i5 = bufferedReader.read();
            boolean zJ = false;
            if (i5 != 239) {
                while (i5 != -1 && Character.isWhitespace(i5)) {
                    i5 = bufferedReader.read();
                }
                i = 0;
                while (true) {
                    if (i < 7) {
                        while (i5 != -1 && Character.isWhitespace(i5) && !v.J(i5)) {
                            i5 = bufferedReader.read();
                        }
                        zJ = v.J(i5);
                    } else {
                        if (i5 != "#EXTM3U".charAt(i)) {
                            break;
                        }
                        i5 = bufferedReader.read();
                        i++;
                    }
                }
            } else if (bufferedReader.read() == 187 && bufferedReader.read() == 191) {
                i5 = bufferedReader.read();
                while (i5 != -1) {
                    i5 = bufferedReader.read();
                }
                i = 0;
                while (true) {
                    if (i < 7) {
                    }
                    i5 = bufferedReader.read();
                    i++;
                }
            }
            if (!zJ) {
                throw F.b("Input does not start with the #EXTM3U header.");
            }
            while (true) {
                String line = bufferedReader.readLine();
                if (line == null) {
                    v.g(bufferedReader);
                    throw F.b("Failed to parse the playlist, could not identify any tags.");
                }
                strTrim = line.trim();
                if (!strTrim.isEmpty()) {
                    if (!strTrim.startsWith("#EXT-X-STREAM-INF")) {
                        if (strTrim.startsWith("#EXT-X-TARGETDURATION") || strTrim.startsWith("#EXT-X-MEDIA-SEQUENCE") || strTrim.startsWith("#EXTINF") || strTrim.startsWith("#EXT-X-KEY") || strTrim.startsWith("#EXT-X-BYTERANGE") || strTrim.equals("#EXT-X-DISCONTINUITY") || strTrim.equals("#EXT-X-DISCONTINUITY-SEQUENCE") || strTrim.equals("#EXT-X-ENDLIST")) {
                            break;
                        }
                        arrayDeque.add(strTrim);
                    } else {
                        arrayDeque.add(strTrim);
                        return e(new y(arrayDeque, bufferedReader), uri.toString());
                    }
                }
            }
            arrayDeque.add(strTrim);
            return d(this.f2912q, this.f2913r, new y(arrayDeque, bufferedReader), uri.toString());
        } finally {
            v.g(bufferedReader);
        }
    }
}
