package i5; import j5.a; import j5.c; import j5.e; import j5.h; import j5.i; import j5.l; import j5.m; import j5.n; import j5.o; import j5.p; import j5.q; import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; import java.util.Calendar; import java.util.Collections; import java.util.Iterator; import java.util.Map; import k5.b; import okhttp3.HttpUrl; import org.w3c.dom.Document; import org.w3c.dom.Node; import org.xml.sax.InputSource; public final class d { /* renamed from: a reason: collision with root package name */ public static e f85123a = new q(); /* renamed from: b reason: collision with root package name */ public static g f85124b = null; /* JADX WARN: Type inference failed for: r2v2 */ /* JADX WARN: Type inference failed for: r2v4, types: [boolean, int] */ /* JADX WARN: Type inference failed for: r2v18 */ /* JADX WARNING: Removed duplicated region for block: B:161:0x03b4 */ /* JADX WARNING: Removed duplicated region for block: B:199:0x041d */ /* JADX WARNING: Unknown variable types count: 1 */ public static c a(byte[] bArr) throws b { Document document; boolean z14; boolean z15; n nVar; n nVar2; String str; n nVar3; String str2; String str3; Object obj = m.f90523a; if (!(bArr instanceof String) || ((String) bArr).length() != 0) { l5.d dVar = new l5.d(); if (bArr instanceof InputStream) { InputStream inputStream = (InputStream) bArr; if (dVar.c(16) || dVar.f()) { try { document = m.c(new a(inputStream), dVar); } catch (IOException e14) { throw new b("Error reading the XML-file", 204, e14); } } else { document = m.b(new InputSource(inputStream)); } } else { document = m.c(new a(bArr), dVar); } ?? r24 = 1; Object[] a14 = m.a(document, dVar.c(1), new Object[3]); if (a14 == null || a14[1] != m.f90523a) { return new l(); } boolean z16 = false; Node node = (Node) a14[0]; l lVar = new l(); if (node.hasAttributes()) { n nVar4 = lVar.f90522b; for (int i14 = 0; i14 < node.getChildNodes().getLength(); i14++) { Node item = node.getChildNodes().item(i14); if (!e.e(item)) { e.h(lVar, nVar4, item, true); } } int i15 = 2; String str4 = (String) a14[2]; if (dVar.c(32)) { return lVar; } Map map = p.f90536a; n nVar5 = lVar.f90522b; o.f(nVar5, "http://purl.org/dc/elements/1.1/", true); Iterator B = lVar.f90522b.B(); while (B.hasNext()) { n nVar6 = (n) B.next(); if ("http://purl.org/dc/elements/1.1/".equals(nVar6.f90525b)) { int i16 = r24 == true ? 1 : 0; Object[] objArr = r24 == true ? 1 : 0; Object[] objArr2 = r24 == true ? 1 : 0; for (int i17 = i16; i17 <= nVar6.m(); i17++) { n j14 = nVar6.j(i17); l5.e eVar = (l5.e) p.f90536a.get(j14.f90525b); if (eVar != null) { if ((j14.n().f105535a & 768) == 0 ? r24 : z16) { n nVar7 = new n(j14.f90525b, null, eVar); j14.f90525b = HttpUrl.PATH_SEGMENT_ENCODE_SET_URI; nVar7.c(j14); nVar7.f90527d = nVar6; nVar6.l().set(i17 - 1, nVar7); if (eVar.h() && !j14.n().f()) { j14.d(new n("xml:lang", "x-default", null)); } } else { j14.n().e(7680, z16); j14.n().m(eVar); if (eVar.h()) { p.b(j14); } } } } } else { if ("http://ns.adobe.com/exif/1.0/".equals(nVar6.f90525b)) { n c14 = o.c(nVar6, "exif:GPSTimeStamp", z16); if (c14 != null) { try { a a15 = f.a(c14.f90526c); if (((i) a15).f90493b == 0 && ((i) a15).f90494c == 0) { if (((i) a15).f90495d == 0) { n c15 = o.c(nVar6, "exif:DateTimeOriginal", z16); if (c15 == null) { c15 = o.c(nVar6, "exif:DateTimeDigitized", z16); } a a16 = f.a(c15.f90526c); Calendar m14 = ((i) a15).m1(); m14.set(r24, ((i) a16).f90493b); m14.set(i15, ((i) a16).f90494c); m14.set(5, ((i) a16).f90495d); c14.f90526c = c.a(new i(m14)); } } } catch (b unused) { } } nVar2 = o.c(nVar6, "exif:UserComment", z16); if (nVar2 == null) { } } else { if ("http://ns.adobe.com/xmp/1.0/DynamicMedia/".equals(nVar6.f90525b)) { n c16 = o.c(nVar6, "xmpDM:copyright", z16); if (c16 != null) { try { n f14 = o.f(lVar.f90522b, "http://purl.org/dc/elements/1.1/", r24); String str5 = c16.f90526c; n c17 = o.c(f14, "dc:rights", z16); if (c17 != null) { if (c17.y()) { int h14 = o.h(c17, "x-default"); if (h14 < 0) { int i18 = r24 == true ? 1 : 0; int i19 = r24 == true ? 1 : 0; int i24 = r24 == true ? 1 : 0; String str6 = c17.j(i18).f90526c; str2 = str5; try { lVar.a("http://purl.org/dc/elements/1.1/", "rights", "", "x-default", str6, null); nVar3 = c17; h14 = o.h(nVar3, "x-default"); str = "\n\n"; } catch (b unused2) { } } else { nVar3 = c17; str = "\n\n"; str2 = str5; } n j15 = nVar3.j(h14); String str7 = j15.f90526c; int indexOf = str7.indexOf(str); if (indexOf < 0) { if (!str2.equals(str7)) { str3 = str7 + str + str2; } c16.f90527d.D(c16); } else { int i25 = indexOf + 2; if (!str7.substring(i25).equals(str2)) { StringBuilder sb4 = new StringBuilder(); try { sb4.append(str7.substring(0, i25)); sb4.append(str2); str3 = sb4.toString(); } catch (b unused3) { z16 = false; } } c16.f90527d.D(c16); } j15.f90526c = str3; c16.f90527d.D(c16); } } lVar.a("http://purl.org/dc/elements/1.1/", "rights", "", "x-default", "\n\n" + str5, null); c16.f90527d.D(c16); } catch (b unused4) { } } } else if ("http://ns.adobe.com/xap/1.0/rights/".equals(nVar6.f90525b)) { z16 = false; nVar2 = o.c(nVar6, "xmpRights:UsageTerms", false); if (nVar2 == null) { } } z16 = false; } p.b(nVar2); } r24 = 1; i15 = 2; } if (nVar5.f90532i) { nVar5.f90532i = z16; boolean c18 = dVar.c(4); for (n nVar8 : Collections.unmodifiableList(new ArrayList(nVar5.l()))) { if (nVar8.f90532i) { Iterator B2 = nVar8.B(); while (B2.hasNext()) { n nVar9 = (n) B2.next(); if (nVar9.f90533j) { nVar9.f90533j = false; m5.a a17 = ((q) f85123a).a(nVar9.f90525b); if (a17 != null) { n e15 = o.e(nVar5, a17.c(), null, true); e15.f90531h = false; n c19 = o.c(e15, a17.d() + a17.a(), false); l5.a b14 = a17.b(); if (c19 != null) { if (!(b14.f105535a == 0)) { if (a17.b().c(4096)) { int h15 = o.h(c19, "x-default"); if (h15 != -1) { nVar = c19.j(h15); z15 = true; if (nVar != null) { if (c18) { p.a(nVar9, nVar, z15); } } } } else if (c19.y()) { z15 = true; nVar = c19.j(1); if (nVar != null) { } } z15 = true; nVar = null; if (nVar != null) { } } else if (c18) { p.a(nVar9, c19, true); } B2.remove(); } else if (b14.f105535a == 0) { nVar9.f90525b = a17.d() + a17.a(); e15.c(nVar9); B2.remove(); } else { c19 = new n(a17.d() + a17.a(), null, new l5.e(a17.b().f105535a)); e15.c(c19); } p.c(B2, nVar9, c19); } } } nVar8.f90532i = false; } } } String str8 = nVar5.f90525b; if (str8 != null && str8.length() >= 36) { String lowerCase = nVar5.f90525b.toLowerCase(); if (lowerCase.startsWith("uuid:")) { lowerCase = lowerCase.substring(5); } boolean[] zArr = h.f90491a; if (lowerCase != null) { boolean z17 = true; int i26 = 0; int i27 = 0; while (i27 < lowerCase.length()) { if (lowerCase.charAt(i27) == '-') { i26++; z17 = z17 && (i27 == 8 || i27 == 13 || i27 == 18 || i27 == 23); } i27++; } if (z17 && 4 == i26 && 36 == i27) { z14 = true; if (z14) { n d14 = o.d(nVar5, b.a("http://ns.adobe.com/xap/1.0/mm/", "InstanceID"), true, null); if (d14 != null) { d14.f90530g = null; d14.f90526c = a1.a.a("uuid:", lowerCase); d14.f90528e = null; l5.e n14 = d14.n(); n14.e(16, false); n14.e(64, false); n14.e(128, false); d14.f90529f = null; nVar5.f90525b = null; } else { throw new b("Failure creating xmpMM:InstanceID", 9); } } } } z14 = false; if (z14) { } } Iterator B3 = nVar5.B(); while (B3.hasNext()) { if (!((n) B3.next()).y()) { B3.remove(); } } return lVar; } throw new b("Invalid attributes of rdf:RDF element", 202); } throw new b("Parameter must not be null or empty", 4); } }