package io.flutter.plugins.webviewflutter;

import a.AbstractC0212a;
import android.webkit.HttpAuthHandler;
import d4.C0550i;
import e4.AbstractC0566j;
import io.flutter.plugin.common.BasicMessageChannel;
import io.flutter.plugin.common.BinaryMessenger;
import io.flutter.plugin.common.MessageCodec;
import io.flutter.plugins.webviewflutter.PigeonApiHttpAuthHandler;
import java.util.List;
import p0.AbstractC0928a;
import r4.AbstractC0980e;
import r4.AbstractC0983h;

/* JADX INFO: loaded from: classes.dex */
public abstract class PigeonApiHttpAuthHandler {
    public static final Companion Companion = new Companion(null);
    private final AndroidWebkitLibraryPigeonProxyApiRegistrar pigeonRegistrar;

    public static final class Companion {
        public /* synthetic */ Companion(AbstractC0980e abstractC0980e) {
            this();
        }

        /* JADX INFO: Access modifiers changed from: private */
        public static final void setUpMessageHandlers$lambda$1$lambda$0(PigeonApiHttpAuthHandler pigeonApiHttpAuthHandler, Object obj, BasicMessageChannel.Reply reply) {
            List<Object> listWrapError;
            AbstractC0983h.e("reply", reply);
            AbstractC0983h.c("null cannot be cast to non-null type kotlin.collections.List<kotlin.Any?>", obj);
            Object obj2 = ((List) obj).get(0);
            AbstractC0983h.c("null cannot be cast to non-null type android.webkit.HttpAuthHandler", obj2);
            try {
                listWrapError = AbstractC0566j.r(Boolean.valueOf(pigeonApiHttpAuthHandler.useHttpAuthUsernamePassword((HttpAuthHandler) obj2)));
            } catch (Throwable th) {
                listWrapError = AndroidWebkitLibraryPigeonUtils.INSTANCE.wrapError(th);
            }
            reply.reply(listWrapError);
        }

        /* JADX INFO: Access modifiers changed from: private */
        public static final void setUpMessageHandlers$lambda$3$lambda$2(PigeonApiHttpAuthHandler pigeonApiHttpAuthHandler, Object obj, BasicMessageChannel.Reply reply) {
            List<Object> listWrapError;
            AbstractC0983h.e("reply", reply);
            AbstractC0983h.c("null cannot be cast to non-null type kotlin.collections.List<kotlin.Any?>", obj);
            Object obj2 = ((List) obj).get(0);
            AbstractC0983h.c("null cannot be cast to non-null type android.webkit.HttpAuthHandler", obj2);
            try {
                pigeonApiHttpAuthHandler.cancel((HttpAuthHandler) obj2);
                listWrapError = AbstractC0566j.r(null);
            } catch (Throwable th) {
                listWrapError = AndroidWebkitLibraryPigeonUtils.INSTANCE.wrapError(th);
            }
            reply.reply(listWrapError);
        }

        /* JADX INFO: Access modifiers changed from: private */
        public static final void setUpMessageHandlers$lambda$5$lambda$4(PigeonApiHttpAuthHandler pigeonApiHttpAuthHandler, Object obj, BasicMessageChannel.Reply reply) {
            List<Object> listWrapError;
            AbstractC0983h.e("reply", reply);
            AbstractC0983h.c("null cannot be cast to non-null type kotlin.collections.List<kotlin.Any?>", obj);
            List list = (List) obj;
            Object obj2 = list.get(0);
            AbstractC0983h.c("null cannot be cast to non-null type android.webkit.HttpAuthHandler", obj2);
            HttpAuthHandler httpAuthHandler = (HttpAuthHandler) obj2;
            Object obj3 = list.get(1);
            AbstractC0983h.c("null cannot be cast to non-null type kotlin.String", obj3);
            String str = (String) obj3;
            Object obj4 = list.get(2);
            AbstractC0983h.c("null cannot be cast to non-null type kotlin.String", obj4);
            try {
                pigeonApiHttpAuthHandler.proceed(httpAuthHandler, str, (String) obj4);
                listWrapError = AbstractC0566j.r(null);
            } catch (Throwable th) {
                listWrapError = AndroidWebkitLibraryPigeonUtils.INSTANCE.wrapError(th);
            }
            reply.reply(listWrapError);
        }

