package com.google.android.gms.internal.ads; import android.text.Html; import android.text.Spanned; import android.text.TextUtils; import androidx.annotation.VisibleForTesting; import com.mbridge.msdk.playercommon.exoplayer2.source.chunk.ChunkedTrackBlacklistUtil; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.regex.Matcher; import java.util.regex.Pattern; /* loaded from: classes3.dex */ public final class zzakz implements zzakf { private static final Pattern zza = Pattern.compile("\\s*((?:(\\d+):)?(\\d+):(\\d+)(?:,(\\d+))?)\\s*-->\\s*((?:(\\d+):)?(\\d+):(\\d+)(?:,(\\d+))?)\\s*"); private static final Pattern zzb = Pattern.compile("\\{\\\\.*?\\}"); private final StringBuilder zzc = new StringBuilder(); private final ArrayList zzd = new ArrayList(); private final zzdy zze = new zzdy(); @VisibleForTesting(otherwise = 2) public static float zzb(int i) { if (i == 0) { return 0.08f; } if (i == 1) { return 0.5f; } if (i == 2) { return 0.92f; } throw new IllegalArgumentException(); } private static long zzc(Matcher matcher, int i) { String group = matcher.group(i + 1); long parseLong = group != null ? Long.parseLong(group) * 3600000 : 0L; String group2 = matcher.group(i + 2); group2.getClass(); long parseLong2 = parseLong + (Long.parseLong(group2) * ChunkedTrackBlacklistUtil.DEFAULT_TRACK_BLACKLIST_MS); String group3 = matcher.group(i + 3); group3.getClass(); long parseLong3 = parseLong2 + (Long.parseLong(group3) * 1000); String group4 = matcher.group(i + 4); if (group4 != null) { parseLong3 += Long.parseLong(group4); } return parseLong3 * 1000; } /* 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 */ @Override // com.google.android.gms.internal.ads.zzakf public final void zza(byte[] bArr, int i, int i2, zzake zzakeVar, zzdb zzdbVar) { String str; char c; char c2; int i3; zzco zzp; this.zze.zzJ(bArr, i + i2); this.zze.zzL(i); Charset zzC = this.zze.zzC(); if (zzC == null) { zzC = StandardCharsets.UTF_8; } while (true) { String zzz = this.zze.zzz(zzC); if (zzz == null) { return; } if (zzz.length() != 0) { String zzz2 = this.zze.zzz(zzC); if (zzz2 == null) { zzdo.zzf("SubripParser", "Unexpected end"); return; } Matcher matcher = zza.matcher(zzz2); if (matcher.matches()) { long zzc = zzc(matcher, 1); long zzc2 = zzc(matcher, 6); int i4 = 0; this.zzc.setLength(0); this.zzd.clear(); String zzz3 = this.zze.zzz(zzC); while (!TextUtils.isEmpty(zzz3)) { if (this.zzc.length() > 0) { this.zzc.append("
"); } StringBuilder sb = this.zzc; ArrayList arrayList = this.zzd; String trim = zzz3.trim(); StringBuilder sb2 = new StringBuilder(trim); Matcher matcher2 = zzb.matcher(trim); int i5 = i4; while (matcher2.find()) { String group = matcher2.group(); arrayList.add(group); int start = matcher2.start() - i5; int length = group.length(); sb2.replace(start, start + length, ""); i5 += length; } sb.append(sb2.toString()); zzz3 = this.zze.zzz(zzC); i4 = 0; } Spanned fromHtml = Html.fromHtml(this.zzc.toString()); int i6 = 0; while (true) { if (i6 < this.zzd.size()) { str = (String) this.zzd.get(i6); if (!str.matches("\\{\\\\an[1-9]\\}")) { i6++; } } else { str = null; } } zzcm zzcmVar = new zzcm(); zzcmVar.zzl(fromHtml); if (str == null) { zzp = zzcmVar.zzp(); } else { switch (str.hashCode()) { case -685620710: if (str.equals("{\\an1}")) { c = 0; break; } c = 65535; break; case -685620648: if (str.equals("{\\an3}")) { c = 3; break; } c = 65535; break; case -685620617: if (str.equals("{\\an4}")) { c = 1; break; } c = 65535; break; case -685620555: if (str.equals("{\\an6}")) { c = 4; break; } c = 65535; break; case -685620524: if (str.equals("{\\an7}")) { c = 2; break; } c = 65535; break; case -685620462: if (str.equals("{\\an9}")) { c = 5; break; } c = 65535; break; default: c = 65535; break; } if (c == 0 || c == 1 || c == 2) { zzcmVar.zzi(0); } else if (c == 3 || c == 4 || c == 5) { zzcmVar.zzi(2); } else { zzcmVar.zzi(1); } switch (str.hashCode()) { case -685620710: if (str.equals("{\\an1}")) { c2 = 0; break; } c2 = 65535; break; case -685620679: if (str.equals("{\\an2}")) { c2 = 1; break; } c2 = 65535; break; case -685620648: if (str.equals("{\\an3}")) { c2 = 2; break; } c2 = 65535; break; case -685620524: if (str.equals("{\\an7}")) { c2 = 3; break; } c2 = 65535; break; case -685620493: if (str.equals("{\\an8}")) { c2 = 4; break; } c2 = 65535; break; case -685620462: if (str.equals("{\\an9}")) { c2 = 5; break; } c2 = 65535; break; default: c2 = 65535; break; } if (c2 == 0 || c2 == 1) { i3 = 2; } else if (c2 != 2) { if (c2 == 3 || c2 == 4 || c2 == 5) { zzcmVar.zzf(0); } else { zzcmVar.zzf(1); } zzcmVar.zzh(zzb(zzcmVar.zzb())); zzcmVar.zze(zzb(zzcmVar.zza()), 0); zzp = zzcmVar.zzp(); } else { i3 = 2; } zzcmVar.zzf(i3); zzcmVar.zzh(zzb(zzcmVar.zzb())); zzcmVar.zze(zzb(zzcmVar.zza()), 0); zzp = zzcmVar.zzp(); } zzdbVar.zza(new zzajx(zzfxn.zzo(zzp), zzc, zzc2 - zzc)); } else { zzdo.zzf("SubripParser", "Skipping invalid timing: ".concat(zzz2)); } } } } }