package w1;

import d5.AbstractC0844a;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import org.xmlpull.v1.XmlPullParserFactory;
import q1.C1449f;
import q1.C1455l;
import q1.InterfaceC1447d;
import q1.InterfaceC1456m;
import x0.AbstractC1709a;
import x0.v;

/* JADX INFO: loaded from: classes.dex */
public final class e implements InterfaceC1456m {

    /* JADX INFO: renamed from: r, reason: collision with root package name */
    public static final Pattern f18255r = Pattern.compile("^([0-9][0-9]+):([0-9][0-9]):([0-9][0-9])(?:(\\.[0-9]+)|:([0-9][0-9])(?:\\.([0-9]+))?)?$");

    /* JADX INFO: renamed from: s, reason: collision with root package name */
    public static final Pattern f18256s = Pattern.compile("^([0-9]+(?:\\.[0-9]+)?)(h|m|s|ms|f|t)$");

    /* JADX INFO: renamed from: t, reason: collision with root package name */
    public static final Pattern f18257t = Pattern.compile("^(([0-9]*.)?[0-9]+)(px|em|%)$");

    /* JADX INFO: renamed from: u, reason: collision with root package name */
    public static final Pattern f18258u = Pattern.compile("^([-+]?\\d+\\.?\\d*?)%$");

    /* JADX INFO: renamed from: v, reason: collision with root package name */
    public static final Pattern f18259v = Pattern.compile("^([-+]?\\d+\\.?\\d*?)% ([-+]?\\d+\\.?\\d*?)%$");

    /* JADX INFO: renamed from: w, reason: collision with root package name */
    public static final Pattern f18260w = Pattern.compile("^([-+]?\\d+\\.?\\d*?)px ([-+]?\\d+\\.?\\d*?)px$");

    /* JADX INFO: renamed from: x, reason: collision with root package name */
    public static final Pattern f18261x = Pattern.compile("^(\\d+) (\\d+)$");

    /* JADX INFO: renamed from: y, reason: collision with root package name */
    public static final d f18262y = new d(30.0f, 1, 1);

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

    public e() {
        try {
            XmlPullParserFactory xmlPullParserFactoryNewInstance = XmlPullParserFactory.newInstance();
            this.f18263q = xmlPullParserFactoryNewInstance;
            xmlPullParserFactoryNewInstance.setNamespaceAware(true);
        } catch (XmlPullParserException e8) {
            throw new RuntimeException("Couldn't create XmlPullParserFactory instance", e8);
        }
    }

    public static g b(g gVar) {
        return gVar == null ? new g() : gVar;
    }

    public static boolean c(String str) {
        return str.equals("tt") || str.equals("head") || str.equals("body") || str.equals("div") || str.equals("p") || str.equals("span") || str.equals("br") || str.equals("style") || str.equals("styling") || str.equals("layout") || str.equals("region") || str.equals("metadata") || str.equals("image") || str.equals("data") || str.equals("information");
    }

    public static int e(XmlPullParser xmlPullParser) {
        String attributeValue = xmlPullParser.getAttributeValue("http://www.w3.org/ns/ttml#parameter", "cellResolution");
        if (attributeValue == null) {
            return 15;
        }
        Matcher matcher = f18261x.matcher(attributeValue);
        if (!matcher.matches()) {
            AbstractC1709a.B("TtmlParser", "Ignoring malformed cell resolution: ".concat(attributeValue));
            return 15;
        }
        boolean z8 = true;
        try {
            String strGroup = matcher.group(1);
            strGroup.getClass();
            int i = Integer.parseInt(strGroup);
            String strGroup2 = matcher.group(2);
            strGroup2.getClass();
            int i5 = Integer.parseInt(strGroup2);
            if (i == 0 || i5 == 0) {
                z8 = false;
            }
            AbstractC1709a.c("Invalid cell resolution " + i + " " + i5, z8);
            return i5;
        } catch (NumberFormatException unused) {
            AbstractC1709a.B("TtmlParser", "Ignoring malformed cell resolution: ".concat(attributeValue));
            return 15;
        }
    }