        public final void setUpMessageHandlers(BinaryMessenger binaryMessenger, final PigeonApiHttpAuthHandler pigeonApiHttpAuthHandler) {
            MessageCodec<Object> androidWebkitLibraryPigeonCodec;
            AndroidWebkitLibraryPigeonProxyApiRegistrar pigeonRegistrar;
            AbstractC0983h.e("binaryMessenger", binaryMessenger);
            if (pigeonApiHttpAuthHandler == null || (pigeonRegistrar = pigeonApiHttpAuthHandler.getPigeonRegistrar()) == null || (androidWebkitLibraryPigeonCodec = pigeonRegistrar.getCodec()) == null) {
                androidWebkitLibraryPigeonCodec = new AndroidWebkitLibraryPigeonCodec();
            }
            BasicMessageChannel basicMessageChannel = new BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.webview_flutter_android.HttpAuthHandler.useHttpAuthUsernamePassword", androidWebkitLibraryPigeonCodec);
            if (pigeonApiHttpAuthHandler != null) {
                final int i = 0;
                basicMessageChannel.setMessageHandler(new BasicMessageChannel.MessageHandler() { // from class: io.flutter.plugins.webviewflutter.n
                    @Override // io.flutter.plugin.common.BasicMessageChannel.MessageHandler
                    public final void onMessage(Object obj, BasicMessageChannel.Reply reply) {
                        switch (i) {
                            case 0:
                                PigeonApiHttpAuthHandler.Companion.setUpMessageHandlers$lambda$1$lambda$0(pigeonApiHttpAuthHandler, obj, reply);
                                break;
                            case 1:
                                PigeonApiHttpAuthHandler.Companion.setUpMessageHandlers$lambda$3$lambda$2(pigeonApiHttpAuthHandler, obj, reply);
                                break;
                            default:
                                PigeonApiHttpAuthHandler.Companion.setUpMessageHandlers$lambda$5$lambda$4(pigeonApiHttpAuthHandler, obj, reply);
                                break;
                        }
                    }
                });
            } else {
                basicMessageChannel.setMessageHandler(null);
            }
            BasicMessageChannel basicMessageChannel2 = new BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.webview_flutter_android.HttpAuthHandler.cancel", androidWebkitLibraryPigeonCodec);
            if (pigeonApiHttpAuthHandler != null) {
                final int i5 = 1;
                basicMessageChannel2.setMessageHandler(new BasicMessageChannel.MessageHandler() { // from class: io.flutter.plugins.webviewflutter.n
                    @Override // io.flutter.plugin.common.BasicMessageChannel.MessageHandler
                    public final void onMessage(Object obj, BasicMessageChannel.Reply reply) {
                        switch (i5) {
                            case 0:
                                PigeonApiHttpAuthHandler.Companion.setUpMessageHandlers$lambda$1$lambda$0(pigeonApiHttpAuthHandler, obj, reply);
                                break;
                            case 1:
                                PigeonApiHttpAuthHandler.Companion.setUpMessageHandlers$lambda$3$lambda$2(pigeonApiHttpAuthHandler, obj, reply);
                                break;
                            default:
                                PigeonApiHttpAuthHandler.Companion.setUpMessageHandlers$lambda$5$lambda$4(pigeonApiHttpAuthHandler, obj, reply);
                                break;
                        }
                    }
                });
            } else {
                basicMessageChannel2.setMessageHandler(null);
            }
            BasicMessageChannel basicMessageChannel3 = new BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.webview_flutter_android.HttpAuthHandler.proceed", androidWebkitLibraryPigeonCodec);
            if (pigeonApiHttpAuthHandler == null) {
                basicMessageChannel3.setMessageHandler(null);
            } else {
                final int i6 = 2;
                basicMessageChannel3.setMessageHandler(new BasicMessageChannel.MessageHandler() { // from class: io.flutter.plugins.webviewflutter.n
                    @Override // io.flutter.plugin.common.BasicMessageChannel.MessageHandler
                    public final void onMessage(Object obj, BasicMessageChannel.Reply reply) {
                        switch (i6) {
                            case 0:
                                PigeonApiHttpAuthHandler.Companion.setUpMessageHandlers$lambda$1$lambda$0(pigeonApiHttpAuthHandler, obj, reply);
                                break;
                            case 1:
                                PigeonApiHttpAuthHandler.Companion.setUpMessageHandlers$lambda$3$lambda$2(pigeonApiHttpAuthHandler, obj, reply);
                                break;
                            default:
                                PigeonApiHttpAuthHandler.Companion.setUpMessageHandlers$lambda$5$lambda$4(pigeonApiHttpAuthHandler, obj, reply);
                                break;
                        }
                    }
                });
            }
        }

