package tv.danmaku.ijk.media.player.ui.subtitleconverter.subtitleFile;

import androidx.media3.exoplayer.rtsp.SessionDescription;
import androidx.media3.exoplayer.upstream.CmcdConfiguration;
import androidx.media3.exoplayer.upstream.CmcdData;
import com.bytedance.sdk.component.adexpress.dynamic.dynamicview.b;
import com.google.android.gms.measurement.internal.u1;
import defpackage.e;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.Charset;
import java.util.ArrayList;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
import u.a;
import xyz.stream.download.config.InnerConstant;

/* JADX INFO: loaded from: classes3.dex */
public class FormatTTML implements TimedTextFileFormat {
    private String parseColor(String str, TimedTextObject timedTextObject) {
        if (str.startsWith("#")) {
            if (str.length() == 7) {
                return str.substring(1) + "ff";
            }
            if (str.length() == 9) {
                return str.substring(1);
            }
            timedTextObject.warnings = b.h(new StringBuilder(), timedTextObject.warnings, "Unrecoginzed format: ", str, "\n\n");
            return "ffffffff";
        }
        if (!str.startsWith("rgb")) {
            String rGBValue = Style.getRGBValue("name", str);
            if (rGBValue != null && !rGBValue.isEmpty()) {
                return rGBValue;
            }
            timedTextObject.warnings = b.h(new StringBuilder(), timedTextObject.warnings, "Unrecoginzed color: ", str, "\n\n");
            return "ffffffff";
        }
        boolean zStartsWith = str.startsWith("rgba");
        try {
            String[] strArrSplit = str.split("\\(")[1].split(",");
            int i10 = Integer.parseInt(strArrSplit[0]);
            int i11 = Integer.parseInt(strArrSplit[1]);
            int i12 = Integer.parseInt(strArrSplit[2].substring(0, 2));
            int i13 = zStartsWith ? Integer.parseInt(strArrSplit[3].substring(0, 2)) : 255;
            strArrSplit[0] = Integer.toHexString(i10);
            strArrSplit[1] = Integer.toHexString(i11);
            strArrSplit[2] = Integer.toHexString(i12);
            if (zStartsWith) {
                strArrSplit[2] = Integer.toHexString(i13);
            }
            String str2 = "";
            for (int i14 = 0; i14 < strArrSplit.length; i14++) {
                if (strArrSplit[i14].length() < 2) {
                    strArrSplit[i14] = SessionDescription.SUPPORTED_SDP_VERSION + strArrSplit[i14];
                }
                str2 = str2 + strArrSplit[i14];
            }
            if (zStartsWith) {
                return str2;
            }
            return str2 + "ff";
        } catch (Exception unused) {
            timedTextObject.warnings = b.h(new StringBuilder(), timedTextObject.warnings, "Unrecoginzed color: ", str, "\n\n");
            return "ffffffff";
        }
    }

