package com.unity3d.services.core.domain.task; import c9.p; import com.unity3d.services.core.configuration.Configuration; import com.unity3d.services.core.configuration.ErrorState; import com.unity3d.services.core.domain.task.InitializeStateCreate; import com.unity3d.services.core.log.DeviceLog; import com.unity3d.services.core.webview.WebViewApp; import d9.j; 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.InitializeStateCreate$doWork$2", f = "InitializeStateCreate.kt", l = {}, m = "invokeSuspend") /* loaded from: classes2.dex */ final class InitializeStateCreate$doWork$2 extends l implements p { final /* synthetic */ InitializeStateCreate.Params $params; int label; /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */ InitializeStateCreate$doWork$2(InitializeStateCreate.Params params, d dVar) { super(2, dVar); this.$params = params; } @Override // kotlin.coroutines.jvm.internal.a public final d create(Object obj, d dVar) { j.e(dVar, "completion"); return new InitializeStateCreate$doWork$2(this.$params, dVar); } @Override // c9.p public final Object invoke(Object obj, Object obj2) { return ((InitializeStateCreate$doWork$2) create(obj, (d) obj2)).invokeSuspend(v.f14109a); } @Override // kotlin.coroutines.jvm.internal.a public final Object invokeSuspend(Object obj) { Object b10; Configuration config; ErrorState create; 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: creating webapp"); config = this.$params.getConfig(); config.setWebViewData(this.$params.getWebViewData()); try { create = WebViewApp.create(config, false); } catch (IllegalThreadStateException e10) { DeviceLog.exception("Illegal Thread", e10); throw new InitializationException(ErrorState.CreateWebApp, e10, config); } } catch (CancellationException e11) { throw e11; } catch (Throwable th) { n.a aVar2 = n.f14096b; b10 = n.b(o.a(th)); } if (create == null) { b10 = n.b(config); 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); } String str = "Unity Ads WebApp creation failed"; WebViewApp currentApp = WebViewApp.getCurrentApp(); j.d(currentApp, "WebViewApp.getCurrentApp()"); if (currentApp.getWebAppFailureMessage() != null) { WebViewApp currentApp2 = WebViewApp.getCurrentApp(); j.d(currentApp2, "WebViewApp.getCurrentApp()"); str = currentApp2.getWebAppFailureMessage(); } DeviceLog.error(str); throw new InitializationException(create, new Exception(str), config); } }