package p82; import i5.c; import i5.d; import j5.q; import java.io.IOException; import java.io.InputStream; import java.io.UnsupportedEncodingException; import java.util.ArrayList; import java.util.Iterator; import org.w3c.dom.DOMException; public class b { /* renamed from: a reason: collision with root package name */ public static final /* synthetic */ int f126794a = 0; /* renamed from: p82.b$b reason: collision with other inner class name */ public static class C2287b { /* renamed from: a reason: collision with root package name */ public byte[] f126795a; public C2287b() { } public C2287b(a aVar) { } } static { try { ((q) d.f85123a).e("http://ns.google.com/photos/1.0/panorama/", "GPano"); } catch (i5.b unused) { } } /* JADX WARNING: Code restructure failed: missing block: B:32:0x0068, code lost: if (r9 == null) goto L_0x006d; */ /* JADX WARNING: Removed duplicated region for block: B:54:0x00a2 */ /* JADX WARNING: Removed duplicated region for block: B:76:0x0075 A[SYNTHETIC] */ public static c a(InputStream inputStream) { ArrayList arrayList; boolean z14; int length; int read; try { if (inputStream.read() == 255) { if (inputStream.read() == 216) { arrayList = new ArrayList(); while (true) { int read2 = inputStream.read(); if (read2 != -1) { if (read2 != 255) { break; } do { read = inputStream.read(); } while (read == 255); if (read != -1) { if (read != 218) { int read3 = inputStream.read(); int read4 = inputStream.read(); if (read3 != -1 && read4 != -1) { int i14 = (read3 << 8) | read4; if (read == 225) { C2287b bVar = new C2287b(null); int i15 = i14 - 2; byte[] bArr = new byte[i15]; bVar.f126795a = bArr; inputStream.read(bArr, 0, i15); arrayList.add(bVar); } else { inputStream.skip((long) (i14 - 2)); } } } } } try { inputStream.close(); break; } catch (IOException unused) { } } } } } catch (IOException unused2) { } catch (Throwable th4) { if (inputStream != null) { try { inputStream.close(); } catch (IOException unused3) { } } throw th4; } try { inputStream.close(); break; } catch (IOException unused4) { } arrayList = null; if (arrayList == null) { return null; } Iterator it3 = arrayList.iterator(); while (it3.hasNext()) { C2287b bVar2 = (C2287b) it3.next(); byte[] bArr2 = bVar2.f126795a; if (bArr2.length >= 29) { try { byte[] bArr3 = new byte[29]; System.arraycopy(bArr2, 0, bArr3, 0, 29); if (new String(bArr3, "UTF-8").equals("http://ns.adobe.com/xap/1.0/\u0000")) { z14 = true; if (!z14) { byte[] bArr4 = bVar2.f126795a; int length2 = bArr4.length - 1; while (true) { if (length2 >= 1) { if (bArr4[length2] == 62 && bArr4[length2 - 1] != 63) { length = length2 + 1; break; } length2--; } else { length = bArr4.length; break; } } int i16 = length - 29; byte[] bArr5 = new byte[i16]; System.arraycopy(bVar2.f126795a, 29, bArr5, 0, i16); try { return d.a(bArr5); } catch (i5.b | DOMException unused5) { continue; } } } } catch (UnsupportedEncodingException unused6) { } } z14 = false; if (!z14) { } } return null; } }