package p138.p176.p177.p190.p226.p232;

import android.text.Layout;
import android.util.Log;
import com.google.android.exoplayer2.text.SubtitleDecoderException;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
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 p000.p001.p002.p003.p004.C0567;
import p138.p139.p143.p144.C2803;
import p138.p176.p177.p190.p226.AbstractC3947;
import p138.p176.p177.p190.p226.InterfaceC3949;
import p138.p176.p177.p190.p239.C4122;
import p138.p176.p177.p190.p239.C4131;
import p138.p176.p177.p190.p239.C4150;

/* JADX INFO: renamed from: ދ.ހ.֏.ؠ.ໟ.ގ.֏, reason: contains not printable characters */
/* JADX INFO: loaded from: classes.dex */
public final class C3991 extends AbstractC3947 {

    /* JADX INFO: renamed from: ލ, reason: contains not printable characters */
    public static final Pattern f12595 = 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: ގ, reason: contains not printable characters */
    public static final Pattern f12596 = Pattern.compile("^([0-9]+(?:\\.[0-9]+)?)(h|m|s|ms|f|t)$");

    /* JADX INFO: renamed from: ޏ, reason: contains not printable characters */
    public static final Pattern f12597 = Pattern.compile("^(([0-9]*.)?[0-9]+)(px|em|%)$");

    /* JADX INFO: renamed from: ސ, reason: contains not printable characters */
    public static final Pattern f12598 = Pattern.compile("^(\\d+\\.?\\d*?)% (\\d+\\.?\\d*?)%$");

    /* JADX INFO: renamed from: ޑ, reason: contains not printable characters */
    public static final Pattern f12599 = Pattern.compile("^(\\d+\\.?\\d*?)px (\\d+\\.?\\d*?)px$");

    /* JADX INFO: renamed from: ޒ, reason: contains not printable characters */
    public static final Pattern f12600 = Pattern.compile("^(\\d+) (\\d+)$");

    /* JADX INFO: renamed from: ޓ, reason: contains not printable characters */
    public static final C3993 f12601 = new C3993(30.0f, 1, 1);

    /* JADX INFO: renamed from: ޔ, reason: contains not printable characters */
    public static final C3992 f12602 = new C3992(32, 15);

    /* JADX INFO: renamed from: ތ, reason: contains not printable characters */
    public final XmlPullParserFactory f12603;

    /* JADX INFO: renamed from: ދ.ހ.֏.ؠ.ໟ.ގ.֏$֏, reason: contains not printable characters */
    public static final class C3992 {

        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public final int f12604;

        public C3992(int i, int i2) {
            this.f12604 = i2;
        }
    }

    /* JADX INFO: renamed from: ދ.ހ.֏.ؠ.ໟ.ގ.֏$ؠ, reason: contains not printable characters */
    public static final class C3993 {

        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public final float f12605;

        /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
        public final int f12606;

        /* JADX INFO: renamed from: ހ, reason: contains not printable characters */
        public final int f12607;

        public C3993(float f, int i, int i2) {
            this.f12605 = f;
            this.f12606 = i;
            this.f12607 = i2;
        }
    }

    /* JADX INFO: renamed from: ދ.ހ.֏.ؠ.ໟ.ގ.֏$ހ, reason: contains not printable characters */
    public static final class C3994 {

        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public final int f12608;

        /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
        public final int f12609;

        public C3994(int i, int i2) {
            this.f12608 = i;
            this.f12609 = i2;
        }
    }

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