    private int parseTimeExpression(String str, TimedTextObject timedTextObject, Document document) {
        Node nodeItem;
        int i10;
        double d10;
        int i11;
        int i12 = 0;
        if (str.contains(":")) {
            String[] strArrSplit = str.split(":");
            if (strArrSplit.length == 3) {
                return (Integer.parseInt(strArrSplit[1]) * 60000) + (Integer.parseInt(strArrSplit[0]) * 3600000) + ((int) (Float.parseFloat(strArrSplit[2]) * 1000.0f));
            }
            if (strArrSplit.length != 4) {
                return 0;
            }
            Node nodeItem2 = document.getElementsByTagName("ttp:frameRate").item(0);
            if (nodeItem2 != null) {
                try {
                    i11 = Integer.parseInt(nodeItem2.getNodeValue());
                } catch (NumberFormatException unused) {
                    i11 = 25;
                }
            } else {
                i11 = 25;
            }
            return (Integer.parseInt(strArrSplit[2]) * 1000) + (Integer.parseInt(strArrSplit[1]) * 60000) + (Integer.parseInt(strArrSplit[0]) * 3600000) + ((int) ((Float.parseFloat(strArrSplit[3]) * 1000.0f) / i11));
        }
        String strSubstring = str.substring(str.length() - 1);
        try {
            double d11 = Double.parseDouble(str.substring(0, str.length() - 1).replace(',', '.').trim());
            if (strSubstring.equalsIgnoreCase(CmcdData.STREAMING_FORMAT_HLS)) {
                d10 = 3600000.0d;
            } else {
                if (!strSubstring.equalsIgnoreCase(CmcdData.OBJECT_TYPE_MANIFEST)) {
                    if (strSubstring.equalsIgnoreCase(CmcdData.STREAMING_FORMAT_SS)) {
                        d11 *= 1000.0d;
                    } else if (!strSubstring.equalsIgnoreCase("ms")) {
                        if (strSubstring.equalsIgnoreCase("f")) {
                            Node nodeItem3 = document.getElementsByTagName("ttp:frameRate").item(0);
                            if (nodeItem3 == null) {
                                return 0;
                            }
                            i10 = Integer.parseInt(nodeItem3.getNodeValue());
                        } else {
                            if (!strSubstring.equalsIgnoreCase("t") || (nodeItem = document.getElementsByTagName("ttp:tickRate").item(0)) == null) {
                                return 0;
                            }
                            i10 = Integer.parseInt(nodeItem.getNodeValue());
                        }
                        d11 = (d11 * 1000.0d) / ((double) i10);
                    }
                    i12 = (int) d11;
                    return i12;
                }
                d10 = 60000.0d;
            }
            d11 *= d10;
            i12 = (int) d11;
            return i12;
        } catch (NumberFormatException unused2) {
            return i12;
        }
    }

    @Override // tv.danmaku.ijk.media.player.ui.subtitleconverter.subtitleFile.TimedTextFileFormat
    public TimedTextObject parseFile(String str, InputStream inputStream) throws FatalParsingException, IOException {
        return parseFile(str, inputStream, Charset.defaultCharset());
    }

