package o; import com.adobe.internal.xmp.XMPException; import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; import java.util.List; import okhttp3.HttpUrl; import org.bouncycastle.asn1.cmp.PKIFailureInfo; /* loaded from: classes.dex */ final class sfI implements Comparable { boolean a; boolean b; boolean c; boolean d; List e; String f; C14373frw g; List h; String i; sfI j; public sfI(String str, String str2, C14373frw c14373frw) { this.e = null; this.h = null; this.f = str; this.i = str2; this.g = c14373frw; } public sfI(String str, C14373frw c14373frw) { this(str, null, c14373frw); } public final sfI b(int i) { if (this.e == null) { this.e = new ArrayList(0); } return (sfI) this.e.get(i - 1); } public final void e(sfI sfi) { if (this.e == null) { this.e = new ArrayList(0); } this.e.remove(sfi); if (this.e.isEmpty()) { this.e = null; } } public final sfI d(int i) { if (this.h == null) { this.h = new ArrayList(0); } return (sfI) this.h.get(i - 1); } public final void b(sfI sfi) { if (this.g == null) { this.g = new C14373frw(); } C14373frw c14373frw = this.g; if ("xml:lang".equals(sfi.f)) { c14373frw.a &= -65; } else if ("rdf:type".equals(sfi.f)) { c14373frw.a &= -129; } if (this.h == null) { this.h = new ArrayList(0); } this.h.remove(sfi); if (this.h.isEmpty()) { c14373frw.a &= -17; this.h = null; } } public final void a() { if (this.g == null) { this.g = new C14373frw(); } C14373frw c14373frw = this.g; c14373frw.a &= -17; c14373frw.a &= -65; c14373frw.a &= -129; this.h = null; } public final Object clone() { return d(false); } private Object d(boolean z) { C14373frw c14373frw; Iterator listIterator; String str; List list; String str2; List list2; try { if (this.g == null) { this.g = new C14373frw(); } c14373frw = new C14373frw(this.g.a); } catch (XMPException unused) { c14373frw = new C14373frw(); } sfI sfi = new sfI(this.f, this.i, c14373frw); try { List list3 = this.e; if (list3 != null) { if (list3 == null) { this.e = new ArrayList(0); } listIterator = this.e.iterator(); } else { listIterator = Collections.EMPTY_LIST.listIterator(); } while (listIterator.hasNext()) { sfI sfi2 = (sfI) listIterator.next(); if (!z || (((str2 = sfi2.i) != null && str2.length() != 0) || ((list2 = sfi2.e) != null && list2.size() > 0))) { sfI sfi3 = (sfI) sfi2.d(z); if (sfi3 != null) { sfi.c(sfi3); } } } Iterator e = e(); while (e.hasNext()) { sfI sfi4 = (sfI) e.next(); if (!z || (((str = sfi4.i) != null && str.length() != 0) || ((list = sfi4.e) != null && list.size() > 0))) { sfI sfi5 = (sfI) sfi4.d(z); if (sfi5 != null) { sfi.d(sfi5); } } } } catch (XMPException unused2) { } if (!z) { return sfi; } String str3 = sfi.i; if (str3 != null && str3.length() != 0) { return sfi; } List list4 = sfi.e; if (list4 == null || list4.size() <= 0) { return null; } return sfi; } @Override // java.lang.Comparable public final int compareTo(Object obj) { if (this.g == null) { this.g = new C14373frw(); } if ((this.g.a & PKIFailureInfo.systemUnavail) != 0) { return this.i.compareTo(((sfI) obj).i); } return this.f.compareTo(((sfI) obj).f); } /* JADX INFO: Access modifiers changed from: package-private */ public static sfI b(List list, String str) { if (list == null) { return null; } Iterator it = list.iterator(); while (it.hasNext()) { sfI sfi = (sfI) it.next(); if (sfi.f.equals(str)) { return sfi; } } return null; } private void a(String str) throws XMPException { if (HttpUrl.PATH_SEGMENT_ENCODE_SET_URI.equals(str)) { return; } if (this.e == null) { this.e = new ArrayList(0); } if (b(this.e, str) == null) { return; } StringBuilder sb = new StringBuilder("Duplicate property or field node '"); sb.append(str); sb.append("'"); throw new XMPException(sb.toString(), 203); } public final void a(sfI sfi) throws XMPException { a(sfi.f); sfi.j = this; if (this.e == null) { this.e = new ArrayList(0); } this.e.add(0, sfi); } public final void c(sfI sfi) throws XMPException { a(sfi.f); sfi.j = this; if (this.e == null) { this.e = new ArrayList(0); } this.e.add(sfi); } public final void d(sfI sfi) throws XMPException { String str = sfi.f; if (!HttpUrl.PATH_SEGMENT_ENCODE_SET_URI.equals(str) && b(this.h, str) != null) { StringBuilder sb = new StringBuilder("Duplicate '"); sb.append(str); sb.append("' qualifier"); throw new XMPException(sb.toString(), 203); } sfi.j = this; if (sfi.g == null) { sfi.g = new C14373frw(); } sfi.g.a |= 32; if (this.g == null) { this.g = new C14373frw(); } this.g.a |= 16; if ("xml:lang".equals(sfi.f)) { this.g.a |= 64; if (this.h == null) { this.h = new ArrayList(0); } this.h.add(0, sfi); return; } if ("rdf:type".equals(sfi.f)) { this.g.a |= 128; if (this.h == null) { this.h = new ArrayList(0); } this.h.add((this.g.a & 64) != 0 ? 1 : 0, sfi); return; } if (this.h == null) { this.h = new ArrayList(0); } this.h.add(sfi); } public final Iterator c() { List list = this.e; if (list != null) { if (list == null) { this.e = new ArrayList(0); } return this.e.iterator(); } return Collections.EMPTY_LIST.listIterator(); } public final Iterator e() { List list = this.h; if (list != null) { if (list == null) { this.h = new ArrayList(0); } return new Iterator(this, this.h.iterator()) { // from class: o.sfI.3 private Iterator b; private sfI e; { this.e = this; this.b = r2; } @Override // java.util.Iterator public final boolean hasNext() { return this.b.hasNext(); } @Override // java.util.Iterator public final Object next() { return this.b.next(); } @Override // java.util.Iterator public final void remove() { throw new UnsupportedOperationException("remove() is not allowed due to the internal contraints"); } }; } return Collections.EMPTY_LIST.iterator(); } }