package z1;

import java.nio.charset.StandardCharsets;
import java.util.regex.Pattern;
import u0.F;
import x0.o;
import x0.v;

/* JADX INFO: renamed from: z1.i, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes.dex */
public abstract class AbstractC1789i {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public static final Pattern f19230a = Pattern.compile("^NOTE([ \t].*)?$");

    public static boolean a(o oVar) {
        oVar.getClass();
        String strH = oVar.h(StandardCharsets.UTF_8);
        return strH != null && strH.startsWith("WEBVTT");
    }

    public static float b(String str) {
        if (str.endsWith("%")) {
            return Float.parseFloat(str.substring(0, str.length() - 1)) / 100.0f;
        }
        throw new NumberFormatException("Percentages must end with %");
    }

    public static long c(String str) {
        int i = v.f18553a;
        String[] strArrSplit = str.split("\\.", 2);
        long j8 = 0;
        for (String str2 : strArrSplit[0].split(":", -1)) {
            j8 = (j8 * 60) + Long.parseLong(str2);
        }
        long j9 = j8 * 1000;
        if (strArrSplit.length == 2) {
            String strTrim = strArrSplit[1].trim();
            if (strTrim.length() != 3) {
                throw new IllegalArgumentException("Expected 3 decimal places, got: ".concat(strTrim));
            }
            j9 += Long.parseLong(strTrim);
        }
        return j9 * 1000;
    }

    public static void d(o oVar) throws F {
        int i = oVar.f18540b;
        if (a(oVar)) {
            return;
        }
        oVar.F(i);
        throw F.a(null, "Expected WEBVTT. Got " + oVar.h(StandardCharsets.UTF_8));
    }
}
