package com.ironsource; import com.ironsource.mediationsdk.IronSource; import com.ironsource.ng; import com.ironsource.sdk.controller.FeaturesManager; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.concurrent.locks.ReadWriteLock; import java.util.concurrent.locks.ReentrantReadWriteLock; import kotlin.NoWhenBranchMatchedException; import kotlin.TuplesKt; import kotlin.collections.CollectionsKt___CollectionsKt; import kotlin.collections.MapsKt__MapsKt; import kotlin.jvm.internal.Intrinsics; import kotlin.jvm.internal.SourceDebugExtension; import org.json.JSONObject; @SourceDebugExtension({"SMAP\nISessionHistoryService.kt\nKotlin\n*S Kotlin\n*F\n+ 1 ISessionHistoryService.kt\ncom/ironsource/services/sessionhistory/services/SessionHistoryManager\n+ 2 Maps.kt\nkotlin/collections/MapsKt__MapsKt\n+ 3 _Maps.kt\nkotlin/collections/MapsKt___MapsKt\n*L\n1#1,141:1\n361#2,7:142\n483#2,7:151\n215#3,2:149\n*S KotlinDebug\n*F\n+ 1 ISessionHistoryService.kt\ncom/ironsource/services/sessionhistory/services/SessionHistoryManager\n*L\n56#1:142,7\n103#1:151,7\n74#1:149,2\n*E\n"}) /* loaded from: classes2.dex */ public final class lr implements ng, ng.a { private Map a = new LinkedHashMap(); private final hm b = new hm(); private final ReadWriteLock c = new ReentrantReadWriteLock(); public /* synthetic */ class a { public static final /* synthetic */ int[] a; static { int[] iArr = new int[kr.values().length]; try { iArr[kr.CurrentlyLoadedAdsAndFullHistory.ordinal()] = 1; } catch (NoSuchFieldError unused) { } try { iArr[kr.CurrentlyLoadedAds.ordinal()] = 2; } catch (NoSuchFieldError unused2) { } try { iArr[kr.Off.ordinal()] = 3; } catch (NoSuchFieldError unused3) { } a = iArr; } } private final void b() { jr configuration = FeaturesManager.getInstance().getSessionHistoryConfig(); hm hmVar = this.b; Intrinsics.checkNotNullExpressionValue(configuration, "configuration"); hmVar.a(a(configuration)); this.b.a(a()); } @Override // com.ironsource.ng public int a(IronSource.AD_UNIT adFormat) { Intrinsics.checkNotNullParameter(adFormat, "adFormat"); this.c.readLock().lock(); try { v vVar = this.a.get(adFormat.toString()); return vVar != null ? vVar.a() : 0; } finally { this.c.readLock().unlock(); } } @Override // com.ironsource.ng public List a() { this.c.readLock().lock(); try { Map map = this.a; LinkedHashMap linkedHashMap = new LinkedHashMap(); for (Map.Entry entry : map.entrySet()) { if (entry.getValue().b()) { linkedHashMap.put(entry.getKey(), entry.getValue()); } } List list = CollectionsKt___CollectionsKt.toList(linkedHashMap.keySet()); this.c.readLock().unlock(); return list; } catch (Throwable th) { this.c.readLock().unlock(); throw th; } } @Override // com.ironsource.ng public Map a(jr configuration) { Map mutableMapOf; Intrinsics.checkNotNullParameter(configuration, "configuration"); this.c.readLock().lock(); try { int i = a.a[configuration.a().ordinal()]; if (i == 1) { mutableMapOf = MapsKt__MapsKt.mutableMapOf(TuplesKt.to(ad.h1, a(vr.FullHistory)), TuplesKt.to(ad.i1, a(vr.CurrentlyLoadedAds))); } else if (i == 2) { mutableMapOf = MapsKt__MapsKt.mutableMapOf(TuplesKt.to(ad.i1, a(vr.CurrentlyLoadedAds))); } else { if (i != 3) { throw new NoWhenBranchMatchedException(); } mutableMapOf = MapsKt__MapsKt.emptyMap(); } this.c.readLock().unlock(); return mutableMapOf; } catch (Throwable th) { this.c.readLock().unlock(); throw th; } } @Override // com.ironsource.ng public JSONObject a(vr mode) { Intrinsics.checkNotNullParameter(mode, "mode"); this.c.readLock().lock(); try { JSONObject jSONObject = new JSONObject(); for (Map.Entry entry : this.a.entrySet()) { String key = entry.getKey(); JSONObject a2 = entry.getValue().a(mode); if (a2.length() > 0) { jSONObject.put(key, a2); } } return jSONObject; } finally { this.c.readLock().unlock(); } } @Override // com.ironsource.ng.a public void a(mr historyRecord) { Intrinsics.checkNotNullParameter(historyRecord, "historyRecord"); this.c.writeLock().lock(); try { k0 a2 = historyRecord.a(); String valueOf = String.valueOf(a2 != null ? a2.b() : null); Map map = this.a; v vVar = map.get(valueOf); if (vVar == null) { vVar = new v(); map.put(valueOf, vVar); } vVar.a(historyRecord.a(new sr())); this.c.writeLock().unlock(); b(); } catch (Throwable th) { this.c.writeLock().unlock(); throw th; } } }