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 java.util.NoSuchElementException; import org.bouncycastle.asn1.cmp.PKIFailureInfo; /* loaded from: classes.dex */ public final class xQZ implements KfL { private Iterator d; C16758qxA e; String b = null; protected boolean c = false; private boolean a = false; public xQZ(C16814rTK c16814rTK, String str, C16758qxA c16758qxA) throws XMPException { sfI sfi; this.d = null; this.e = c16758qxA == null ? new C16758qxA() : c16758qxA; if (str == null || str.length() <= 0) { sfi = c16814rTK.b; } else { sfi = pmJ.e(c16814rTK.b, str, null, false); } if (sfi == null) { this.d = Collections.EMPTY_LIST.iterator(); } else if ((this.e.a & 256) == 0) { this.d = new LWm(this, sfi, null, 1); } else { this.d = new IeS(this, sfi, null); } } @Override // java.util.Iterator public final boolean hasNext() { return this.d.hasNext(); } @Override // java.util.Iterator public final Object next() { return this.d.next(); } @Override // java.util.Iterator public final void remove() { throw new UnsupportedOperationException("The XMPIterator does not support remove()."); } /* loaded from: classes.dex */ class LWm implements Iterator { private VYk a; private Iterator b; private int c; private String d; private int e; private xQZ f; private sfI g; private Iterator j; public LWm(xQZ xqz) { this.f = xqz; this.e = 0; this.b = null; this.c = 0; this.j = Collections.EMPTY_LIST.iterator(); this.a = null; } public LWm(xQZ xqz, sfI sfi, String str, int i) { this.f = xqz; this.e = 0; this.b = null; this.c = 0; this.j = Collections.EMPTY_LIST.iterator(); this.a = null; this.g = sfi; this.e = 0; if (sfi.g == null) { sfi.g = new C14373frw(); } if ((sfi.g.a & PKIFailureInfo.systemUnavail) != 0) { xqz.b = sfi.f; } this.d = c(sfi, str, i); } @Override // java.util.Iterator public boolean hasNext() { List list; Iterator listIterator; List list2; if (this.a != null) { return true; } int i = this.e; if (i == 0) { this.e = 1; if (this.g.j != null && ((this.f.e.a & 512) == 0 || (list2 = this.g.e) == null || list2.size() <= 0)) { this.a = e(this.g, this.f.b, this.d); return true; } return hasNext(); } if (i == 1) { if (this.b == null) { sfI sfi = this.g; if (sfi.e != null) { if (sfi.e == null) { sfi.e = new ArrayList(0); } listIterator = sfi.e.iterator(); } else { listIterator = Collections.EMPTY_LIST.listIterator(); } this.b = listIterator; } boolean d = d(this.b); if (d || (list = this.g.h) == null || list.size() <= 0 || (this.f.e.a & 4096) != 0) { return d; } this.e = 2; this.b = null; return hasNext(); } if (this.b == null) { this.b = this.g.e(); } return d(this.b); } private boolean d(Iterator it) { boolean z = this.f.c; if (!this.j.hasNext() && it.hasNext()) { sfI sfi = (sfI) it.next(); int i = this.c + 1; this.c = i; this.j = new LWm(this.f, sfi, this.d, i); } if (!this.j.hasNext()) { return false; } this.a = (VYk) this.j.next(); return true; } @Override // java.util.Iterator public Object next() { if (!hasNext()) { throw new NoSuchElementException("There are no more nodes to return"); } VYk vYk = this.a; this.a = null; return vYk; } @Override // java.util.Iterator public void remove() { throw new UnsupportedOperationException(); } protected final VYk e(sfI sfi, String str, String str2) { if (sfi.g == null) { sfi.g = new C14373frw(); } return new VYk(this, sfi, str, str2, (sfi.g.a & PKIFailureInfo.systemUnavail) != 0 ? null : sfi.i) { // from class: o.xQZ.LWm.3 private LWm a; private String b; private String c; private String d; private sfI e; { this.a = this; this.e = sfi; this.c = str; this.b = str2; this.d = r5; } @Override // o.VYk public final String c() { return this.d; } @Override // o.VYk public final String a() { return this.b; } }; } protected final String c(sfI sfi, String str, int i) { String str2; String str3; if (sfi.j == null) { return null; } if (sfi.g == null) { sfi.g = new C14373frw(); } if ((sfi.g.a & PKIFailureInfo.systemUnavail) != 0) { return null; } sfI sfi2 = sfi.j; if (sfi2.g == null) { sfi2.g = new C14373frw(); } if ((sfi2.g.a & 512) != 0) { StringBuilder sb = new StringBuilder("["); sb.append(String.valueOf(i)); sb.append("]"); str2 = sb.toString(); str3 = ""; } else { str2 = sfi.f; str3 = "/"; } if (str == null || str.length() == 0) { return str2; } if ((this.f.e.a & 1024) != 0) { return str2.startsWith("?") ? str2.substring(1) : str2; } StringBuilder sb2 = new StringBuilder(); sb2.append(str); sb2.append(str3); sb2.append(str2); return sb2.toString(); } protected final void a(VYk vYk) { this.a = vYk; } protected final VYk b() { return this.a; } } /* loaded from: classes.dex */ class IeS extends LWm { private Iterator a; private int b; private xQZ c; private String e; /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */ public IeS(xQZ xqz, sfI sfi, String str) { super(xqz); Iterator listIterator; this.c = xqz; this.b = 0; if (sfi.g == null) { sfi.g = new C14373frw(); } if ((sfi.g.a & PKIFailureInfo.systemUnavail) != 0) { xqz.b = sfi.f; } this.e = c(sfi, null, 1); if (sfi.e != null) { if (sfi.e == null) { sfi.e = new ArrayList(0); } listIterator = sfi.e.iterator(); } else { listIterator = Collections.EMPTY_LIST.listIterator(); } this.a = listIterator; } @Override // o.xQZ.LWm, java.util.Iterator public final boolean hasNext() { String c; List list; while (b() == null) { boolean z = this.c.c; if (!this.a.hasNext()) { return false; } sfI sfi = (sfI) this.a.next(); this.b++; if (sfi.g == null) { sfi.g = new C14373frw(); } if ((sfi.g.a & PKIFailureInfo.systemUnavail) != 0) { this.c.b = sfi.f; } else if (sfi.j != null) { c = c(sfi, this.e, this.b); if ((this.c.e.a & 512) != 0 || (list = sfi.e) == null || list.size() <= 0) { a(e(sfi, this.c.b, c)); return true; } } c = null; if ((this.c.e.a & 512) != 0) { } a(e(sfi, this.c.b, c)); return true; } return true; } } }