    public static void f(String str, g gVar) throws C1449f {
        Matcher matcher;
        String strGroup;
        int i = v.f18553a;
        String[] strArrSplit = str.split("\\s+", -1);
        int length = strArrSplit.length;
        Pattern pattern = f18257t;
        if (length == 1) {
            matcher = pattern.matcher(str);
        } else {
            if (strArrSplit.length != 2) {
                throw new C1449f(AbstractC0844a.n(new StringBuilder("Invalid number of entries for fontSize: "), strArrSplit.length, "."));
            }
            matcher = pattern.matcher(strArrSplit[1]);
            AbstractC1709a.B("TtmlParser", "Multiple values in fontSize attribute. Picking the second value for vertical font size and ignoring the first.");
        }
        if (!matcher.matches()) {
            throw new C1449f(I1.a.p("Invalid expression for fontSize: '", str, "'."));
        }
        strGroup = matcher.group(3);
        strGroup.getClass();
        switch (strGroup) {
            case "%":
                gVar.f18281j = 3;
                break;
            case "em":
                gVar.f18281j = 2;
                break;
            case "px":
                gVar.f18281j = 1;
                break;
            default:
                throw new C1449f(I1.a.p("Invalid unit for fontSize: '", strGroup, "'."));
        }
        String strGroup2 = matcher.group(1);
        strGroup2.getClass();
        gVar.f18282k = Float.parseFloat(strGroup2);
    }

    public static d g(XmlPullParser xmlPullParser) {
        float f3;
        String attributeValue = xmlPullParser.getAttributeValue("http://www.w3.org/ns/ttml#parameter", "frameRate");
        int i = attributeValue != null ? Integer.parseInt(attributeValue) : 30;
        String attributeValue2 = xmlPullParser.getAttributeValue("http://www.w3.org/ns/ttml#parameter", "frameRateMultiplier");
        if (attributeValue2 != null) {
            int i5 = v.f18553a;
            AbstractC1709a.c("frameRateMultiplier doesn't have 2 parts", attributeValue2.split(" ", -1).length == 2);
            f3 = Integer.parseInt(r2[0]) / Integer.parseInt(r2[1]);
        } else {
            f3 = 1.0f;
        }
        d dVar = f18262y;
        int i8 = dVar.f18253b;
        String attributeValue3 = xmlPullParser.getAttributeValue("http://www.w3.org/ns/ttml#parameter", "subFrameRate");
        if (attributeValue3 != null) {
            i8 = Integer.parseInt(attributeValue3);
        }
        String attributeValue4 = xmlPullParser.getAttributeValue("http://www.w3.org/ns/ttml#parameter", "tickRate");
        return new d(i * f3, i8, attributeValue4 != null ? Integer.parseInt(attributeValue4) : dVar.f18254c);
    }

