package com.applovin.impl.sdk; import com.applovin.impl.h0; import com.applovin.impl.sdk.ad.AppLovinAdImpl; import java.util.HashMap; import java.util.Map; /* loaded from: classes2.dex */ public class c { private final j a; private final n b; private final Map d = new HashMap(); private final Map e = new HashMap(); private final Object c = new Object(); public c(j jVar) { this.a = jVar; this.b = jVar.J(); for (h0 h0Var : h0.a()) { this.d.put(h0Var, new p()); this.e.put(h0Var, new p()); } } public AppLovinAdImpl e(h0 h0Var) { com.applovin.impl.sdk.ad.c cVar; synchronized (this.c) { try { p d = d(h0Var); if (d.b() > 0) { b(h0Var).a(d.a()); cVar = new com.applovin.impl.sdk.ad.c(h0Var, this.a); } else { cVar = null; } } catch (Throwable th) { throw th; } } if (cVar != null) { if (n.a()) { this.b.a("AdPreloadManager", "Retrieved ad of zone " + h0Var + "..."); } } else if (n.a()) { this.b.a("AdPreloadManager", "Unable to retrieve ad of zone " + h0Var + "..."); } return cVar; } public AppLovinAdImpl a(h0 h0Var) { AppLovinAdImpl a; synchronized (this.c) { a = c(h0Var).a(); } return a; } public void a(AppLovinAdImpl appLovinAdImpl) { synchronized (this.c) { try { d(appLovinAdImpl.getAdZone()).a(appLovinAdImpl); if (n.a()) { this.b.a("AdPreloadManager", "Ad enqueued: " + appLovinAdImpl); } } catch (Throwable th) { throw th; } } } public AppLovinAdBase f(h0 h0Var) { AppLovinAdImpl d; synchronized (this.c) { d = c(h0Var).d(); } return d; } private p d(h0 h0Var) { p pVar; synchronized (this.c) { try { pVar = (p) this.d.get(h0Var); if (pVar == null) { pVar = new p(); this.d.put(h0Var, pVar); } } catch (Throwable th) { throw th; } } return pVar; } private p b(h0 h0Var) { p pVar; synchronized (this.c) { try { pVar = (p) this.e.get(h0Var); if (pVar == null) { pVar = new p(); this.e.put(h0Var, pVar); } } catch (Throwable th) { throw th; } } return pVar; } public void b(AppLovinAdImpl appLovinAdImpl) { synchronized (this.c) { c(appLovinAdImpl.getAdZone()).b(appLovinAdImpl); } } private p c(h0 h0Var) { synchronized (this.c) { try { p b = b(h0Var); if (b.b() > 0) { return b; } return d(h0Var); } catch (Throwable th) { throw th; } } } }