    /* JADX WARN: Removed duplicated region for block: B:111:0x02c8 A[Catch: Exception -> 0x0044, TryCatch #0 {Exception -> 0x0044, blocks: (B:3:0x0013, B:5:0x003d, B:8:0x0047, B:10:0x0053, B:11:0x0059, B:13:0x0065, B:14:0x006b, B:15:0x008b, B:18:0x0093, B:20:0x00ac, B:21:0x00b2, B:23:0x00ba, B:24:0x00c0, B:26:0x00c6, B:28:0x00d2, B:29:0x00e6, B:31:0x00ee, B:32:0x00f8, B:34:0x0100, B:35:0x010a, B:37:0x0112, B:38:0x0118, B:40:0x0120, B:41:0x0126, B:44:0x0130, B:46:0x013c, B:49:0x014a, B:51:0x0154, B:52:0x0157, B:53:0x0159, B:55:0x0161, B:57:0x016d, B:58:0x0171, B:60:0x017b, B:61:0x017d, B:63:0x0185, B:69:0x019b, B:71:0x01aa, B:72:0x01bb, B:73:0x01ea, B:75:0x01f2, B:77:0x01fe, B:80:0x020b, B:82:0x0217, B:84:0x0221, B:85:0x0226, B:86:0x022a, B:88:0x0232, B:90:0x023e, B:91:0x0242, B:93:0x024e, B:94:0x0250, B:96:0x025c, B:98:0x0262, B:100:0x0287, B:101:0x0293, B:103:0x0299, B:109:0x02c2, B:111:0x02c8, B:113:0x02d6, B:114:0x02d9, B:115:0x02fa, B:116:0x02ff, B:119:0x0307, B:121:0x0317, B:125:0x035a, B:122:0x0337, B:124:0x0347, B:126:0x035d, B:130:0x0370, B:131:0x0374, B:133:0x0380, B:134:0x0383, B:104:0x02a6, B:106:0x02ae), top: B:141:0x0013 }] */
    /* JADX WARN: Removed duplicated region for block: B:119:0x0307 A[Catch: Exception -> 0x0044, TRY_ENTER, TryCatch #0 {Exception -> 0x0044, blocks: (B:3:0x0013, B:5:0x003d, B:8:0x0047, B:10:0x0053, B:11:0x0059, B:13:0x0065, B:14:0x006b, B:15:0x008b, B:18:0x0093, B:20:0x00ac, B:21:0x00b2, B:23:0x00ba, B:24:0x00c0, B:26:0x00c6, B:28:0x00d2, B:29:0x00e6, B:31:0x00ee, B:32:0x00f8, B:34:0x0100, B:35:0x010a, B:37:0x0112, B:38:0x0118, B:40:0x0120, B:41:0x0126, B:44:0x0130, B:46:0x013c, B:49:0x014a, B:51:0x0154, B:52:0x0157, B:53:0x0159, B:55:0x0161, B:57:0x016d, B:58:0x0171, B:60:0x017b, B:61:0x017d, B:63:0x0185, B:69:0x019b, B:71:0x01aa, B:72:0x01bb, B:73:0x01ea, B:75:0x01f2, B:77:0x01fe, B:80:0x020b, B:82:0x0217, B:84:0x0221, B:85:0x0226, B:86:0x022a, B:88:0x0232, B:90:0x023e, B:91:0x0242, B:93:0x024e, B:94:0x0250, B:96:0x025c, B:98:0x0262, B:100:0x0287, B:101:0x0293, B:103:0x0299, B:109:0x02c2, B:111:0x02c8, B:113:0x02d6, B:114:0x02d9, B:115:0x02fa, B:116:0x02ff, B:119:0x0307, B:121:0x0317, B:125:0x035a, B:122:0x0337, B:124:0x0347, B:126:0x035d, B:130:0x0370, B:131:0x0374, B:133:0x0380, B:134:0x0383, B:104:0x02a6, B:106:0x02ae), top: B:141:0x0013 }] */
    /* JADX WARN: Removed duplicated region for block: B:133:0x0380 A[Catch: Exception -> 0x0044, LOOP:3: B:131:0x0374->B:133:0x0380, LOOP_END, TryCatch #0 {Exception -> 0x0044, blocks: (B:3:0x0013, B:5:0x003d, B:8:0x0047, B:10:0x0053, B:11:0x0059, B:13:0x0065, B:14:0x006b, B:15:0x008b, B:18:0x0093, B:20:0x00ac, B:21:0x00b2, B:23:0x00ba, B:24:0x00c0, B:26:0x00c6, B:28:0x00d2, B:29:0x00e6, B:31:0x00ee, B:32:0x00f8, B:34:0x0100, B:35:0x010a, B:37:0x0112, B:38:0x0118, B:40:0x0120, B:41:0x0126, B:44:0x0130, B:46:0x013c, B:49:0x014a, B:51:0x0154, B:52:0x0157, B:53:0x0159, B:55:0x0161, B:57:0x016d, B:58:0x0171, B:60:0x017b, B:61:0x017d, B:63:0x0185, B:69:0x019b, B:71:0x01aa, B:72:0x01bb, B:73:0x01ea, B:75:0x01f2, B:77:0x01fe, B:80:0x020b, B:82:0x0217, B:84:0x0221, B:85:0x0226, B:86:0x022a, B:88:0x0232, B:90:0x023e, B:91:0x0242, B:93:0x024e, B:94:0x0250, B:96:0x025c, B:98:0x0262, B:100:0x0287, B:101:0x0293, B:103:0x0299, B:109:0x02c2, B:111:0x02c8, B:113:0x02d6, B:114:0x02d9, B:115:0x02fa, B:116:0x02ff, B:119:0x0307, B:121:0x0317, B:125:0x035a, B:122:0x0337, B:124:0x0347, B:126:0x035d, B:130:0x0370, B:131:0x0374, B:133:0x0380, B:134:0x0383, B:104:0x02a6, B:106:0x02ae), top: B:141:0x0013 }] */
    /* JADX WARN: Removed duplicated region for block: B:71:0x01aa A[Catch: Exception -> 0x0044, NumberFormatException -> 0x01ea, TryCatch #0 {Exception -> 0x0044, blocks: (B:3:0x0013, B:5:0x003d, B:8:0x0047, B:10:0x0053, B:11:0x0059, B:13:0x0065, B:14:0x006b, B:15:0x008b, B:18:0x0093, B:20:0x00ac, B:21:0x00b2, B:23:0x00ba, B:24:0x00c0, B:26:0x00c6, B:28:0x00d2, B:29:0x00e6, B:31:0x00ee, B:32:0x00f8, B:34:0x0100, B:35:0x010a, B:37:0x0112, B:38:0x0118, B:40:0x0120, B:41:0x0126, B:44:0x0130, B:46:0x013c, B:49:0x014a, B:51:0x0154, B:52:0x0157, B:53:0x0159, B:55:0x0161, B:57:0x016d, B:58:0x0171, B:60:0x017b, B:61:0x017d, B:63:0x0185, B:69:0x019b, B:71:0x01aa, B:72:0x01bb, B:73:0x01ea, B:75:0x01f2, B:77:0x01fe, B:80:0x020b, B:82:0x0217, B:84:0x0221, B:85:0x0226, B:86:0x022a, B:88:0x0232, B:90:0x023e, B:91:0x0242, B:93:0x024e, B:94:0x0250, B:96:0x025c, B:98:0x0262, B:100:0x0287, B:101:0x0293, B:103:0x0299, B:109:0x02c2, B:111:0x02c8, B:113:0x02d6, B:114:0x02d9, B:115:0x02fa, B:116:0x02ff, B:119:0x0307, B:121:0x0317, B:125:0x035a, B:122:0x0337, B:124:0x0347, B:126:0x035d, B:130:0x0370, B:131:0x0374, B:133:0x0380, B:134:0x0383, B:104:0x02a6, B:106:0x02ae), top: B:141:0x0013 }] */
    @Override // tv.danmaku.ijk.media.player.ui.subtitleconverter.subtitleFile.TimedTextFileFormat
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public TimedTextObject parseFile(String str, InputStream inputStream, Charset charset) throws FatalParsingException, IOException {
        boolean z10;
        Node namedItem;
        NodeList childNodes;
        int i10;
        int i11;
        String hexString;
        TimedTextObject timedTextObject = new TimedTextObject();
        timedTextObject.fileName = str;
        try {
            Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new InputSource(new InputStreamReader(inputStream, charset)));
            document.getDocumentElement().normalize();
            Node nodeItem = document.getElementsByTagName("ttm:title").item(0);
            if (nodeItem != null) {
                timedTextObject.title = nodeItem.getTextContent();
            }
            Node nodeItem2 = document.getElementsByTagName("ttm:copyright").item(0);
            if (nodeItem2 != null) {
                timedTextObject.copyrigth = nodeItem2.getTextContent();
            }
            Node nodeItem3 = document.getElementsByTagName("ttm:desc").item(0);
            if (nodeItem3 != null) {
                timedTextObject.description = nodeItem3.getTextContent();
            }
            NodeList elementsByTagName = document.getElementsByTagName("style");
            NodeList elementsByTagName2 = document.getElementsByTagName("p");
            timedTextObject.warnings += "Styling attributes are only recognized inside a style definition, to be referenced later in the captions.\n\n";
            for (int i12 = 0; i12 < elementsByTagName.getLength(); i12++) {
                Style style = new Style(Style.defaultID());
                NamedNodeMap attributes = elementsByTagName.item(i12).getAttributes();
                Node namedItem2 = attributes.getNamedItem(InnerConstant.Db.f36069id);
                if (namedItem2 != null) {
                    style.iD = namedItem2.getNodeValue();
                }
                Node namedItem3 = attributes.getNamedItem("xml:id");
                if (namedItem3 != null) {
                    style.iD = namedItem3.getNodeValue();
                }
                Node namedItem4 = attributes.getNamedItem("style");
                if (namedItem4 != null && timedTextObject.styling.containsKey(namedItem4.getNodeValue())) {
                    style = new Style(style.iD, timedTextObject.styling.get(namedItem4.getNodeValue()));
                }
                Node namedItem5 = attributes.getNamedItem("tts:backgroundColor");
                if (namedItem5 != null) {
                    style.backgroundColor = parseColor(namedItem5.getNodeValue(), timedTextObject);
                }
                Node namedItem6 = attributes.getNamedItem("tts:color");
                if (namedItem6 != null) {
                    style.color = parseColor(namedItem6.getNodeValue(), timedTextObject);
                }
                Node namedItem7 = attributes.getNamedItem("tts:fontFamily");
                if (namedItem7 != null) {
                    style.font = namedItem7.getNodeValue();
                }
                Node namedItem8 = attributes.getNamedItem("tts:fontSize");
                if (namedItem8 != null) {
                    style.fontSize = namedItem8.getNodeValue();
                }
                Node namedItem9 = attributes.getNamedItem("tts:fontStyle");
                if (namedItem9 != null) {
                    if (namedItem9.getNodeValue().equalsIgnoreCase("italic") || namedItem9.getNodeValue().equalsIgnoreCase("oblique")) {
                        style.italic = true;
                    } else if (namedItem9.getNodeValue().equalsIgnoreCase("normal")) {
                        style.italic = false;
                    }
                }
                Node namedItem10 = attributes.getNamedItem("tts:fontWeight");
                if (namedItem10 != null) {
                    if (namedItem10.getNodeValue().equalsIgnoreCase("bold")) {
                        style.bold = true;
                    } else if (namedItem10.getNodeValue().equalsIgnoreCase("normal")) {
                        style.bold = false;
                    }
                }
                Node namedItem11 = attributes.getNamedItem("tts:opacity");
                if (namedItem11 != null) {
                    try {
                        float f10 = Float.parseFloat(namedItem11.getNodeValue());
                        float f11 = 1.0f;
                        if (f10 > 1.0f) {
                            f10 = f11;
                            hexString = Integer.toHexString((int) (f10 * 255.0f));
                            if (hexString.length() < 2) {
                                hexString = SessionDescription.SUPPORTED_SDP_VERSION + hexString;
                            }
                            style.color = style.color.substring(0, 6) + hexString;
                            style.backgroundColor = style.backgroundColor.substring(0, 6) + hexString;
                        } else {
                            f11 = 0.0f;
                            if (f10 < 0.0f) {
                                f10 = f11;
                            }
                            hexString = Integer.toHexString((int) (f10 * 255.0f));
                            if (hexString.length() < 2) {
                            }
                            style.color = style.color.substring(0, 6) + hexString;
                            style.backgroundColor = style.backgroundColor.substring(0, 6) + hexString;
                        }
                    } catch (NumberFormatException unused) {
                    }
                }
                Node namedItem12 = attributes.getNamedItem("tts:textAlign");
                if (namedItem12 != null) {
                    if (namedItem12.getNodeValue().equalsIgnoreCase("left") || namedItem12.getNodeValue().equalsIgnoreCase("start")) {
                        style.textAlign = "bottom-left";
                    } else if (namedItem12.getNodeValue().equalsIgnoreCase("right") || namedItem12.getNodeValue().equalsIgnoreCase("end")) {
                        style.textAlign = "bottom-right";
                    }
                }
                Node namedItem13 = attributes.getNamedItem("tts:textDecoration");
                if (namedItem13 != null) {
                    if (namedItem13.getNodeValue().equalsIgnoreCase("underline")) {
                        style.underline = true;
                    } else if (namedItem13.getNodeValue().equalsIgnoreCase("noUnderline")) {
                        style.underline = false;
                    }
                }
                timedTextObject.styling.put(style.iD, style);
            }
            for (int i13 = 0; i13 < elementsByTagName2.getLength(); i13++) {
                Caption caption = new Caption();
                caption.content = "";
                Node nodeItem4 = elementsByTagName2.item(i13);
                NamedNodeMap attributes2 = nodeItem4.getAttributes();
                Node namedItem14 = attributes2.getNamedItem("begin");
                caption.start = new Time("", "");
                caption.end = new Time("", "");
                if (namedItem14 != null) {
                    caption.start.mseconds = parseTimeExpression(namedItem14.getNodeValue(), timedTextObject, document);
                }
                Node namedItem15 = attributes2.getNamedItem("end");
                if (namedItem15 != null) {
                    caption.end.mseconds = parseTimeExpression(namedItem15.getNodeValue(), timedTextObject, document);
                } else {
                    Node namedItem16 = attributes2.getNamedItem("dur");
                    if (namedItem16 != null) {
                        caption.end.mseconds = caption.start.mseconds + parseTimeExpression(namedItem16.getNodeValue(), timedTextObject, document);
                    } else {
                        z10 = false;
                        namedItem = attributes2.getNamedItem("style");
                        if (namedItem != null) {
                            Style style2 = timedTextObject.styling.get(namedItem.getNodeValue());
                            if (style2 != null) {
                                caption.style = style2;
                            } else {
                                timedTextObject.warnings += "unrecoginzed style referenced: " + namedItem.getNodeValue() + "\n\n";
                            }
                        }
                        childNodes = nodeItem4.getChildNodes();
                        for (i10 = 0; i10 < childNodes.getLength(); i10++) {
                            if (childNodes.item(i10).getNodeName().equals("#text")) {
                                caption.content += childNodes.item(i10).getTextContent().trim();
                            } else if (childNodes.item(i10).getNodeName().equals(CmcdConfiguration.KEY_BITRATE)) {
                                caption.content += "<br />";
                            }
                        }
                        if (!caption.content.replaceAll("<br />", "").trim().isEmpty() && z10) {
                            i11 = caption.start.mseconds;
                            while (timedTextObject.captions.containsKey(Integer.valueOf(i11))) {
                                i11++;
                            }
                            timedTextObject.captions.put(Integer.valueOf(i11), caption);
                        }
                    }
                }
                z10 = true;
                namedItem = attributes2.getNamedItem("style");
                if (namedItem != null) {
                }
                childNodes = nodeItem4.getChildNodes();
                while (i10 < childNodes.getLength()) {
                }
                if (!caption.content.replaceAll("<br />", "").trim().isEmpty()) {
                    i11 = caption.start.mseconds;
                    while (timedTextObject.captions.containsKey(Integer.valueOf(i11))) {
                    }
                    timedTextObject.captions.put(Integer.valueOf(i11), caption);
                }
            }
            timedTextObject.built = true;
            return timedTextObject;
        } catch (Exception e10) {
            e10.printStackTrace();
            throw new FatalParsingException("Error during parsing: " + e10.getMessage());
        }
    }

    @Override // tv.danmaku.ijk.media.player.ui.subtitleconverter.subtitleFile.TimedTextFileFormat
    public String[] toFile(TimedTextObject timedTextObject) {
        if (!timedTextObject.built) {
            return null;
        }
        ArrayList arrayList = new ArrayList(timedTextObject.captions.size() + timedTextObject.styling.size() + 30);
        arrayList.add(0, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
        arrayList.add(1, "<tt xml:lang=\"" + timedTextObject.language + "\" xmlns=\"http://www.w3.org/ns/ttml\" xmlns:tts=\"http://www.w3.org/ns/ttml#styling\">");
        arrayList.add(2, "\t<head>");
        arrayList.add(3, "\t\t<metadata xmlns:ttm=\"http://www.w3.org/ns/ttml#metadata\">");
        String str = timedTextObject.title;
        arrayList.add(4, "\t\t\t<ttm:title>" + ((str == null || str.isEmpty()) ? timedTextObject.fileName : timedTextObject.title) + "</ttm:title>");
        String str2 = timedTextObject.copyrigth;
        int i10 = 5;
        if (str2 != null && !str2.isEmpty()) {
            arrayList.add(5, "\t\t\t<ttm:copyright>" + timedTextObject.copyrigth + "</ttm:copyright>");
            i10 = 6;
        }
        String str3 = timedTextObject.author;
        String strO = (str3 == null || str3.isEmpty()) ? "Converted by the Online Subtitle Converter developed by J. David Requejo\n" : e.o(new StringBuilder("Converted by the Online Subtitle Converter developed by J. David Requejo\n\n Original file by: "), timedTextObject.author, "\n");
        String str4 = timedTextObject.description;
        if (str4 != null && !str4.isEmpty()) {
            strO = e.o(a.c(strO), timedTextObject.description, "\n");
        }
        arrayList.add(i10, "\t\t\t<ttm:desc>" + strO + "\t\t\t</ttm:desc>");
        int i11 = i10 + 2;
        arrayList.add(i10 + 1, "\t\t</metadata>");
        int i12 = i10 + 3;
        arrayList.add(i11, "\t\t<styling>");
        for (Style style : timedTextObject.styling.values()) {
            String strO2 = e.o(new StringBuilder("\t\t\t<style xml:id=\""), style.iD, "\"");
            if (style.color != null) {
                strO2 = e.o(a.d(strO2, " tts:color=\"#"), style.color, "\"");
            }
            if (style.backgroundColor != null) {
                strO2 = e.o(a.d(strO2, " tts:backgroundColor=\"#"), style.backgroundColor, "\"");
            }
            if (style.font != null) {
                strO2 = e.o(a.d(strO2, " tts:fontFamily=\""), style.font, "\"");
            }
            if (style.fontSize != null) {
                strO2 = e.o(a.d(strO2, " tts:fontSize=\""), style.fontSize, "\"");
            }
            if (style.italic) {
                strO2 = u1.j(strO2, " tts:fontStyle=\"italic\"");
            }
            if (style.bold) {
                strO2 = u1.j(strO2, " tts:fontWeight=\"bold\"");
            }
            String strJ = u1.j(strO2, " tts:textAlign=\"");
            String strJ2 = style.textAlign.contains("left") ? u1.j(strJ, "left\"") : style.textAlign.contains("right") ? u1.j(strJ, "rigth\"") : u1.j(strJ, "center\"");
            if (style.underline) {
                strJ2 = u1.j(strJ2, " tts:textDecoration=\"underline\"");
            }
            arrayList.add(i12, u1.j(strJ2, " />"));
            i12++;
        }
        arrayList.add(i12, "\t\t</styling>");
        arrayList.add(i12 + 1, "\t</head>");
        int i13 = i12 + 3;
        arrayList.add(i12 + 2, "\t<body>");
        int i14 = i12 + 4;
        arrayList.add(i13, "\t\t<div>");
        for (Caption caption : timedTextObject.captions.values()) {
            StringBuilder sbD = a.d("\t\t\t<p begin=\"" + caption.start.getTime("hh:mm:ss,ms").replace(',', '.') + "\"", " end=\"");
            sbD.append(caption.end.getTime("hh:mm:ss,ms").replace(',', '.'));
            sbD.append("\"");
            String string = sbD.toString();
            if (caption.style != null) {
                string = e.o(a.d(string, " style=\""), caption.style.iD, "\"");
            }
            arrayList.add(i14, e.o(a.d(string, " >"), caption.content, "</p>\n"));
            i14++;
        }
        arrayList.add(i14, "\t\t</div>");
        arrayList.add(i14 + 1, "\t</body>");
        arrayList.add(i14 + 2, "</tt>");
        arrayList.add(i14 + 3, "");
        int size = arrayList.size();
        String[] strArr = new String[size];
        for (int i15 = 0; i15 < size; i15++) {
            strArr[i15] = (String) arrayList.get(i15);
        }
        return strArr;
    }
}