    /* JADX WARN: Can't fix incorrect switch cases order, some code will duplicate */
    /* JADX WARN: Removed duplicated region for block: B:103:0x0217  */
    /* JADX WARN: Removed duplicated region for block: B:106:0x0227  */
    /* JADX WARN: Removed duplicated region for block: B:120:0x0268 A[LOOP:0: B:3:0x000a->B:120:0x0268, LOOP_END] */
    /* JADX WARN: Removed duplicated region for block: B:127:0x0267 A[SYNTHETIC] */
    /* JADX WARN: Removed duplicated region for block: B:81:0x01cf  */
    /* JADX WARN: Removed duplicated region for block: B:86:0x01eb  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public static void h(XmlPullParser xmlPullParser, HashMap map, int i, A7.a aVar, HashMap map2, HashMap map3) throws XmlPullParserException, IOException {
        String strR;
        float f3;
        float f7;
        float f8;
        float f9;
        float f10;
        float f11;
        int i5;
        int i8;
        f fVar;
        float f12;
        float f13;
        String strR2;
        g gVar;
        String strR3;
        g gVar2;
        String[] strArrSplit;
        int i9 = -1;
        int i10 = 0;
        while (true) {
            xmlPullParser.next();
            if (AbstractC1709a.v(xmlPullParser, "style")) {
                String strR4 = AbstractC1709a.r(xmlPullParser, "style");
                g gVarJ = j(xmlPullParser, new g());
                if (strR4 != null) {
                    String strTrim = strR4.trim();
                    if (strTrim.isEmpty()) {
                        strArrSplit = new String[i10];
                    } else {
                        int i11 = v.f18553a;
                        strArrSplit = strTrim.split("\\s+", i9);
                    }
                    int length = strArrSplit.length;
                    for (int i12 = i10; i12 < length; i12++) {
                        gVarJ.a((g) map.get(strArrSplit[i12]));
                    }
                }
                String str = gVarJ.f18283l;
                if (str != null) {
                    map.put(str, gVarJ);
                }
            } else {
                if (AbstractC1709a.v(xmlPullParser, "region")) {
                    String strR5 = AbstractC1709a.r(xmlPullParser, "id");
                    if (strR5 != null) {
                        String strR6 = AbstractC1709a.r(xmlPullParser, "origin");
                        if (strR6 == null && (strR3 = AbstractC1709a.r(xmlPullParser, "style")) != null && (gVar2 = (g) map.get(strR3)) != null) {
                            strR6 = gVar2.f18291t;
                        }
                        Pattern pattern = f18260w;
                        Pattern pattern2 = f18259v;
                        if (strR6 != null) {
                            Matcher matcher = pattern2.matcher(strR6);
                            Matcher matcher2 = pattern.matcher(strR6);
                            if (matcher.matches()) {
                                try {
                                    String strGroup = matcher.group(1);
                                    strGroup.getClass();
                                    f8 = Float.parseFloat(strGroup) / 100.0f;
                                    String strGroup2 = matcher.group(2);
                                    strGroup2.getClass();
                                    f7 = Float.parseFloat(strGroup2) / 100.0f;
                                    f3 = 100.0f;
                                } catch (NumberFormatException unused) {
                                    AbstractC1709a.B("TtmlParser", "Ignoring region with malformed origin: ".concat(strR6));
                                }
                            } else {
                                if (!matcher2.matches()) {
                                    AbstractC1709a.B("TtmlParser", "Ignoring region with unsupported origin: ".concat(strR6));
                                } else if (aVar == null) {
                                    AbstractC1709a.B("TtmlParser", "Ignoring region with missing tts:extent: ".concat(strR6));
                                } else {
                                    try {
                                        String strGroup3 = matcher2.group(1);
                                        strGroup3.getClass();
                                        int i13 = Integer.parseInt(strGroup3);
                                        String strGroup4 = matcher2.group(2);
                                        strGroup4.getClass();
                                        f3 = 100.0f;
                                        float f14 = i13 / aVar.f460a;
                                        float f15 = Integer.parseInt(strGroup4) / aVar.f461b;
                                        f8 = f14;
                                        f7 = f15;
                                    } catch (NumberFormatException unused2) {
                                        AbstractC1709a.B("TtmlParser", "Ignoring region with malformed origin: ".concat(strR6));
                                    }
                                }
                                fVar = null;
                                if (fVar == null) {
                                    map2.put(fVar.f18264a, fVar);
                                }
                            }
                        } else {
                            f3 = 100.0f;
                            f7 = 0.0f;
                            f8 = 0.0f;
                        }
                        String strR7 = AbstractC1709a.r(xmlPullParser, "extent");
                        if (strR7 == null && (strR2 = AbstractC1709a.r(xmlPullParser, "style")) != null && (gVar = (g) map.get(strR2)) != null) {
                            strR7 = gVar.f18292u;
                        }
                        if (strR7 != null) {
                            Matcher matcher3 = pattern2.matcher(strR7);
                            Matcher matcher4 = pattern.matcher(strR7);
                            if (matcher3.matches()) {
                                try {
                                    String strGroup5 = matcher3.group(1);
                                    strGroup5.getClass();
                                    f12 = Float.parseFloat(strGroup5) / f3;
                                    String strGroup6 = matcher3.group(2);
                                    strGroup6.getClass();
                                    f13 = Float.parseFloat(strGroup6) / f3;
                                    f9 = f12;
                                    f10 = f13;
                                } catch (NumberFormatException unused3) {
                                    AbstractC0844a.v("Ignoring region with malformed extent: ", strR6, "TtmlParser");
                                    fVar = null;
                                }
                            } else {
                                if (!matcher4.matches()) {
                                    AbstractC0844a.v("Ignoring region with unsupported extent: ", strR6, "TtmlParser");
                                } else if (aVar == null) {
                                    AbstractC0844a.v("Ignoring region with missing tts:extent: ", strR6, "TtmlParser");
                                } else {
                                    String strGroup7 = matcher4.group(1);
                                    strGroup7.getClass();
                                    int i14 = Integer.parseInt(strGroup7);
                                    String strGroup8 = matcher4.group(2);
                                    strGroup8.getClass();
                                    float f16 = i14 / aVar.f460a;
                                    f13 = Integer.parseInt(strGroup8) / aVar.f461b;
                                    f12 = f16;
                                    f9 = f12;
                                    f10 = f13;
                                }
                                fVar = null;
                                if (fVar == null) {
                                }
                            }
                        } else {
                            f9 = 1.0f;
                            f10 = 1.0f;
                        }
                        String strR8 = AbstractC1709a.r(xmlPullParser, "displayAlign");
                        if (strR8 != null) {
                            String strF = s7.d.F(strR8);
                            strF.getClass();
                            if (strF.equals("center")) {
                                f11 = f7 + (f10 / 2.0f);
                                i5 = 1;
                            } else if (strF.equals("after")) {
                                i5 = 2;
                                f11 = f7 + f10;
                            } else {
                                f11 = f7;
                                i5 = 0;
                            }
                            float f17 = 1.0f / i;
                            String strR9 = AbstractC1709a.r(xmlPullParser, "writingMode");
                            if (strR9 != null) {
                                String strF2 = s7.d.F(strR9);
                                strF2.getClass();
                                switch (strF2) {
                                    case "tb":
                                    case "tblr":
                                        i8 = 2;
                                        break;
                                    case "tbrl":
                                        i8 = 1;
                                        break;
                                    default:
                                        i8 = Integer.MIN_VALUE;
                                        break;
                                }
                                fVar = new f(strR5, f8, f11, 0, i5, f9, f10, 1, f17, i8);
                                if (fVar == null) {
                                }
                            }
                        }
                    } else {
                        fVar = null;
                        if (fVar == null) {
                        }
                    }
                    if (!AbstractC1709a.u(xmlPullParser, "head")) {
                        return;
                    }
                    i9 = -1;
                    i10 = 0;
                } else {
                    if (AbstractC1709a.v(xmlPullParser, "metadata")) {
                        do {
                            xmlPullParser.next();
                            if (AbstractC1709a.v(xmlPullParser, "image") && (strR = AbstractC1709a.r(xmlPullParser, "id")) != null) {
                                map3.put(strR, xmlPullParser.nextText());
                            }
                        } while (!AbstractC1709a.u(xmlPullParser, "metadata"));
                    }
                    if (!AbstractC1709a.u(xmlPullParser, "head")) {
                    }
                }
                if (!AbstractC1709a.u(xmlPullParser, "head")) {
                }
            }
            if (!AbstractC1709a.u(xmlPullParser, "head")) {
            }
        }
    }

    /* JADX WARN: Can't fix incorrect switch cases order, some code will duplicate */
    /* JADX WARN: Removed duplicated region for block: B:6:0x0037  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public static C1697c i(XmlPullParser xmlPullParser, C1697c c1697c, HashMap map, d dVar) throws C1449f {
        String attributeValue;
        byte b8;
        String[] strArrSplit;
        int attributeCount = xmlPullParser.getAttributeCount();
        String strSubstring = null;
        g gVarJ = j(xmlPullParser, null);
        long j8 = -9223372036854775807L;
        long jK = -9223372036854775807L;
        long jK2 = -9223372036854775807L;
        long jK3 = -9223372036854775807L;
        String[] strArr = null;
        String str = "";
        int i = 0;
        while (i < attributeCount) {
            long j9 = j8;
            String attributeName = xmlPullParser.getAttributeName(i);
            attributeValue = xmlPullParser.getAttributeValue(i);
            attributeName.getClass();
            switch (attributeName) {
                case "region":
                    if (!map.containsKey(attributeValue)) {
                        break;
                    } else {
                        str = attributeValue;
                        break;
                    }
                    break;
                case "dur":
                    jK3 = k(attributeValue, dVar);
                    break;
                case "end":
                    jK2 = k(attributeValue, dVar);
                    break;
                case "begin":
                    jK = k(attributeValue, dVar);
                    break;
                case "style":
                    String strTrim = attributeValue.trim();
                    if (strTrim.isEmpty()) {
                        strArrSplit = new String[0];
                        b8 = -1;
                    } else {
                        int i5 = v.f18553a;
                        b8 = -1;
                        strArrSplit = strTrim.split("\\s+", -1);
                    }
                    if (strArrSplit.length <= 0) {
                        break;
                    } else {
                        strArr = strArrSplit;
                        break;
                    }
                    break;
                case "backgroundImage":
                    if (attributeValue.startsWith("#")) {
                        strSubstring = attributeValue.substring(1);
                        break;
                    }
            }
            i++;
            j8 = j9;
        }
        long j10 = j8;
        if (c1697c != null) {
            long j11 = c1697c.f18243d;
            if (j11 != j10) {
                if (jK != j10) {
                    jK += j11;
                }
                if (jK2 != j10) {
                    jK2 += j11;
                }
            }
        }
        long j12 = jK;
        if (jK2 == j10) {
            if (jK3 != j10) {
                jK2 = j12 + jK3;
            } else if (c1697c != null) {
                long j13 = c1697c.f18244e;
                if (j13 != j10) {
                    jK2 = j13;
                }
            }
        }
        return new C1697c(xmlPullParser.getName(), null, j12, jK2, gVarJ, strArr, str, strSubstring, c1697c);
    }

    /* JADX WARN: Can't fix incorrect switch cases order, some code will duplicate */
    /* JADX WARN: Removed duplicated region for block: B:6:0x0031  */
    /*  JADX ERROR: JadxRuntimeException in pass: RegionMakerVisitor
        jadx.core.utils.exceptions.JadxRuntimeException: Failed to find switch 'out' block (already processed)
        	at jadx.core.dex.visitors.regions.maker.SwitchRegionMaker.calcSwitchOut(SwitchRegionMaker.java:217)
        	at jadx.core.dex.visitors.regions.maker.SwitchRegionMaker.process(SwitchRegionMaker.java:68)
        	at jadx.core.dex.visitors.regions.maker.RegionMaker.traverse(RegionMaker.java:112)
        	at jadx.core.dex.visitors.regions.maker.RegionMaker.makeRegion(RegionMaker.java:66)
        	at jadx.core.dex.visitors.regions.maker.SwitchRegionMaker.addCases(SwitchRegionMaker.java:123)
        	at jadx.core.dex.visitors.regions.maker.SwitchRegionMaker.process(SwitchRegionMaker.java:71)
        	at jadx.core.dex.visitors.regions.maker.RegionMaker.traverse(RegionMaker.java:112)
        	at jadx.core.dex.visitors.regions.maker.RegionMaker.makeRegion(RegionMaker.java:66)
        	at jadx.core.dex.visitors.regions.maker.LoopRegionMaker.process(LoopRegionMaker.java:125)
        	at jadx.core.dex.visitors.regions.maker.RegionMaker.traverse(RegionMaker.java:89)
        	at jadx.core.dex.visitors.regions.maker.RegionMaker.makeRegion(RegionMaker.java:66)
        	at jadx.core.dex.visitors.regions.maker.RegionMaker.makeMthRegion(RegionMaker.java:48)
        	at jadx.core.dex.visitors.regions.RegionMakerVisitor.visit(RegionMakerVisitor.java:25)
        */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public static w1.g j(org.xmlpull.v1.XmlPullParser r21, w1.g r22) {
        /*
            Method dump skipped, instruction units count: 1698
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: w1.e.j(org.xmlpull.v1.XmlPullParser, w1.g):w1.g");
    }

    public static long k(String str, d dVar) throws C1449f {
        double d8;
        double d9;
        double d10;
        Matcher matcher = f18255r.matcher(str);
        if (matcher.matches()) {
            String strGroup = matcher.group(1);
            strGroup.getClass();
            double d11 = Long.parseLong(strGroup) * 3600;
            matcher.group(2).getClass();
            double d12 = d11 + (Long.parseLong(r13) * 60);
            matcher.group(3).getClass();
            double d13 = d12 + Long.parseLong(r13);
            String strGroup2 = matcher.group(4);
            return (long) ((d13 + (strGroup2 != null ? Double.parseDouble(strGroup2) : 0.0d) + (matcher.group(5) != null ? Long.parseLong(r13) / dVar.f18252a : 0.0d) + (matcher.group(6) != null ? (Long.parseLong(r13) / ((double) dVar.f18253b)) / ((double) dVar.f18252a) : 0.0d)) * 1000000.0d);
        }
        Matcher matcher2 = f18256s.matcher(str);
        if (!matcher2.matches()) {
            throw new C1449f(AbstractC0844a.x("Malformed time expression: ", str));
        }
        String strGroup3 = matcher2.group(1);
        strGroup3.getClass();
        d8 = Double.parseDouble(strGroup3);
        String strGroup4 = matcher2.group(2);
        strGroup4.getClass();
        switch (strGroup4) {
            case "f":
                d9 = dVar.f18252a;
                d8 /= d9;
                return (long) (d8 * 1000000.0d);
            case "h":
                d10 = 3600.0d;
                break;
            case "m":
                d10 = 60.0d;
                break;
            case "t":
                d9 = dVar.f18254c;
                d8 /= d9;
                return (long) (d8 * 1000000.0d);
            case "ms":
                d9 = 1000.0d;
                d8 /= d9;
                return (long) (d8 * 1000000.0d);
            default:
                return (long) (d8 * 1000000.0d);
        }
        d8 *= d10;
        return (long) (d8 * 1000000.0d);
    }

    public static A7.a l(XmlPullParser xmlPullParser) {
        String strR = AbstractC1709a.r(xmlPullParser, "extent");
        if (strR == null) {
            return null;
        }
        Matcher matcher = f18260w.matcher(strR);
        if (!matcher.matches()) {
            AbstractC1709a.B("TtmlParser", "Ignoring non-pixel tts extent: ".concat(strR));
            return null;
        }
        try {
            String strGroup = matcher.group(1);
            strGroup.getClass();
            int i = Integer.parseInt(strGroup);
            String strGroup2 = matcher.group(2);
            strGroup2.getClass();
            return new A7.a(i, Integer.parseInt(strGroup2), false);
        } catch (NumberFormatException unused) {
            AbstractC1709a.B("TtmlParser", "Ignoring malformed tts extent: ".concat(strR));
            return null;
        }
    }

    @Override // q1.InterfaceC1456m
    public final void a(byte[] bArr, int i, int i5, C1455l c1455l, x0.d dVar) {
        android.support.v4.media.session.a.u(d(bArr, i, i5), c1455l, dVar);
    }

    @Override // q1.InterfaceC1456m
    public final InterfaceC1447d d(byte[] bArr, int i, int i5) {
        try {
            XmlPullParser xmlPullParserNewPullParser = this.f18263q.newPullParser();
            HashMap map = new HashMap();
            HashMap map2 = new HashMap();
            HashMap map3 = new HashMap();
            map2.put("", new f("", -3.4028235E38f, -3.4028235E38f, Integer.MIN_VALUE, Integer.MIN_VALUE, -3.4028235E38f, -3.4028235E38f, Integer.MIN_VALUE, -3.4028235E38f, Integer.MIN_VALUE));
            A7.a aVarL = null;
            xmlPullParserNewPullParser.setInput(new ByteArrayInputStream(bArr, i, i5), null);
            ArrayDeque arrayDeque = new ArrayDeque();
            d dVarG = f18262y;
            int i8 = 0;
            int iE = 15;
            K2.e eVar = null;
            for (int eventType = xmlPullParserNewPullParser.getEventType(); eventType != 1; eventType = xmlPullParserNewPullParser.getEventType()) {
                C1697c c1697c = (C1697c) arrayDeque.peek();
                if (i8 == 0) {
                    String name = xmlPullParserNewPullParser.getName();
                    if (eventType == 2) {
                        if ("tt".equals(name)) {
                            dVarG = g(xmlPullParserNewPullParser);
                            iE = e(xmlPullParserNewPullParser);
                            aVarL = l(xmlPullParserNewPullParser);
                        }
                        d dVar = dVarG;
                        A7.a aVar = aVarL;
                        int i9 = iE;
                        if (c(name)) {
                            if ("head".equals(name)) {
                                h(xmlPullParserNewPullParser, map, i9, aVar, map2, map3);
                            } else {
                                try {
                                    C1697c c1697cI = i(xmlPullParserNewPullParser, c1697c, map2, dVar);
                                    arrayDeque.push(c1697cI);
                                    if (c1697c != null) {
                                        if (c1697c.f18251m == null) {
                                            c1697c.f18251m = new ArrayList();
                                        }
                                        c1697c.f18251m.add(c1697cI);
                                    }
                                } catch (C1449f e8) {
                                    AbstractC1709a.C("TtmlParser", "Suppressing parser error", e8);
                                    i8++;
                                }
                            }
                            iE = i9;
                            aVarL = aVar;
                            dVarG = dVar;
                        } else {
                            AbstractC1709a.t("TtmlParser", "Ignoring unsupported tag: " + xmlPullParserNewPullParser.getName());
                        }
                        i8++;
                        iE = i9;
                        aVarL = aVar;
                        dVarG = dVar;
                    } else if (eventType == 4) {
                        c1697c.getClass();
                        C1697c c1697cA = C1697c.a(xmlPullParserNewPullParser.getText());
                        if (c1697c.f18251m == null) {
                            c1697c.f18251m = new ArrayList();
                        }
                        c1697c.f18251m.add(c1697cA);
                    } else if (eventType == 3) {
                        if (xmlPullParserNewPullParser.getName().equals("tt")) {
                            C1697c c1697c2 = (C1697c) arrayDeque.peek();
                            c1697c2.getClass();
                            eVar = new K2.e(c1697c2, map, map2, map3);
                        }
                        arrayDeque.pop();
                    }
                } else if (eventType == 2) {
                    i8++;
                } else if (eventType == 3) {
                    i8--;
                }
                xmlPullParserNewPullParser.next();
            }
            eVar.getClass();
            return eVar;
        } catch (IOException e9) {
            throw new IllegalStateException("Unexpected error when reading input.", e9);
        } catch (XmlPullParserException e10) {
            throw new IllegalStateException("Unable to decode source", e10);
        }
    }

    @Override // q1.InterfaceC1456m
    public final /* synthetic */ void reset() {
    }
}
