package defpackage;

import android.app.Activity;
import com.bumptech.glide.f;
import dev.fluttercommunity.plus.wakelock.NoActivityException;
import e.y;
import ed.e;
import ed.i;
import ed.p;
import java.util.List;
import kd.c;
import kotlin.a;
import nb.g;

/* JADX INFO: loaded from: classes.dex */
public final class f {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public static final /* synthetic */ f f25888a = new f();

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public static final c f25889b = a.c(new c(0));

    public static void a(f fVar, i iVar, final g gVar) {
        fVar.getClass();
        String strConcat = "".length() > 0 ? ".".concat("") : "";
        String strI = e.i("dev.flutter.pigeon.wakelock_plus_platform_interface.WakelockPlusApi.toggle", strConcat);
        c cVar = f25889b;
        e eVar = new e(iVar, strI, (p) cVar.getValue(), null);
        if (gVar != null) {
            final int i10 = 0;
            eVar.setMessageHandler(new ed.c() { // from class: d
                @Override // ed.c
                public final void onMessage(Object obj, ed.d dVar) {
                    List listW;
                    List listW2;
                    Object obj2;
                    int i11 = i10;
                    g gVar2 = gVar;
                    switch (i11) {
                        case 0:
                            g.i(dVar, "reply");
                            g.g(obj, "null cannot be cast to non-null type kotlin.collections.List<kotlin.Any?>");
                            Object obj3 = ((List) obj).get(0);
                            g.g(obj3, "null cannot be cast to non-null type <root>.ToggleMessage");
                            try {
                                ((uc.a) gVar2).a((b) obj3);
                                listW = hb.a.l0(null);
                                break;
                            } catch (Throwable th) {
                                listW = f.w(th);
                            }
                            dVar.reply(listW);
                            return;
                        default:
                            g.i(dVar, "reply");
                            try {
                                y yVar = ((uc.a) gVar2).f33439a;
                                g.f(yVar);
                                obj2 = yVar.f25365a;
                            } catch (Throwable th2) {
                                listW2 = f.w(th2);
                            }
                            if (((Activity) obj2) == null) {
                                throw new NoActivityException();
                            }
                            Activity activity = (Activity) obj2;
                            g.f(activity);
                            listW2 = hb.a.l0(new a(Boolean.valueOf((activity.getWindow().getAttributes().flags & 128) != 0)));
                            dVar.reply(listW2);
                            return;
                    }
                }
            });
        } else {
            eVar.setMessageHandler(null);
        }
        e eVar2 = new e(iVar, e.i("dev.flutter.pigeon.wakelock_plus_platform_interface.WakelockPlusApi.isEnabled", strConcat), (p) cVar.getValue(), null);
        if (gVar == null) {
            eVar2.setMessageHandler(null);
        } else {
            final int i11 = 1;
            eVar2.setMessageHandler(new ed.c() { // from class: d
                @Override // ed.c
                public final void onMessage(Object obj, ed.d dVar) {
                    List listW;
                    List listW2;
                    Object obj2;
                    int i112 = i11;
                    g gVar2 = gVar;
                    switch (i112) {
                        case 0:
                            g.i(dVar, "reply");
                            g.g(obj, "null cannot be cast to non-null type kotlin.collections.List<kotlin.Any?>");
                            Object obj3 = ((List) obj).get(0);
                            g.g(obj3, "null cannot be cast to non-null type <root>.ToggleMessage");
                            try {
                                ((uc.a) gVar2).a((b) obj3);
                                listW = hb.a.l0(null);
                                break;
                            } catch (Throwable th) {
                                listW = f.w(th);
                            }
                            dVar.reply(listW);
                            return;
                        default:
                            g.i(dVar, "reply");
                            try {
                                y yVar = ((uc.a) gVar2).f33439a;
                                g.f(yVar);
                                obj2 = yVar.f25365a;
                            } catch (Throwable th2) {
                                listW2 = f.w(th2);
                            }
                            if (((Activity) obj2) == null) {
                                throw new NoActivityException();
                            }
                            Activity activity = (Activity) obj2;
                            g.f(activity);
                            listW2 = hb.a.l0(new a(Boolean.valueOf((activity.getWindow().getAttributes().flags & 128) != 0)));
                            dVar.reply(listW2);
                            return;
                    }
                }
            });
        }
    }
}
