package e6; import e6.f; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.nio.ByteBuffer; import java.util.List; import o6.v; /* loaded from: classes2.dex */ public abstract class g { class a implements h { /* renamed from: a, reason: collision with root package name */ final /* synthetic */ InputStream f9353a; a(InputStream inputStream) { this.f9353a = inputStream; } @Override // e6.g.h public f.a a(e6.f fVar) { try { return fVar.b(this.f9353a); } finally { this.f9353a.reset(); } } } class b implements h { /* renamed from: a, reason: collision with root package name */ final /* synthetic */ ByteBuffer f9354a; b(ByteBuffer byteBuffer) { this.f9354a = byteBuffer; } @Override // e6.g.h public f.a a(e6.f fVar) { return fVar.a(this.f9354a); } } class c implements h { /* renamed from: a, reason: collision with root package name */ final /* synthetic */ f6.m f9355a; /* renamed from: b, reason: collision with root package name */ final /* synthetic */ i6.a f9356b; c(f6.m mVar, i6.a aVar) { this.f9355a = mVar; this.f9356b = aVar; } @Override // e6.g.h public f.a a(e6.f fVar) { v vVar; try { vVar = new v(new FileInputStream(this.f9355a.a().getFileDescriptor()), this.f9356b); } catch (Throwable th) { th = th; vVar = null; } try { f.a b10 = fVar.b(vVar); try { vVar.close(); } catch (IOException unused) { } this.f9355a.a(); return b10; } catch (Throwable th2) { th = th2; if (vVar != null) { try { vVar.close(); } catch (IOException unused2) { } } this.f9355a.a(); throw th; } } } class d implements InterfaceC0137g { /* renamed from: a, reason: collision with root package name */ final /* synthetic */ ByteBuffer f9357a; /* renamed from: b, reason: collision with root package name */ final /* synthetic */ i6.a f9358b; d(ByteBuffer byteBuffer, i6.a aVar) { this.f9357a = byteBuffer; this.f9358b = aVar; } @Override // e6.g.InterfaceC0137g public int a(e6.f fVar) { return fVar.c(this.f9357a, this.f9358b); } } class e implements InterfaceC0137g { /* renamed from: a, reason: collision with root package name */ final /* synthetic */ InputStream f9359a; /* renamed from: b, reason: collision with root package name */ final /* synthetic */ i6.a f9360b; e(InputStream inputStream, i6.a aVar) { this.f9359a = inputStream; this.f9360b = aVar; } @Override // e6.g.InterfaceC0137g public int a(e6.f fVar) { try { return fVar.d(this.f9359a, this.f9360b); } finally { this.f9359a.reset(); } } } class f implements InterfaceC0137g { /* renamed from: a, reason: collision with root package name */ final /* synthetic */ f6.m f9361a; /* renamed from: b, reason: collision with root package name */ final /* synthetic */ i6.a f9362b; f(f6.m mVar, i6.a aVar) { this.f9361a = mVar; this.f9362b = aVar; } @Override // e6.g.InterfaceC0137g public int a(e6.f fVar) { v vVar; try { vVar = new v(new FileInputStream(this.f9361a.a().getFileDescriptor()), this.f9362b); } catch (Throwable th) { th = th; vVar = null; } try { int d10 = fVar.d(vVar, this.f9362b); try { vVar.close(); } catch (IOException unused) { } this.f9361a.a(); return d10; } catch (Throwable th2) { th = th2; if (vVar != null) { try { vVar.close(); } catch (IOException unused2) { } } this.f9361a.a(); throw th; } } } /* renamed from: e6.g$g, reason: collision with other inner class name */ private interface InterfaceC0137g { int a(e6.f fVar); } private interface h { f.a a(e6.f fVar); } private static int a(List list, InterfaceC0137g interfaceC0137g) { int size = list.size(); for (int i10 = 0; i10 < size; i10++) { int a10 = interfaceC0137g.a((e6.f) list.get(i10)); if (a10 != -1) { return a10; } } return -1; } private static f.a b(List list, h hVar) { int size = list.size(); for (int i10 = 0; i10 < size; i10++) { f.a a10 = hVar.a((e6.f) list.get(i10)); if (a10 != f.a.UNKNOWN) { return a10; } } return f.a.UNKNOWN; } public static int c(List list, f6.m mVar, i6.a aVar) { return a(list, new f(mVar, aVar)); } public static int d(List list, InputStream inputStream, i6.a aVar) { if (inputStream == null) { return -1; } if (!inputStream.markSupported()) { inputStream = new v(inputStream, aVar); } inputStream.mark(5242880); return a(list, new e(inputStream, aVar)); } public static int e(List list, ByteBuffer byteBuffer, i6.a aVar) { if (byteBuffer == null) { return -1; } return a(list, new d(byteBuffer, aVar)); } public static f.a f(List list, f6.m mVar, i6.a aVar) { return b(list, new c(mVar, aVar)); } public static f.a g(List list, InputStream inputStream, i6.a aVar) { if (inputStream == null) { return f.a.UNKNOWN; } if (!inputStream.markSupported()) { inputStream = new v(inputStream, aVar); } inputStream.mark(5242880); return b(list, new a(inputStream)); } public static f.a h(List list, ByteBuffer byteBuffer) { return byteBuffer == null ? f.a.UNKNOWN : b(list, new b(byteBuffer)); } }