        private Companion() {
        }
    }

    public PigeonApiHttpAuthHandler(AndroidWebkitLibraryPigeonProxyApiRegistrar androidWebkitLibraryPigeonProxyApiRegistrar) {
        AbstractC0983h.e("pigeonRegistrar", androidWebkitLibraryPigeonProxyApiRegistrar);
        this.pigeonRegistrar = androidWebkitLibraryPigeonProxyApiRegistrar;
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final void pigeon_newInstance$lambda$0(q4.l lVar, String str, Object obj) {
        if (!(obj instanceof List)) {
            AbstractC0928a.r(AbstractC0212a.e(AndroidWebkitLibraryPigeonUtils.INSTANCE.createConnectionError(str)), lVar);
            return;
        }
        List list = (List) obj;
        if (list.size() <= 1) {
            AbstractC0928a.s(C0550i.f6143a, lVar);
            return;
        }
        Object obj2 = list.get(0);
        AbstractC0983h.c("null cannot be cast to non-null type kotlin.String", obj2);
        Object obj3 = list.get(1);
        AbstractC0983h.c("null cannot be cast to non-null type kotlin.String", obj3);
        AbstractC0928a.r(AbstractC0212a.e(new AndroidWebKitError((String) obj2, (String) obj3, (String) list.get(2))), lVar);
    }

    public abstract void cancel(HttpAuthHandler httpAuthHandler);

    public AndroidWebkitLibraryPigeonProxyApiRegistrar getPigeonRegistrar() {
        return this.pigeonRegistrar;
    }

    public final void pigeon_newInstance(HttpAuthHandler httpAuthHandler, q4.l lVar) {
        AbstractC0983h.e("pigeon_instanceArg", httpAuthHandler);
        AbstractC0983h.e("callback", lVar);
        if (getPigeonRegistrar().getIgnoreCallsToDart()) {
            AbstractC0928a.r(AbstractC0928a.g("ignore-calls-error", "Calls to Dart are being ignored.", ""), lVar);
        } else if (getPigeonRegistrar().getInstanceManager().containsInstance(httpAuthHandler)) {
            AbstractC0928a.s(C0550i.f6143a, lVar);
        } else {
            new BasicMessageChannel(getPigeonRegistrar().getBinaryMessenger(), "dev.flutter.pigeon.webview_flutter_android.HttpAuthHandler.pigeon_newInstance", getPigeonRegistrar().getCodec()).send(AbstractC0566j.r(Long.valueOf(getPigeonRegistrar().getInstanceManager().addHostCreatedInstance(httpAuthHandler))), new C0661b(lVar, 11));
        }
    }

    public abstract void proceed(HttpAuthHandler httpAuthHandler, String str, String str2);

    public abstract boolean useHttpAuthUsernamePassword(HttpAuthHandler httpAuthHandler);
}
