package com.applovin.impl; import android.text.TextUtils; import java.util.ArrayList; /* loaded from: classes.dex */ public final class yr extends ek { private final bh o; private final ur p; public yr() { super("WebvttDecoder"); this.o = new bh(); this.p = new ur(); } @Override // com.applovin.impl.ek public nl a(byte[] bArr, int i, boolean z) { wr a; this.o.a(bArr, i); ArrayList arrayList = new ArrayList(); try { zr.b(this.o); while (!TextUtils.isEmpty(this.o.l())) { } ArrayList arrayList2 = new ArrayList(); while (true) { int a2 = a(this.o); if (a2 == 0) { return new as(arrayList2); } if (a2 == 1) { b(this.o); } else if (a2 == 2) { if (arrayList2.isEmpty()) { this.o.l(); arrayList.addAll(this.p.c(this.o)); } else { throw new pl("A style block was found after the first cue."); } } else if (a2 == 3 && (a = xr.a(this.o, arrayList)) != null) { arrayList2.add(a); } } } catch (dh e) { throw new pl(e); } } private static void b(bh bhVar) { while (!TextUtils.isEmpty(bhVar.l())) { } } private static int a(bh bhVar) { int i = -1; int i2 = 0; while (i == -1) { i2 = bhVar.d(); String l = bhVar.l(); if (l == null) { i = 0; } else if ("STYLE".equals(l)) { i = 2; } else { i = l.startsWith("NOTE") ? 1 : 3; } } bhVar.f(i2); return i; } }