    /* JADX WARN: Removed duplicated region for block: B:50:0x00e6  */
    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public static long m6426(String str, C3993 c3993) throws SubtitleDecoderException {
        double d;
        double d2;
        Matcher matcher = f12595.matcher(str);
        byte b = 2;
        if (matcher.matches()) {
            double d3 = (Long.parseLong(matcher.group(1)) * 3600) + (Long.parseLong(matcher.group(2)) * 60) + Long.parseLong(matcher.group(3));
            String strGroup = matcher.group(4);
            return (long) ((d3 + (strGroup != null ? Double.parseDouble(strGroup) : 0.0d) + (matcher.group(5) != null ? Long.parseLong(r14) / c3993.f12605 : 0.0d) + (matcher.group(6) != null ? (Long.parseLong(r14) / ((double) c3993.f12606)) / ((double) c3993.f12605) : 0.0d)) * 1000000.0d);
        }
        Matcher matcher2 = f12596.matcher(str);
        if (!matcher2.matches()) {
            throw new SubtitleDecoderException(C2803.m4879("Malformed time expression: ", str));
        }
        double d4 = Double.parseDouble(matcher2.group(1));
        String strGroup2 = matcher2.group(2);
        int iHashCode = strGroup2.hashCode();
        if (iHashCode != 102) {
            if (iHashCode != 104) {
                if (iHashCode != 109) {
                    if (iHashCode != 3494) {
                        if (iHashCode != 115) {
                            b = (iHashCode == 116 && strGroup2.equals("t")) ? (byte) 5 : (byte) -1;
                        } else if (!strGroup2.equals("s")) {
                        }
                    } else if (strGroup2.equals("ms")) {
                        b = 3;
                    }
                } else if (strGroup2.equals("m")) {
                    b = 1;
                }
            } else if (strGroup2.equals("h")) {
                b = 0;
            }
        } else if (strGroup2.equals("f")) {
            b = 4;
        }
        if (b == 0) {
            d = 3600.0d;
        } else {
            if (b != 1) {
                if (b == 3) {
                    d2 = 1000.0d;
                } else {
                    if (b != 4) {
                        if (b == 5) {
                            d2 = c3993.f12607;
                        }
                        return (long) (d4 * 1000000.0d);
                    }
                    d2 = c3993.f12605;
                }
                d4 /= d2;
                return (long) (d4 * 1000000.0d);
            }
            d = 60.0d;
        }
        d4 *= d;
        return (long) (d4 * 1000000.0d);
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static void m6427(String str, C3997 c3997) throws SubtitleDecoderException {
        Matcher matcher;
        String[] strArrM6781 = C4150.m6781(str, "\\s+");
        if (strArrM6781.length == 1) {
            matcher = f12597.matcher(str);
        } else {
            if (strArrM6781.length != 2) {
                throw new SubtitleDecoderException(C2803.m4882(C2803.m4889("Invalid number of entries for fontSize: "), strArrM6781.length, "."));
            }
            matcher = f12597.matcher(strArrM6781[1]);
            Log.w("TtmlDecoder", "Multiple values in fontSize attribute. Picking the second value for vertical font size and ignoring the first.");
        }
        if (!matcher.matches()) {
            throw new SubtitleDecoderException(C2803.m4880("Invalid expression for fontSize: '", str, "'."));
        }
        String strGroup = matcher.group(3);
        byte b = -1;
        int iHashCode = strGroup.hashCode();
        if (iHashCode != 37) {
            if (iHashCode != 3240) {
                if (iHashCode == 3592 && strGroup.equals("px")) {
                    b = 0;
                }
            } else if (strGroup.equals("em")) {
                b = 1;
            }
        } else if (strGroup.equals("%")) {
            b = 2;
        }
        if (b == 0) {
            c3997.f12640 = 1;
        } else if (b == 1) {
            c3997.f12640 = 2;
        } else {
            if (b != 2) {
                throw new SubtitleDecoderException(C2803.m4880("Invalid unit for fontSize: '", strGroup, "'."));
            }
            c3997.f12640 = 3;
        }
        c3997.f12641 = Float.valueOf(matcher.group(1)).floatValue();
    }

    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
    public static boolean m6428(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");
    }

    /* JADX WARN: Removed duplicated region for block: B:34:0x00c5  */
    /* JADX WARN: Removed duplicated region for block: B:47:0x0125  */
    /* JADX WARN: Removed duplicated region for block: B:63:0x015f  */
    /* JADX WARN: Removed duplicated region for block: B:67:0x0180  */
    /* JADX WARN: Removed duplicated region for block: B:74:0x019b  */
    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Map<String, C3997> m6429(XmlPullParser xmlPullParser, Map<String, C3997> map, C3992 c3992, C3994 c3994, Map<String, C3996> map2, Map<String, String> map3) throws XmlPullParserException, IOException {
        String strM1862;
        C3996 c3996;
        C3996 c39962;
        float f;
        float f2;
        String strM18622;
        float f3;
        float f4;
        String strM18623;
        float f5;
        int i;
        do {
            xmlPullParser.next();
            if (C0567.m1933(xmlPullParser, "style")) {
                String strM18624 = C0567.m1862(xmlPullParser, "style");
                C3997 c3997M6433 = m6433(xmlPullParser, new C3997());
                if (strM18624 != null) {
                    for (String str : m6435(strM18624)) {
                        c3997M6433.m6448(map.get(str));
                    }
                }
                String str2 = c3997M6433.f12642;
                if (str2 != null) {
                    map.put(str2, c3997M6433);
                }
            } else if (C0567.m1933(xmlPullParser, "region")) {
                String strM18625 = C0567.m1862(xmlPullParser, "id");
                if (strM18625 != null) {
                    String strM18626 = C0567.m1862(xmlPullParser, "origin");
                    if (strM18626 != null) {
                        Matcher matcher = f12598.matcher(strM18626);
                        Matcher matcher2 = f12599.matcher(strM18626);
                        if (matcher.matches()) {
                            try {
                                f = Float.parseFloat(matcher.group(1)) / 100.0f;
                                f2 = Float.parseFloat(matcher.group(2)) / 100.0f;
                                strM18622 = C0567.m1862(xmlPullParser, "extent");
                            } catch (NumberFormatException unused) {
                                C2803.m4901("Ignoring region with malformed origin: ", strM18626, "TtmlDecoder");
                            }
                            if (strM18622 == null) {
                                Matcher matcher3 = f12598.matcher(strM18622);
                                Matcher matcher4 = f12599.matcher(strM18622);
                                if (matcher3.matches()) {
                                    try {
                                        float f6 = Float.parseFloat(matcher3.group(1)) / 100.0f;
                                        f3 = Float.parseFloat(matcher3.group(2)) / 100.0f;
                                        f4 = f6;
                                        strM18623 = C0567.m1862(xmlPullParser, "displayAlign");
                                        if (strM18623 == null) {
                                            String strM6809 = C4150.m6809(strM18623);
                                            byte b = -1;
                                            int iHashCode = strM6809.hashCode();
                                            if (iHashCode != -1364013995) {
                                                if (iHashCode == 92734940 && strM6809.equals("after")) {
                                                    b = 1;
                                                }
                                            } else if (strM6809.equals("center")) {
                                                b = 0;
                                            }
                                            if (b == 0) {
                                                f5 = (f3 / 2.0f) + f2;
                                                i = 1;
                                            } else if (b != 1) {
                                                f5 = f2;
                                                i = 0;
                                            } else {
                                                f5 = f2 + f3;
                                                i = 2;
                                            }
                                            c3996 = new C3996(strM18625, f, f5, 0, i, f4, f3, 1, 1.0f / c3992.f12604);
                                        }
                                    } catch (NumberFormatException unused2) {
                                        C2803.m4901("Ignoring region with malformed extent: ", strM18626, "TtmlDecoder");
                                        c3996 = null;
                                    }
                                } else if (!matcher4.matches()) {
                                    C2803.m4901("Ignoring region with unsupported extent: ", strM18626, "TtmlDecoder");
                                } else if (c3994 == null) {
                                    C2803.m4901("Ignoring region with missing tts:extent: ", strM18626, "TtmlDecoder");
                                } else {
                                    try {
                                        float f7 = Integer.parseInt(matcher4.group(1)) / c3994.f12608;
                                        f3 = Integer.parseInt(matcher4.group(2)) / c3994.f12609;
                                        f4 = f7;
                                        strM18623 = C0567.m1862(xmlPullParser, "displayAlign");
                                        if (strM18623 == null) {
                                        }
                                    } catch (NumberFormatException unused3) {
                                        C2803.m4901("Ignoring region with malformed extent: ", strM18626, "TtmlDecoder");
                                        c3996 = null;
                                    }
                                }
                                c39962 = c3996;
                                if (c39962 != null) {
                                    map2.put(c39962.f12622, c39962);
                                }
                            } else {
                                Log.w("TtmlDecoder", "Ignoring region without an extent");
                            }
                        } else if (!matcher2.matches()) {
                            C2803.m4901("Ignoring region with unsupported origin: ", strM18626, "TtmlDecoder");
                        } else if (c3994 == null) {
                            C2803.m4901("Ignoring region with missing tts:extent: ", strM18626, "TtmlDecoder");
                        } else {
                            try {
                                float f8 = Integer.parseInt(matcher2.group(1)) / c3994.f12608;
                                float f9 = Integer.parseInt(matcher2.group(2)) / c3994.f12609;
                                f = f8;
                                f2 = f9;
                                strM18622 = C0567.m1862(xmlPullParser, "extent");
                                if (strM18622 == null) {
                                }
                            } catch (NumberFormatException unused4) {
                                C2803.m4901("Ignoring region with malformed origin: ", strM18626, "TtmlDecoder");
                            }
                        }
                    } else {
                        Log.w("TtmlDecoder", "Ignoring region without an origin");
                    }
                    c3996 = null;
                    c39962 = c3996;
                    if (c39962 != null) {
                    }
                } else {
                    c3996 = null;
                    c39962 = c3996;
                    if (c39962 != null) {
                    }
                }
            } else if (C0567.m1933(xmlPullParser, "metadata")) {
                do {
                    xmlPullParser.next();
                    if (C0567.m1933(xmlPullParser, "image") && (strM1862 = C0567.m1862(xmlPullParser, "id")) != null) {
                        map3.put(strM1862, xmlPullParser.nextText());
                    }
                } while (!C0567.m1923(xmlPullParser, "metadata"));
            }
        } while (!C0567.m1923(xmlPullParser, "head"));
        return map;
    }

    @Override // p138.p176.p177.p190.p226.AbstractC3947
    /* JADX INFO: renamed from: ֏ */
    public InterfaceC3949 mo6372(byte[] bArr, int i, boolean z) throws SubtitleDecoderException {
        C3998 c3998;
        C3993 c3993;
        try {
            XmlPullParser xmlPullParserNewPullParser = this.f12603.newPullParser();
            Map<String, C3997> map = new HashMap<>();
            HashMap map2 = new HashMap();
            Map<String, String> map3 = new HashMap<>();
            map2.put("", new C3996(null, -3.4028235E38f, -3.4028235E38f, Integer.MIN_VALUE, Integer.MIN_VALUE, -3.4028235E38f, -3.4028235E38f, Integer.MIN_VALUE, -3.4028235E38f));
            C3994 c3994M6436 = null;
            xmlPullParserNewPullParser.setInput(new ByteArrayInputStream(bArr, 0, i), null);
            ArrayDeque arrayDeque = new ArrayDeque();
            C3993 c3993M6431 = f12601;
            C3992 c3992M6430 = f12602;
            C3998 c39982 = null;
            int i2 = 0;
            for (int eventType = xmlPullParserNewPullParser.getEventType(); eventType != 1; eventType = xmlPullParserNewPullParser.getEventType()) {
                C3995 c3995 = (C3995) arrayDeque.peek();
                if (i2 == 0) {
                    String name = xmlPullParserNewPullParser.getName();
                    if (eventType == 2) {
                        if ("tt".equals(name)) {
                            c3993M6431 = m6431(xmlPullParserNewPullParser);
                            c3992M6430 = m6430(xmlPullParserNewPullParser, f12602);
                            c3994M6436 = m6436(xmlPullParserNewPullParser);
                        }
                        C3994 c3994 = c3994M6436;
                        C3993 c39932 = c3993M6431;
                        C3992 c3992 = c3992M6430;
                        if (m6428(name)) {
                            if ("head".equals(name)) {
                                c3998 = c39982;
                                c3993 = c39932;
                                m6429(xmlPullParserNewPullParser, map, c3992, c3994, map2, map3);
                            } else {
                                c3998 = c39982;
                                c3993 = c39932;
                                try {
                                    C3995 c3995M6432 = m6432(xmlPullParserNewPullParser, c3995, map2, c3993);
                                    arrayDeque.push(c3995M6432);
                                    if (c3995 != null) {
                                        c3995.m6445(c3995M6432);
                                    }
                                } catch (SubtitleDecoderException e) {
                                    C4131.m6646("TtmlDecoder", "Suppressing parser error", e);
                                    i2++;
                                }
                            }
                            c3993M6431 = c3993;
                            c3994M6436 = c3994;
                            c3992M6430 = c3992;
                        } else {
                            Log.i("TtmlDecoder", "Ignoring unsupported tag: " + xmlPullParserNewPullParser.getName());
                            i2++;
                            c3993M6431 = c39932;
                            c3994M6436 = c3994;
                            c3992M6430 = c3992;
                        }
                    } else {
                        c3998 = c39982;
                        if (eventType == 4) {
                            C3995 c3995M6438 = C3995.m6438(xmlPullParserNewPullParser.getText());
                            if (c3995.f12621 == null) {
                                c3995.f12621 = new ArrayList();
                            }
                            c3995.f12621.add(c3995M6438);
                        } else if (eventType == 3) {
                            c39982 = xmlPullParserNewPullParser.getName().equals("tt") ? new C3998((C3995) arrayDeque.peek(), map, map2, map3) : c3998;
                            arrayDeque.pop();
                        }
                    }
                    xmlPullParserNewPullParser.next();
                } else {
                    c3998 = c39982;
                    if (eventType == 2) {
                        i2++;
                    } else if (eventType == 3) {
                        i2--;
                    }
                }
                c39982 = c3998;
                xmlPullParserNewPullParser.next();
            }
            return c39982;
        } catch (IOException e2) {
            throw new IllegalStateException("Unexpected error when reading input.", e2);
        } catch (XmlPullParserException e3) {
            throw new SubtitleDecoderException("Unable to decode source", e3);
        }
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final C3992 m6430(XmlPullParser xmlPullParser, C3992 c3992) throws SubtitleDecoderException {
        String attributeValue = xmlPullParser.getAttributeValue("http://www.w3.org/ns/ttml#parameter", "cellResolution");
        if (attributeValue == null) {
            return c3992;
        }
        Matcher matcher = f12600.matcher(attributeValue);
        if (!matcher.matches()) {
            C2803.m4901("Ignoring malformed cell resolution: ", attributeValue, "TtmlDecoder");
            return c3992;
        }
        try {
            int i = Integer.parseInt(matcher.group(1));
            int i2 = Integer.parseInt(matcher.group(2));
            if (i != 0 && i2 != 0) {
                return new C3992(i, i2);
            }
            throw new SubtitleDecoderException("Invalid cell resolution " + i + " " + i2);
        } catch (NumberFormatException unused) {
            C2803.m4901("Ignoring malformed cell resolution: ", attributeValue, "TtmlDecoder");
            return c3992;
        }
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final C3993 m6431(XmlPullParser xmlPullParser) throws SubtitleDecoderException {
        String attributeValue = xmlPullParser.getAttributeValue("http://www.w3.org/ns/ttml#parameter", "frameRate");
        int i = attributeValue != null ? Integer.parseInt(attributeValue) : 30;
        float f = 1.0f;
        String attributeValue2 = xmlPullParser.getAttributeValue("http://www.w3.org/ns/ttml#parameter", "frameRateMultiplier");
        if (attributeValue2 != null) {
            if (C4150.m6781(attributeValue2, " ").length != 2) {
                throw new SubtitleDecoderException("frameRateMultiplier doesn't have 2 parts");
            }
            f = Integer.parseInt(r2[0]) / Integer.parseInt(r2[1]);
        }
        int i2 = f12601.f12606;
        String attributeValue3 = xmlPullParser.getAttributeValue("http://www.w3.org/ns/ttml#parameter", "subFrameRate");
        if (attributeValue3 != null) {
            i2 = Integer.parseInt(attributeValue3);
        }
        int i3 = f12601.f12607;
        String attributeValue4 = xmlPullParser.getAttributeValue("http://www.w3.org/ns/ttml#parameter", "tickRate");
        if (attributeValue4 != null) {
            i3 = Integer.parseInt(attributeValue4);
        }
        return new C3993(i * f, i2, i3);
    }

    /* JADX WARN: Can't fix incorrect switch cases order, some code will duplicate */
    /* JADX WARN: Failed to restore switch over string. Please report as a decompilation issue */
    /* JADX WARN: Removed duplicated region for block: B:25:0x0075  */
    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final C3995 m6432(XmlPullParser xmlPullParser, C3995 c3995, Map<String, C3996> map, C3993 c3993) throws SubtitleDecoderException {
        long j;
        byte b;
        int attributeCount = xmlPullParser.getAttributeCount();
        C3997 c3997M6433 = m6433(xmlPullParser, (C3997) null);
        String[] strArr = null;
        String strSubstring = null;
        String str = "";
        long jM6426 = -9223372036854775807L;
        long jM64262 = -9223372036854775807L;
        long jM64263 = -9223372036854775807L;
        for (int i = 0; i < attributeCount; i++) {
            String attributeName = xmlPullParser.getAttributeName(i);
            String attributeValue = xmlPullParser.getAttributeValue(i);
            switch (attributeName.hashCode()) {
                case -934795532:
                    b = attributeName.equals("region") ? (byte) 4 : (byte) -1;
                    break;
                case 99841:
                    if (attributeName.equals("dur")) {
                        b = 2;
                        break;
                    }
                    break;
                case 100571:
                    if (attributeName.equals("end")) {
                        b = 1;
                        break;
                    }
                    break;
                case 93616297:
                    if (attributeName.equals("begin")) {
                        b = 0;
                        break;
                    }
                    break;
                case 109780401:
                    if (attributeName.equals("style")) {
                        b = 3;
                        break;
                    }
                    break;
                case 1292595405:
                    if (attributeName.equals("backgroundImage")) {
                        b = 5;
                        break;
                    }
                    break;
            }
            if (b == 0) {
                jM6426 = m6426(attributeValue, c3993);
            } else if (b == 1) {
                jM64262 = m6426(attributeValue, c3993);
            } else if (b == 2) {
                jM64263 = m6426(attributeValue, c3993);
            } else if (b == 3) {
                String[] strArrM6435 = m6435(attributeValue);
                if (strArrM6435.length > 0) {
                    strArr = strArrM6435;
                }
            } else if (b != 4) {
                if (b == 5 && attributeValue.startsWith("#")) {
                    strSubstring = attributeValue.substring(1);
                }
            } else if (map.containsKey(attributeValue)) {
                str = attributeValue;
            }
        }
        if (c3995 != null) {
            long j2 = c3995.f12613;
            j = -9223372036854775807L;
            if (j2 != -9223372036854775807L) {
                if (jM6426 != -9223372036854775807L) {
                    jM6426 += j2;
                }
                if (jM64262 != -9223372036854775807L) {
                    jM64262 += c3995.f12613;
                }
            }
        } else {
            j = -9223372036854775807L;
        }
        if (jM64262 == j) {
            if (jM64263 != j) {
                jM64262 = jM6426 + jM64263;
            } else if (c3995 != null) {
                long j3 = c3995.f12614;
                if (j3 != j) {
                    jM64262 = j3;
                }
            }
        }
        return new C3995(xmlPullParser.getName(), null, jM6426, jM64262, c3997M6433, strArr, str, strSubstring);
    }

    /* JADX WARN: Can't fix incorrect switch cases order, some code will duplicate */
    /* JADX WARN: Failed to restore switch over string. Please report as a decompilation issue */
    /* JADX WARN: Removed duplicated region for block: B:34:0x0078  */
    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final C3997 m6433(XmlPullParser xmlPullParser, C3997 c3997) {
        String attributeValue;
        byte b;
        int attributeCount = xmlPullParser.getAttributeCount();
        for (int i = 0; i < attributeCount; i++) {
            attributeValue = xmlPullParser.getAttributeValue(i);
            b = -1;
            switch (xmlPullParser.getAttributeName(i)) {
                case "id":
                    if (!"style".equals(xmlPullParser.getName())) {
                        break;
                    } else {
                        c3997 = m6434(c3997);
                        c3997.f12642 = attributeValue;
                        break;
                    }
                    break;
                case "backgroundColor":
                    c3997 = m6434(c3997);
                    try {
                        c3997.f12634 = C4122.m6625(attributeValue, false);
                        c3997.f12635 = true;
                        break;
                    } catch (IllegalArgumentException unused) {
                        C2803.m4901("Failed parsing background value: ", attributeValue, "TtmlDecoder");
                        break;
                    }
                    break;
                case "color":
                    c3997 = m6434(c3997);
                    try {
                        int iM6625 = C4122.m6625(attributeValue, false);
                        if (c3997 == null) {
                            throw null;
                        }
                        C0567.m1932(true);
                        c3997.f12632 = iM6625;
                        c3997.f12633 = true;
                        break;
                    } catch (IllegalArgumentException unused2) {
                        C2803.m4901("Failed parsing color value: ", attributeValue, "TtmlDecoder");
                        break;
                    }
                    break;
                case "fontFamily":
                    c3997 = m6434(c3997);
                    if (c3997 == null) {
                        throw null;
                    }
                    C0567.m1932(true);
                    c3997.f12631 = attributeValue;
                    break;
                    break;
                case "fontSize":
                    try {
                        c3997 = m6434(c3997);
                        m6427(attributeValue, c3997);
                        break;
                    } catch (SubtitleDecoderException unused3) {
                        C2803.m4901("Failed parsing fontSize value: ", attributeValue, "TtmlDecoder");
                        break;
                    }
                    break;
                case "fontWeight":
                    c3997 = m6434(c3997);
                    boolean zEqualsIgnoreCase = "bold".equalsIgnoreCase(attributeValue);
                    if (c3997 == null) {
                        throw null;
                    }
                    C0567.m1932(true);
                    c3997.f12638 = zEqualsIgnoreCase ? 1 : 0;
                    break;
                    break;
                case "fontStyle":
                    c3997 = m6434(c3997);
                    boolean zEqualsIgnoreCase2 = "italic".equalsIgnoreCase(attributeValue);
                    if (c3997 == null) {
                        throw null;
                    }
                    C0567.m1932(true);
                    c3997.f12639 = zEqualsIgnoreCase2 ? 1 : 0;
                    break;
                    break;
                case "textAlign":
                    String strM6809 = C4150.m6809(attributeValue);
                    switch (strM6809.hashCode()) {
                        case -1364013995:
                            if (strM6809.equals("center")) {
                                b = 4;
                            }
                            break;
                        case 100571:
                            if (strM6809.equals("end")) {
                                b = 3;
                            }
                            break;
                        case 3317767:
                            if (strM6809.equals("left")) {
                                b = 0;
                            }
                            break;
                        case 108511772:
                            if (strM6809.equals("right")) {
                                b = 2;
                            }
                            break;
                        case 109757538:
                            if (strM6809.equals("start")) {
                                b = 1;
                            }
                            break;
                    }
                    if (b == 0) {
                        c3997 = m6434(c3997);
                        c3997.f12643 = Layout.Alignment.ALIGN_NORMAL;
                        break;
                    } else {
                        if (b == 1) {
                            c3997 = m6434(c3997);
                            c3997.f12643 = Layout.Alignment.ALIGN_NORMAL;
                        } else if (b == 2) {
                            c3997 = m6434(c3997);
                            c3997.f12643 = Layout.Alignment.ALIGN_OPPOSITE;
                        } else if (b == 3) {
                            c3997 = m6434(c3997);
                            c3997.f12643 = Layout.Alignment.ALIGN_OPPOSITE;
                        } else if (b == 4) {
                            c3997 = m6434(c3997);
                            c3997.f12643 = Layout.Alignment.ALIGN_CENTER;
                        }
                        break;
                    }
                    break;
                case "textDecoration":
                    String strM68092 = C4150.m6809(attributeValue);
                    switch (strM68092.hashCode()) {
                        case -1461280213:
                            if (strM68092.equals("nounderline")) {
                                b = 3;
                            }
                            break;
                        case -1026963764:
                            if (strM68092.equals("underline")) {
                                b = 2;
                            }
                            break;
                        case 913457136:
                            if (strM68092.equals("nolinethrough")) {
                                b = 1;
                            }
                            break;
                        case 1679736913:
                            if (strM68092.equals("linethrough")) {
                                b = 0;
                            }
                            break;
                    }
                    if (b == 0) {
                        c3997 = m6434(c3997);
                        if (c3997 == null) {
                            throw null;
                        }
                        C0567.m1932(true);
                        c3997.f12636 = 1;
                        break;
                    } else {
                        if (b == 1) {
                            c3997 = m6434(c3997);
                            if (c3997 == null) {
                                throw null;
                            }
                            C0567.m1932(true);
                            c3997.f12636 = 0;
                        } else if (b == 2) {
                            c3997 = m6434(c3997);
                            if (c3997 == null) {
                                throw null;
                            }
                            C0567.m1932(true);
                            c3997.f12637 = 1;
                        } else if (b == 3) {
                            c3997 = m6434(c3997);
                            if (c3997 == null) {
                                throw null;
                            }
                            C0567.m1932(true);
                            c3997.f12637 = 0;
                        } else {
                            continue;
                        }
                        break;
                    }
                    break;
            }
        }
        return c3997;
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final C3997 m6434(C3997 c3997) {
        return c3997 == null ? new C3997() : c3997;
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final String[] m6435(String str) {
        String strTrim = str.trim();
        return strTrim.isEmpty() ? new String[0] : C4150.m6781(strTrim, "\\s+");
    }

    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
    public final C3994 m6436(XmlPullParser xmlPullParser) {
        String strM1862 = C0567.m1862(xmlPullParser, "extent");
        if (strM1862 == null) {
            return null;
        }
        Matcher matcher = f12599.matcher(strM1862);
        if (!matcher.matches()) {
            C2803.m4901("Ignoring non-pixel tts extent: ", strM1862, "TtmlDecoder");
            return null;
        }
        try {
            return new C3994(Integer.parseInt(matcher.group(1)), Integer.parseInt(matcher.group(2)));
        } catch (NumberFormatException unused) {
            C2803.m4901("Ignoring malformed tts extent: ", strM1862, "TtmlDecoder");
            return null;
        }
    }
}
