package com.unity3d.services.core.domain.task; import c9.p; import com.unity3d.services.core.domain.task.InitializeStateLoadCache; import com.unity3d.services.core.log.DeviceLog; import com.unity3d.services.core.misc.Utilities; import d9.j; import java.nio.charset.Charset; import java.util.concurrent.CancellationException; import kotlin.coroutines.jvm.internal.f; import kotlin.coroutines.jvm.internal.l; import s8.n; import s8.o; import s8.v; import v8.d; @f(c = "com.unity3d.services.core.domain.task.InitializeStateLoadCache$doWork$2", f = "InitializeStateLoadCache.kt", l = {}, m = "invokeSuspend") /* loaded from: classes2.dex */ final class InitializeStateLoadCache$doWork$2 extends l implements p { final /* synthetic */ InitializeStateLoadCache.Params $params; int label; final /* synthetic */ InitializeStateLoadCache this$0; /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */ InitializeStateLoadCache$doWork$2(InitializeStateLoadCache initializeStateLoadCache, InitializeStateLoadCache.Params params, d dVar) { super(2, dVar); this.this$0 = initializeStateLoadCache; this.$params = params; } @Override // kotlin.coroutines.jvm.internal.a public final d create(Object obj, d dVar) { j.e(dVar, "completion"); return new InitializeStateLoadCache$doWork$2(this.this$0, this.$params, dVar); } @Override // c9.p public final Object invoke(Object obj, Object obj2) { return ((InitializeStateLoadCache$doWork$2) create(obj, (d) obj2)).invokeSuspend(v.f14109a); } @Override // kotlin.coroutines.jvm.internal.a public final Object invokeSuspend(Object obj) { Object b10; byte[] webViewData; String Sha256; w8.d.c(); if (this.label != 0) { throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine"); } o.b(obj); try { n.a aVar = n.f14096b; DeviceLog.debug("Unity Ads init: check if webapp can be loaded from local cache"); webViewData = this.this$0.getWebViewData(); String str = null; if (webViewData != null && (Sha256 = Utilities.Sha256(webViewData)) != null && j.a(Sha256, this.$params.getConfig().getWebViewHash())) { Charset forName = Charset.forName("UTF-8"); j.d(forName, "Charset.forName(\"UTF-8\")"); String str2 = new String(webViewData, forName); DeviceLog.info("Unity Ads init: webapp loaded from local cache"); str = str2; } b10 = n.b(str); } catch (CancellationException e10) { throw e10; } catch (Throwable th) { n.a aVar2 = n.f14096b; b10 = n.b(o.a(th)); } if (n.g(b10)) { b10 = n.b(b10); } else { Throwable d10 = n.d(b10); if (d10 != null) { b10 = n.b(o.a(d10)); } } return n.a(b10); } }