package com.applovin.impl; import android.net.Uri; import android.webkit.MimeTypeMap; import com.applovin.impl.sdk.utils.CollectionUtils; import com.applovin.impl.sdk.utils.StringUtils; import com.facebook.internal.security.CertificateUtil; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.TimeUnit; /* loaded from: classes.dex */ public class nq { private List b; private int c; private Uri d; private gq f; private List a = Collections.emptyList(); private final Set e = new HashSet(); private final Map g = new HashMap(); public Set a() { return this.e; } public Uri b() { return this.d; } public int c() { return this.c; } public Map d() { return this.g; } public gq e() { return this.f; } public List f() { return this.a; } public String toString() { return "VastVideoCreative{videoFiles=" + this.a + ", durationSeconds=" + this.c + ", destinationUri=" + this.d + ", clickTrackers=" + this.e + ", eventTrackers=" + this.g + ", industryIcon=" + this.f + '}'; } private nq(eq eqVar) { this.b = Collections.emptyList(); this.b = eqVar.f(); } public static nq a(es esVar, nq nqVar, eq eqVar, com.applovin.impl.sdk.j jVar) { es c; gq a; List a2; es c2; List a3; es c3; int a4; if (esVar == null) { throw new IllegalArgumentException("No node specified."); } if (eqVar == null) { throw new IllegalArgumentException("No context specified."); } if (jVar != null) { if (nqVar == null) { try { nqVar = new nq(eqVar); } catch (Throwable th) { jVar.J(); if (com.applovin.impl.sdk.n.a()) { jVar.J().a("VastVideoCreative", "Error occurred while initializing", th); } jVar.E().a("VastVideoCreative", th); return null; } } if (nqVar.c == 0 && (c3 = esVar.c("Duration")) != null && (a4 = a(c3.d(), jVar)) > 0) { nqVar.c = a4; } es c4 = esVar.c("MediaFiles"); if (c4 != null && (a3 = a(c4, jVar)) != null && a3.size() > 0) { List list = nqVar.a; if (list != null) { a3.addAll(list); } nqVar.a = a3; } es c5 = esVar.c("VideoClicks"); if (c5 != null) { if (nqVar.d == null && (c2 = c5.c("ClickThrough")) != null) { String d = c2.d(); if (StringUtils.isValidString(d)) { nqVar.d = Uri.parse(d); } } mq.a(c5.a("ClickTracking"), nqVar.e, eqVar, jVar); } es c6 = esVar.c("Icons"); if (c6 != null && (a = gq.a((c = c6.c("Icon")), jVar)) != null) { es c7 = c.c("IconClicks"); if (c7 != null && (a2 = c7.a("IconClickTracking")) != null) { mq.a(a2, a.a, eqVar, jVar); } List a5 = c.a("IconViewTracking"); if (a5 != null) { mq.a(a5, a.b, eqVar, jVar); } nqVar.f = a; } mq.a(esVar, nqVar.g, eqVar, jVar); return nqVar; } throw new IllegalArgumentException("No sdk specified."); } public boolean equals(Object obj) { if (this == obj) { return true; } if (!(obj instanceof nq)) { return false; } nq nqVar = (nq) obj; if (this.c != nqVar.c) { return false; } List list = this.a; if (list == null ? nqVar.a != null : !list.equals(nqVar.a)) { return false; } Uri uri = this.d; if (uri == null ? nqVar.d != null : !uri.equals(nqVar.d)) { return false; } Set set = this.e; if (set == null ? nqVar.e != null : !set.equals(nqVar.e)) { return false; } Map map = this.g; Map map2 = nqVar.g; return map != null ? map.equals(map2) : map2 == null; } public int hashCode() { List list = this.a; int hashCode = (((list != null ? list.hashCode() : 0) * 31) + this.c) * 31; Uri uri = this.d; int hashCode2 = (hashCode + (uri != null ? uri.hashCode() : 0)) * 31; Set set = this.e; int hashCode3 = (hashCode2 + (set != null ? set.hashCode() : 0)) * 31; Map map = this.g; return hashCode3 + (map != null ? map.hashCode() : 0); } public oq a(long j) { List list = this.a; oq oqVar = null; if (list == null || list.size() == 0) { return null; } List arrayList = new ArrayList(3); for (String str : this.b) { for (oq oqVar2 : this.a) { String b = oqVar2.b(); if (StringUtils.isValidString(b) && str.equalsIgnoreCase(b)) { arrayList.add(oqVar2); } } if (!arrayList.isEmpty()) { break; } } if (arrayList.isEmpty()) { arrayList = this.a; } Collections.sort(arrayList, new Comparator() { // from class: com.applovin.impl.nq$$ExternalSyntheticLambda0 @Override // java.util.Comparator public final int compare(Object obj, Object obj2) { int a; a = nq.a((oq) obj, (oq) obj2); return a; } }); for (oq oqVar3 : arrayList) { if (oqVar3.a() > j) { break; } oqVar = oqVar3; } return oqVar != null ? oqVar : (oq) arrayList.get(0); } /* JADX INFO: Access modifiers changed from: private */ public static /* synthetic */ int a(oq oqVar, oq oqVar2) { return Long.compare(oqVar.a(), oqVar2.a()); } private static int a(String str, com.applovin.impl.sdk.j jVar) { try { if (CollectionUtils.explode(str, CertificateUtil.DELIMITER).size() == 3) { return (int) (TimeUnit.HOURS.toSeconds(StringUtils.parseInt(r1.get(0))) + TimeUnit.MINUTES.toSeconds(StringUtils.parseInt(r1.get(1))) + StringUtils.parseInt(r1.get(2))); } } catch (Throwable unused) { jVar.J(); if (com.applovin.impl.sdk.n.a()) { jVar.J().b("VastVideoCreative", "Unable to parse duration from \"" + str + "\""); } } return 0; } private static List a(es esVar, com.applovin.impl.sdk.j jVar) { List a = esVar.a("MediaFile"); ArrayList arrayList = new ArrayList(a.size()); List explode = CollectionUtils.explode((String) jVar.a(sj.W4)); List explode2 = CollectionUtils.explode((String) jVar.a(sj.V4)); Iterator it = a.iterator(); while (it.hasNext()) { oq a2 = oq.a((es) it.next(), jVar); if (a2 != null) { try { String b = a2.b(); if (StringUtils.isValidString(b) && !explode.contains(b)) { arrayList.add(a2); } else { if (((Boolean) jVar.a(sj.X4)).booleanValue()) { String fileExtensionFromUrl = MimeTypeMap.getFileExtensionFromUrl(a2.d().toString()); if (StringUtils.isValidString(fileExtensionFromUrl) && !explode2.contains(fileExtensionFromUrl)) { arrayList.add(a2); } } jVar.J(); if (com.applovin.impl.sdk.n.a()) { jVar.J().k("VastVideoCreative", "Video file not supported: " + a2); } } } catch (Throwable th) { jVar.J(); if (com.applovin.impl.sdk.n.a()) { jVar.J().a("VastVideoCreative", "Failed to validate video file: " + a2, th); } } } } return arrayList; } }