Swiggy v4.51.1版本的 MD5 值为:5af7ec91512a0a8c1510e3f8bac20b8b

以下内容为反编译后的 ForgotPasswordOTPViewModel.java 源代码,内容仅作参考


package in.swiggy.android.mvvm.viewmodels.loginsignup;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.CountDownTimer;
import androidx.databinding.ObservableBoolean;
import androidx.databinding.ObservableField;
import androidx.databinding.j;
import androidx.lifecycle.l0;
import com.google.android.gms.auth.api.phone.SmsRetriever;
import com.payu.threeDS2.constants.LoggingConstants;
import com.payu.threedsbase.constants.APIConstants;
import com.swiggy.tns.duplix.v1.CloningSignalsProto;
import in.swiggy.android.R;
import in.swiggy.android.SwiggyApplication;
import in.swiggy.android.activities.LoginLimitErrorActivity;
import in.swiggy.android.commons.utils.DispatchProviderKt;
import in.swiggy.android.feature.address.LoginAddressSyncKt;
import in.swiggy.android.feature.logout.LogoutUseCase;
import in.swiggy.android.mvvm.services.LoginSignupServices;
import in.swiggy.android.mvvm.viewmodels.PostLoginViewModel;
import in.swiggy.android.mvvm.viewmodels.settings.AccountDeletionStatusCode;
import in.swiggy.android.mvvm.viewmodels.settings.SettingsActivityViewModel;
import in.swiggy.android.network.interceptors.p;
import in.swiggy.android.tejas.Response;
import in.swiggy.android.tejas.api.models.SwiggyApiResponse;
import in.swiggy.android.tejas.api.models.SwiggyBaseResponse;
import in.swiggy.android.tejas.feature.address.model.Address;
import in.swiggy.android.tejas.feature.address.model.AllAddress;
import in.swiggy.android.tejas.feature.address.v2.usecase.GetAllAddressUseCase;
import in.swiggy.android.tejas.feature.auth.OtpVerifyUseCase;
import in.swiggy.android.tejas.feature.otpverification.OtpVerificationManager;
import in.swiggy.android.tejas.feature.user.UserDeleteCheckUseCase;
import in.swiggy.android.tejas.feature.user.UserDeleteUseCase;
import in.swiggy.android.tejas.generated.ISwiggyNetworkWrapper;
import in.swiggy.android.tejas.oldapi.SwiggyBaseResponseHandler;
import in.swiggy.android.tejas.oldapi.SwiggyDataHandler;
import in.swiggy.android.tejas.oldapi.network.requests.PostableMobileNumberEditOTP;
import in.swiggy.android.tejas.oldapi.network.responses.UserResponseData;
import in.swiggy.android.tejas.oldapi.network.responses.handlers.SignUpResponseHandler;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.regex.Matcher;
import kotlin.Unit;
import kotlin.coroutines.CoroutineContext;
import kotlin.coroutines.jvm.internal.ContinuationImpl;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.text.StringsKt__StringsKt;
import kotlinx.coroutines.f0;
import kotlinx.coroutines.q1;
import kotlinx.coroutines.v0;
import retrofit2.Response;
public final class ForgotPasswordOTPViewModel extends PostLoginViewModel {
    public static final a v1 = new a(null);
    public static final int w1 = 8;
    private static final String x1;
    private final ISwiggyNetworkWrapper A0;
    private final SwiggyApplication B0;
    private final OtpVerifyUseCase C0;
    private final OtpVerificationManager D0;
    private String E0;
    private String F0;
    private final ObservableBoolean G0;
    public UserDeleteUseCase H0;
    public UserDeleteCheckUseCase I0;
    public LogoutUseCase J0;
    public ObservableField<Boolean> K0;
    public ObservableBoolean L0;
    public ObservableField<String> M0;
    public ObservableField<String> N0;
    public ObservableField<String> O0;
    public ObservableField<String> P0;
    public ObservableField<String> Q0;
    public ObservableField<String> R0;
    public ObservableField<String> S0;
    public ObservableField<String> T0;
    private final in.swiggy.android.commons.validation.f<String> U0;
    public ObservableField<String> V0;
    public ObservableField<Boolean> W0;
    public ObservableField<Integer> X0;
    public ObservableField<Float> Y0;
    public ObservableBoolean Z0;
    public boolean a1;
    public ObservableBoolean b1;
    public boolean c1;
    private CountDownTimer d1;
    private boolean e1;
    private final ObservableBoolean f1;
    private final ObservableBoolean g1;
    private final ObservableBoolean h1;
    private boolean i1;
    private final int j1;
    private q1 k1;
    private boolean l1;
    private boolean m1;
    private boolean n1;
    private ObservableBoolean o1;
    private ObservableBoolean p1;
    private ObservableBoolean q1;
    private ObservableBoolean r1;
    private ObservableBoolean s1;
    private boolean t1;
    private ArrayList<String> u1;
    private final LoginSignupServices z0;

    public static final class a {
        public a(DefaultConstructorMarker defaultConstructorMarker) {
            this();
        }

        public final String a() {
            return ForgotPasswordOTPViewModel.x1;
        }

        private a() {
        }
    }

    public static final class b extends kotlin.coroutines.a implements kotlinx.coroutines.f0 {
        final ForgotPasswordOTPViewModel b;

        public b(f0.a aVar, ForgotPasswordOTPViewModel forgotPasswordOTPViewModel) {
            super(aVar);
            this.b = forgotPasswordOTPViewModel;
        }

        @Override
        public void L(CoroutineContext coroutineContext, Throwable th) {
            in.swiggy.android.commons.utils.x.i(ForgotPasswordOTPViewModel.x1, th);
            this.b.S8();
        }
    }

    public static final class c extends kotlin.coroutines.a implements kotlinx.coroutines.f0 {
        final ForgotPasswordOTPViewModel b;

        public c(f0.a aVar, ForgotPasswordOTPViewModel forgotPasswordOTPViewModel) {
            super(aVar);
            this.b = forgotPasswordOTPViewModel;
        }

        @Override
        public void L(CoroutineContext coroutineContext, Throwable th) {
            in.swiggy.android.commons.utils.x.i(ForgotPasswordOTPViewModel.x1, th);
            this.b.S8();
        }
    }

    public static final class d extends kotlin.coroutines.a implements kotlinx.coroutines.f0 {
        public d(f0.a aVar) {
            super(aVar);
        }

        @Override
        public void L(CoroutineContext coroutineContext, Throwable th) {
            in.swiggy.android.commons.utils.x.i(ForgotPasswordOTPViewModel.x1, th);
        }
    }

    public static final class e extends j.a {
        e() {
        }

        @Override
        public void d(androidx.databinding.j sender, int i) {
            kotlin.jvm.internal.o.k(sender, "sender");
            ForgotPasswordOTPViewModel.this.aa();
        }
    }

    public static final class f extends j.a {
        f() {
        }

        @Override
        public void d(androidx.databinding.j sender, int i) {
            kotlin.jvm.internal.o.k(sender, "sender");
            if (!kotlin.jvm.internal.o.f(ForgotPasswordOTPViewModel.this.W0.g(), Boolean.TRUE)) {
                ForgotPasswordOTPViewModel.this.i1 = true;
            }
        }
    }

    public static final class g extends j.a {
        g() {
        }

        @Override
        public void d(androidx.databinding.j sender, int i) {
            kotlin.jvm.internal.o.k(sender, "sender");
            if (ForgotPasswordOTPViewModel.this.c9().b(ForgotPasswordOTPViewModel.this.R0.g())) {
                if (!ForgotPasswordOTPViewModel.this.e9()) {
                    ForgotPasswordOTPViewModel.this.K0.h(Boolean.TRUE);
                }
                if (kotlin.jvm.internal.o.f(ForgotPasswordOTPViewModel.this.X8(), "account_deletion")) {
                    ForgotPasswordOTPViewModel forgotPasswordOTPViewModel = ForgotPasswordOTPViewModel.this;
                    forgotPasswordOTPViewModel.S0.h(forgotPasswordOTPViewModel.r0().getString(R.string.verify_and_delete));
                    return;
                }
                ForgotPasswordOTPViewModel.this.S0.h(null);
                return;
            }
            ForgotPasswordOTPViewModel.this.ea(false);
            ForgotPasswordOTPViewModel.this.K0.h(Boolean.FALSE);
            ForgotPasswordOTPViewModel forgotPasswordOTPViewModel2 = ForgotPasswordOTPViewModel.this;
            forgotPasswordOTPViewModel2.S0.h(forgotPasswordOTPViewModel2.c9().a());
        }
    }

    public static final class h extends CountDownTimer {
        final boolean b;

        h(boolean z, long j) {
            super(j, 1000L);
            this.b = z;
        }

        @Override
        public void onFinish() {
            int i;
            if (!ForgotPasswordOTPViewModel.this.V8().g()) {
                ForgotPasswordOTPViewModel.this.ha();
            }
            in.swiggy.android.mvvm.services.s r0 = ForgotPasswordOTPViewModel.this.r0();
            if (this.b) {
                i = R.string.call_not_received_question;
            } else {
                i = R.string.otp_not_received_question;
            }
            String string = r0.getString(i);
            if (ForgotPasswordOTPViewModel.this.V8().g()) {
                string = string + " " + ForgotPasswordOTPViewModel.this.r0().getString(R.string.retry_via_text);
            }
            ForgotPasswordOTPViewModel.this.la(string);
            ForgotPasswordOTPViewModel.this.S8();
            ForgotPasswordOTPViewModel.this.G().d(ForgotPasswordOTPViewModel.class, ForgotPasswordOTPViewModel.this.r0().getString(R.string.timer_expired));
            ForgotPasswordOTPViewModel.this.X0.h(2);
        }

        @Override
        public void onTick(long j) {
            int i;
            long j2 = j / 1000;
            in.swiggy.android.mvvm.services.s r0 = ForgotPasswordOTPViewModel.this.r0();
            if (this.b) {
                i = R.string.call_verification_in_progress_message;
            } else {
                i = R.string.otp_not_received_question;
            }
            String string = r0.getString(i);
            ForgotPasswordOTPViewModel forgotPasswordOTPViewModel = ForgotPasswordOTPViewModel.this;
            kotlin.jvm.internal.v vVar = kotlin.jvm.internal.v.a;
            String string2 = forgotPasswordOTPViewModel.r0().getString(R.string.retry_countdown_timer_text);
            String format = String.format(string + " " + string2, Arrays.copyOf(new Object[]{Long.valueOf(j2)}, 1));
            kotlin.jvm.internal.o.j(format, "format(...)");
            forgotPasswordOTPViewModel.la(format);
            ForgotPasswordOTPViewModel.this.K8((int) j2);
        }
    }

    static {
        String simpleName = ForgotPasswordOTPViewModel.class.getSimpleName();
        kotlin.jvm.internal.o.j(simpleName, "getSimpleName(...)");
        x1 = simpleName;
    }

    public ForgotPasswordOTPViewModel(LoginSignupServices loginSignUpServices, ISwiggyNetworkWrapper swiggyNetworkWrapper, SwiggyApplication application, OtpVerifyUseCase otpVerifyUseCase, OtpVerificationManager otpVerificationManager, GetAllAddressUseCase getAllAddressUseCase) {
        super(loginSignUpServices, getAllAddressUseCase);
        kotlin.jvm.internal.o.k(loginSignUpServices, "loginSignUpServices");
        kotlin.jvm.internal.o.k(swiggyNetworkWrapper, "swiggyNetworkWrapper");
        kotlin.jvm.internal.o.k(application, "application");
        kotlin.jvm.internal.o.k(otpVerifyUseCase, "otpVerifyUseCase");
        kotlin.jvm.internal.o.k(otpVerificationManager, "otpVerificationManager");
        kotlin.jvm.internal.o.k(getAllAddressUseCase, "getAllAddressUseCase");
        this.z0 = loginSignUpServices;
        this.A0 = swiggyNetworkWrapper;
        this.B0 = application;
        this.C0 = otpVerifyUseCase;
        this.D0 = otpVerificationManager;
        this.G0 = new ObservableBoolean(false);
        Boolean bool = Boolean.FALSE;
        this.K0 = new ObservableField<>(bool);
        this.L0 = new ObservableBoolean(false);
        this.M0 = new ObservableField<>("");
        this.N0 = new ObservableField<>("");
        this.O0 = new ObservableField<>("");
        this.P0 = new ObservableField<>("");
        this.Q0 = new ObservableField<>("");
        this.R0 = new ObservableField<>("");
        this.S0 = new ObservableField<>();
        this.T0 = new ObservableField<>();
        this.U0 = new in.swiggy.android.commons.validation.f<>(null);
        this.V0 = new ObservableField<>("");
        this.W0 = new ObservableField<>(bool);
        this.X0 = new ObservableField<>(1);
        this.Y0 = new ObservableField<>(Float.valueOf(0.4f));
        this.Z0 = new ObservableBoolean(false);
        this.b1 = new ObservableBoolean(false);
        this.f1 = new ObservableBoolean(false);
        this.g1 = new ObservableBoolean(false);
        this.h1 = new ObservableBoolean(false);
        this.i1 = true;
        this.j1 = 4;
        this.o1 = new ObservableBoolean(false);
        this.p1 = new ObservableBoolean(false);
        this.q1 = new ObservableBoolean(false);
        this.r1 = new ObservableBoolean(false);
        this.s1 = new ObservableBoolean(false);
    }

    private final void A9(SwiggyApiResponse<UserResponseData> swiggyApiResponse, String str) {
        String statusMessage = swiggyApiResponse.getStatusMessage();
        if (statusMessage != null) {
            R9(this, statusMessage, false, 2, null);
            T8(str, "failure-1");
        }
    }

    private final void B9(SwiggyApiResponse<UserResponseData> swiggyApiResponse, String str) {
        T8(str, LoggingConstants.SUCCESS);
        UserResponseData data = swiggyApiResponse.getData();
        if (data != null) {
            String str2 = this.F0;
            if (kotlin.jvm.internal.o.f(str2, "onlyOTPVerify")) {
                v9(swiggyApiResponse, data);
            } else if (kotlin.jvm.internal.o.f(str2, "signup")) {
                z9(swiggyApiResponse);
            } else {
                w9(swiggyApiResponse, data);
            }
        }
    }

    public static final void D9(Function1 tmp0, Object obj) {
        kotlin.jvm.internal.o.k(tmp0, "$tmp0");
        tmp0.invoke(obj);
    }

    public static final void E9(Function1 tmp0, Object obj) {
        kotlin.jvm.internal.o.k(tmp0, "$tmp0");
        tmp0.invoke(obj);
    }

    public final void K8(int i) {
        if (kotlin.jvm.internal.o.f(this.W0.g(), Boolean.TRUE)) {
            if (i % this.j1 == 0 || this.i1) {
                G().d(ForgotPasswordOTPViewModel.class, r0().b(R.string.enter_otp_within, Integer.valueOf(i)));
            }
            if (this.i1) {
                this.i1 = false;
            }
        }
    }

    public static final void K9(ForgotPasswordOTPViewModel this$0, SwiggyBaseResponse swiggyBaseResponse) {
        kotlin.jvm.internal.o.k(this$0, "this$0");
        in.swiggy.android.commons.utils.x.b(x1, "Request success");
        this$0.G0.h(false);
        ka(this$0, false, 1, null);
    }

    public static final void L9(ForgotPasswordOTPViewModel this$0, SwiggyBaseResponse swiggyBaseResponse) {
        kotlin.jvm.internal.o.k(this$0, "this$0");
        this$0.S8();
        this$0.z0.x("Not able to process your request, please try again later", 0);
        this$0.G0.h(false);
    }

    public static final void M8(ForgotPasswordOTPViewModel this$0) {
        kotlin.jvm.internal.o.k(this$0, "this$0");
        this$0.z0.k();
    }

    public static final void M9(ForgotPasswordOTPViewModel this$0, Throwable th) {
        kotlin.jvm.internal.o.k(this$0, "this$0");
        this$0.S8();
        this$0.z0.x("Not able to process your request, please try again later", 0);
        this$0.G0.h(false);
    }

    public static final void O8(ForgotPasswordOTPViewModel this$0) {
        kotlin.jvm.internal.o.k(this$0, "this$0");
        if (this$0.G0.g()) {
            this$0.z0.n3("Please wait, we are trying to reach you!");
        } else {
            this$0.J9();
        }
    }

    public static void R9(ForgotPasswordOTPViewModel forgotPasswordOTPViewModel, String str, boolean z, int i, Object obj) {
        if ((i & 2) != 0) {
            z = true;
        }
        forgotPasswordOTPViewModel.Q9(str, z);
    }

    private final void U9() {
        q1 q1Var = this.k1;
        if (q1Var != null && q1Var.b()) {
            return;
        }
        this.k1 = kotlinx.coroutines.g.d(l0.a(this), v0.b(), null, new ForgotPasswordOTPViewModel$pollCallVerificationStatus$1(new d(kotlinx.coroutines.f0.v0), this, null), 2, null);
    }

    public final void V9(String str) {
        this.R0.h(str);
        T9("Whatsapp");
    }

    private final void X9() {
        try {
            kotlinx.coroutines.g.d(l0.a(this), DispatchProviderKt.c().Q(DispatchProviderKt.b().q2()), null, new ForgotPasswordOTPViewModel$sendAccountDeletionOtp$$inlined$launch$1(null, this), 2, null);
        } catch (Throwable th) {
            in.swiggy.android.commons.utils.x.i(SettingsActivityViewModel.E0.a(), th);
            S8();
        }
    }

    public static final void Z9(ForgotPasswordOTPViewModel this$0, Throwable th) {
        kotlin.jvm.internal.o.k(this$0, "this$0");
        this$0.z0.x(this$0.r0().getString(R.string.something_went_wrong_try_again), -1);
        this$0.S8();
        in.swiggy.android.commons.utils.x.f(x1, "Received failure in SendOTPRequestSetPassword", th);
    }

    public final void aa() {
        String str;
        String J;
        String g2 = this.S0.g();
        if (g2 == null) {
            return;
        }
        String string = r0().getString(R.string.otp_content_description);
        String str2 = "";
        if (string == null) {
            str = "";
        } else {
            str = string;
        }
        String string2 = r0().getString(R.string.otp_capital);
        if (string2 != null) {
            str2 = string2;
        }
        ObservableField<String> observableField = this.T0;
        J = kotlin.text.q.J(g2, str2, str, false, 4, null);
        observableField.h(J);
    }

    private final void ba() {
        String str;
        String J;
        int i;
        boolean z;
        ObservableField<String> observableField = this.M0;
        in.swiggy.android.mvvm.services.s r0 = r0();
        Object[] objArr = new Object[1];
        String str2 = this.E0;
        if (str2 != null && J != null) {
            int length = J.length() - 1;
            int i2 = 0;
            boolean z2 = false;
            while (i2 <= length) {
                if (!z2) {
                    i = i2;
                } else {
                    i = length;
                }
                if (kotlin.jvm.internal.o.m(J.charAt(i), 32) <= 0) {
                    z = true;
                } else {
                    z = false;
                }
                if (!z2) {
                    if (!z) {
                        z2 = true;
                    } else {
                        i2++;
                    }
                } else if (!z) {
                    break;
                } else {
                    length--;
                }
            }
            str = J.subSequence(i2, length + 1).toString();
        } else {
            str = null;
        }
        objArr[0] = str;
        observableField.h(r0.b(R.string.verify_otp_header_content_description, objArr));
    }

    private final String d9(String str) {
        String group;
        if (str == null) {
            return "";
        }
        Matcher matcher = in.swiggy.android.repositories.saveablecontexts.i.U.matcher(str);
        if (!matcher.find() || (group = matcher.group(0)) == null) {
            return "";
        }
        return group;
    }

    private final void fa() {
        this.S0.Y(new e());
        this.W0.Y(new f());
        this.S0.h(r0().getString(R.string.enter_otp));
        this.R0.Y(new g());
    }

    private final String k9(String str) {
        if (str != null) {
            switch (str.hashCode()) {
                case -1936417761:
                    if (str.equals("otpVerifySetPwd")) {
                        return "otp-verify-create-password";
                    }
                    break;
                case -902467304:
                    if (str.equals("signup")) {
                        return "otp-verify-sign-up";
                    }
                    break;
                case -137382600:
                    if (str.equals("onlyOTPVerify")) {
                        return "otp-verify-user-verify";
                    }
                    break;
                case 629944030:
                    if (str.equals("forgotPassword")) {
                        return "otp-verify-forgot-password";
                    }
                    break;
            }
        }
        return "otp-verify-other";
    }

    public static void ka(ForgotPasswordOTPViewModel forgotPasswordOTPViewModel, boolean z, int i, Object obj) {
        if ((i & 1) != 0) {
            z = false;
        }
        forgotPasswordOTPViewModel.ja(z);
    }

    public final void la(String str) {
        this.L0.h(false);
        this.V0.h(str);
    }

    public final void n9(UserResponseData userResponseData, SwiggyApiResponse<UserResponseData> swiggyApiResponse) {
        boolean f2 = kotlin.jvm.internal.o.f(r7().getString("android_enable_abuse_breach_feature", "true"), "true");
        if (userResponseData.mSwiggyOneAbuseBreach && f2) {
            LoginSignupServices loginSignupServices = this.z0;
            String mSwiggyOneDeviceLimit = userResponseData.mSwiggyOneDeviceLimit;
            kotlin.jvm.internal.o.j(mSwiggyOneDeviceLimit, "mSwiggyOneDeviceLimit");
            loginSignupServices.r0(mSwiggyOneDeviceLimit);
            return;
        }
        this.z0.k();
        u7().g0();
    }

    public final void o9(Response<SwiggyApiResponse<UserResponseData>> response) {
        if (response.isSuccessful()) {
            p9(response.body());
        } else {
            r9();
        }
    }

    public static final void oa(ForgotPasswordOTPViewModel this$0, SwiggyApiResponse response) {
        kotlin.jvm.internal.o.k(this$0, "this$0");
        kotlin.jvm.internal.o.k(response, "response");
        String statusMessage = response.getStatusMessage();
        if (statusMessage != null) {
            R9(this$0, statusMessage, false, 2, null);
            this$0.T8("otp-verify-edit-number", LoggingConstants.FAILURE);
        }
    }

    private final void p9(final SwiggyApiResponse<UserResponseData> swiggyApiResponse) {
        Integer num;
        if (swiggyApiResponse != null) {
            num = swiggyApiResponse.getStatusCode();
        } else {
            num = null;
        }
        if (num != null && num.intValue() == 0) {
            UserResponseData data = swiggyApiResponse.getData();
            if (data != null) {
                q1 q1Var = this.k1;
                if (q1Var != null) {
                    q1.a.a(q1Var, null, 1, null);
                }
                this.c1 = true;
                P8();
                if (kotlin.jvm.internal.o.f(this.F0, "signup")) {
                    j8(true);
                    String str = this.E0;
                    if (str != null) {
                        g8(swiggyApiResponse, str);
                    }
                    t7().d();
                    return;
                }
                String mCustomerId = data.mCustomerId;
                kotlin.jvm.internal.o.j(mCustomerId, "mCustomerId");
                y9(mCustomerId, new Function0<Unit>() {
                    {
                        super(0);
                    }

                    @Override
                    public Unit invoke() {
                        invoke2();
                        return Unit.a;
                    }

                    public final void invoke2() {
                        LoginSignupServices loginSignupServices;
                        LoginSignupServices loginSignupServices2;
                        LoginSignupServices loginSignupServices3;
                        loginSignupServices = ForgotPasswordOTPViewModel.this.z0;
                        loginSignupServices.b3(swiggyApiResponse, ForgotPasswordOTPViewModel.this.u7());
                        UserResponseData data2 = swiggyApiResponse.getData();
                        if (data2 != null) {
                            ForgotPasswordOTPViewModel forgotPasswordOTPViewModel = ForgotPasswordOTPViewModel.this;
                            boolean f2 = kotlin.jvm.internal.o.f(forgotPasswordOTPViewModel.r7().getString("android_enable_abuse_breach_feature", "true"), "true");
                            if (!data2.mSwiggyOneAbuseBreach || !f2) {
                                loginSignupServices2 = forgotPasswordOTPViewModel.z0;
                                loginSignupServices2.k();
                                forgotPasswordOTPViewModel.u7().g0();
                                return;
                            }
                            loginSignupServices3 = forgotPasswordOTPViewModel.z0;
                            String mSwiggyOneDeviceLimit = data2.mSwiggyOneDeviceLimit;
                            kotlin.jvm.internal.o.j(mSwiggyOneDeviceLimit, "mSwiggyOneDeviceLimit");
                            loginSignupServices3.r0(mSwiggyOneDeviceLimit);
                        }
                    }
                });
                return;
            }
            R9(this, r0().getString(R.string.verification_failed_error_message), false, 2, null);
        } else if (num != null && num.intValue() == 1) {
            P8();
            R9(this, r0().getString(R.string.verification_failed_error_message), false, 2, null);
        } else if (num != null && num.intValue() == 22) {
            P8();
            R9(this, r0().getString(R.string.verification_failed_error_message), false, 2, null);
            q1 q1Var2 = this.k1;
            if (q1Var2 != null) {
                q1.a.a(q1Var2, null, 1, null);
            }
        } else if (num != null && num.intValue() == 21) {
            in.swiggy.android.commons.utils.x.b(x1, "handleCallVerificationStatusResponseSuccess: Verification Status Pending");
        } else {
            R9(this, r0().getString(R.string.verification_failed_error_message), false, 2, null);
        }
    }

    public static final void pa(ForgotPasswordOTPViewModel this$0, Throwable th) {
        kotlin.jvm.internal.o.k(this$0, "this$0");
        R9(this$0, this$0.r0().getString(R.string.verification_failed_error_message), false, 2, null);
    }

    public final void q9(int i, String str) {
        u7().E(i);
        this.z0.k();
    }

    public static final void qa(ForgotPasswordOTPViewModel this$0, SwiggyApiResponse swiggyApiResponse) {
        kotlin.jvm.internal.o.k(this$0, "this$0");
        this$0.u7().W(this$0.E0);
        if (kotlin.jvm.internal.o.f(this$0.F0, "webEditProfile")) {
            this$0.z0.I1();
        } else {
            this$0.z0.k();
        }
        this$0.T8("otp-verify-edit-number", LoggingConstants.SUCCESS);
    }

    private final void r9() {
        R9(this, r0().getString(R.string.verification_failed_error_message), false, 2, null);
    }

    public final void s9(Response<SwiggyBaseResponse> response, String str) {
        if (response.isSuccessful()) {
            t9(response.body(), str);
        } else {
            r9();
        }
    }

    private final void t9(SwiggyBaseResponse swiggyBaseResponse, String str) {
        Integer num;
        String string;
        String string2;
        boolean z;
        if (swiggyBaseResponse != null) {
            num = swiggyBaseResponse.getStatusCode();
        } else {
            num = null;
        }
        if (num != null && num.intValue() == 0) {
            z = kotlin.text.q.z("verify_via_call", str, true);
            ja(z);
            if (z) {
                U9();
            }
        } else if (num != null && num.intValue() == 9) {
            if (swiggyBaseResponse == null || (string2 = swiggyBaseResponse.getStatusMessage()) == null) {
                string2 = r0().getString(R.string.verification_limit_exceeded_try_later);
            }
            Q9(string2, false);
        } else {
            if (swiggyBaseResponse == null || (string = swiggyBaseResponse.getStatusMessage()) == null) {
                string = r0().getString(R.string.verification_failed_error_message);
            }
            Q9(string, true);
        }
    }

    public final void u9(SwiggyApiResponse<UserResponseData> swiggyApiResponse, String str) {
        Integer statusCode = swiggyApiResponse.getStatusCode();
        if (statusCode != null && statusCode.intValue() == 0) {
            B9(swiggyApiResponse, str);
        } else if (statusCode != null && statusCode.intValue() == 1) {
            A9(swiggyApiResponse, str);
        } else {
            x9(swiggyApiResponse, str);
        }
    }

    private final void v9(final SwiggyApiResponse<UserResponseData> swiggyApiResponse, final UserResponseData userResponseData) {
        String mCustomerId = userResponseData.mCustomerId;
        kotlin.jvm.internal.o.j(mCustomerId, "mCustomerId");
        y9(mCustomerId, new Function0<Unit>() {
            {
                super(0);
            }

            @Override
            public Unit invoke() {
                invoke2();
                return Unit.a;
            }

            public final void invoke2() {
                LoginSignupServices loginSignupServices;
                loginSignupServices = ForgotPasswordOTPViewModel.this.z0;
                loginSignupServices.b3(swiggyApiResponse, ForgotPasswordOTPViewModel.this.u7());
                ForgotPasswordOTPViewModel.this.n9(userResponseData, swiggyApiResponse);
            }
        });
    }

    private final void w9(final SwiggyApiResponse<UserResponseData> swiggyApiResponse, UserResponseData userResponseData) {
        String mCustomerId = userResponseData.mCustomerId;
        kotlin.jvm.internal.o.j(mCustomerId, "mCustomerId");
        y9(mCustomerId, new Function0<Unit>() {
            {
                super(0);
            }

            @Override
            public Unit invoke() {
                invoke2();
                return Unit.a;
            }

            public final void invoke2() {
                LoginSignupServices loginSignupServices;
                LoginSignupServices loginSignupServices2;
                loginSignupServices = ForgotPasswordOTPViewModel.this.z0;
                loginSignupServices.b3(swiggyApiResponse, ForgotPasswordOTPViewModel.this.u7());
                loginSignupServices2 = ForgotPasswordOTPViewModel.this.z0;
                loginSignupServices2.k();
                ForgotPasswordOTPViewModel.this.u7().g0();
            }
        });
    }

    private final void x9(SwiggyApiResponse<UserResponseData> swiggyApiResponse, String str) {
        this.G0.h(false);
        this.z0.n3(swiggyApiResponse.getStatusMessage());
        String statusMessage = swiggyApiResponse.getStatusMessage();
        T8(str, "failure-" + statusMessage);
    }

    private final void z9(SwiggyApiResponse<UserResponseData> swiggyApiResponse) {
        j8(true);
        String str = this.E0;
        if (str != null) {
            g8(swiggyApiResponse, str);
        }
        t7().d();
    }

    public final void C9() {
        this.o1.h(false);
        this.q1.h(false);
        this.p1.h(false);
        this.s1.h(false);
    }

    @Override
    public void E6(int i, int i2, Intent intent) {
        String str;
        super.E6(i, i2, intent);
        if (i == 2) {
            this.z0.k();
            u7().g0();
        } else if (i == LoginLimitErrorActivity.E.b()) {
            if (i2 == -1) {
                in.swiggy.android.utils.i0.a.l(true);
                this.z0.k();
                u7().g0();
                return;
            }
            this.z0.k();
        } else if (i == 150) {
            if (i2 == -1) {
                if (intent != null) {
                    str = intent.getStringExtra(SmsRetriever.EXTRA_SMS_MESSAGE);
                } else {
                    str = null;
                }
                String d9 = d9(str);
                if (this.U0.b(d9)) {
                    u7().Z(d9);
                    this.e1 = true;
                    this.R0.h(d9);
                    T9("Sms-consent");
                }
                in.swiggy.android.analytics.gtm.g h2 = s7().h("otp-verify", "click-user-consent-request", "allowed", 9999);
                kotlin.jvm.internal.o.j(h2, "getGtmEventData(...)");
                s7().b(h2);
                return;
            }
            in.swiggy.android.analytics.gtm.g h3 = s7().h("otp-verify", "click-user-consent-request", "denied", 9999);
            kotlin.jvm.internal.o.j(h3, "getGtmEventData(...)");
            s7().b(h3);
        }
    }

    public final void F9() {
        boolean z;
        String string = r7().getString("android_reverification_options_list", "[\"otp_via_sms\",\"verify_via_call\"]");
        if (string == null) {
            string = APIConstants.AUTHENTICATION_INFO_VALUE;
        }
        this.u1 = in.swiggy.android.utils.i0.f(string);
        ArrayList<String> arrayList = null;
        if (kotlin.jvm.internal.o.f(this.F0, "account_deletion")) {
            ArrayList<String> arrayList2 = this.u1;
            if (arrayList2 == null) {
                kotlin.jvm.internal.o.C("verificationOptionsList");
            } else {
                arrayList = arrayList2;
            }
            boolean contains = arrayList.contains("otp_via_sms");
            this.l1 = contains;
            this.r1.h(contains);
            return;
        }
        ArrayList<String> arrayList3 = this.u1;
        if (arrayList3 == null) {
            kotlin.jvm.internal.o.C("verificationOptionsList");
            arrayList3 = null;
        }
        this.l1 = arrayList3.contains("otp_via_sms");
        ArrayList<String> arrayList4 = this.u1;
        if (arrayList4 == null) {
            kotlin.jvm.internal.o.C("verificationOptionsList");
            arrayList4 = null;
        }
        this.m1 = arrayList4.contains("whatsapp");
        ArrayList<String> arrayList5 = this.u1;
        if (arrayList5 == null) {
            kotlin.jvm.internal.o.C("verificationOptionsList");
            arrayList5 = null;
        }
        boolean z2 = true;
        if (!arrayList5.contains("verify_via_call")) {
            ArrayList<String> arrayList6 = this.u1;
            if (arrayList6 == null) {
                kotlin.jvm.internal.o.C("verificationOptionsList");
            } else {
                arrayList = arrayList6;
            }
            if (!arrayList.contains("otp_via_call")) {
                z = false;
                this.n1 = z;
                ObservableBoolean observableBoolean = this.r1;
                if (!this.l1 && !this.m1 && !z) {
                    z2 = false;
                }
                observableBoolean.h(z2);
            }
        }
        z = true;
        this.n1 = z;
        ObservableBoolean observableBoolean2 = this.r1;
        if (!this.l1) {
            z2 = false;
        }
        observableBoolean2.h(z2);
    }

    public final void G9(String objectName) {
        kotlin.jvm.internal.o.k(objectName, "objectName");
        in.swiggy.android.analytics.gtm.g h2 = s7().h("otp-verify", objectName, "-", 9999);
        kotlin.jvm.internal.o.j(h2, "getGtmEventData(...)");
        s7().b(h2);
    }

    public final void H9(String objectName) {
        kotlin.jvm.internal.o.k(objectName, "objectName");
        in.swiggy.android.analytics.gtm.g h2 = s7().h("otp-verify", objectName, "-", 9999);
        kotlin.jvm.internal.o.j(h2, "getGtmEventData(...)");
        s7().j(h2);
    }

    public final void I9() {
        LogoutUseCase b9 = b9();
        Context applicationContext = this.B0.getApplicationContext();
        kotlin.jvm.internal.o.j(applicationContext, "getApplicationContext(...)");
        b9.h(applicationContext);
        u7().signOut();
        this.z0.p2();
    }

    @Override
    public void J6() {
        super.J6();
        P8();
        q1 q1Var = this.k1;
        if (q1Var != null) {
            q1.a.a(q1Var, null, 1, null);
        }
        this.z0.C3();
    }

    public final void J8(SwiggyBaseResponse response) {
        kotlin.jvm.internal.o.k(response, "response");
        if (response.getStatusCode() == null) {
            ga(response.getStatusMessage());
            return;
        }
        Integer statusCode = response.getStatusCode();
        int code = AccountDeletionStatusCode.ARCHIVE_SUCCESS.getCode();
        if (statusCode != null && statusCode.intValue() == code) {
            I9();
        } else {
            ga(response.getStatusMessage());
        }
    }

    public final void J9() {
        this.G0.h(true);
        this.z0.C3();
        this.A0.getCallVerifyV2(this.E0, new SwiggyBaseResponseHandler<>(new SwiggyDataHandler() {
            @Override
            public final void handle(Object obj) {
                ForgotPasswordOTPViewModel.K9(ForgotPasswordOTPViewModel.this, (SwiggyBaseResponse) obj);
            }
        }, new SwiggyDataHandler() {
            @Override
            public final void handle(Object obj) {
                ForgotPasswordOTPViewModel.L9(ForgotPasswordOTPViewModel.this, (SwiggyBaseResponse) obj);
            }
        }), new io.reactivex.functions.d() {
            @Override
            public final void accept(Object obj) {
                ForgotPasswordOTPViewModel.M9(ForgotPasswordOTPViewModel.this, (Throwable) obj);
            }
        }, null);
    }

    @Override
    public void K6() {
        super.K6();
        this.G0.h(false);
    }

    @Override
    public void L7(Bundle args) {
        kotlin.jvm.internal.o.k(args, "args");
        this.E0 = args.getString("userPhoneNumber", null);
        this.F0 = args.getString("comingFrom", null);
    }

    public final io.reactivex.functions.a L8() {
        return new io.reactivex.functions.a() {
            @Override
            public final void run() {
                ForgotPasswordOTPViewModel.M8(ForgotPasswordOTPViewModel.this);
            }
        };
    }

    public final io.reactivex.functions.a N8() {
        return new io.reactivex.functions.a() {
            @Override
            public final void run() {
                ForgotPasswordOTPViewModel.O8(ForgotPasswordOTPViewModel.this);
            }
        };
    }

    public final void N9() {
        this.t1 = true;
        G9("click-verify-via-call");
        Q8();
        ArrayList<String> arrayList = this.u1;
        if (arrayList == null) {
            kotlin.jvm.internal.o.C("verificationOptionsList");
            arrayList = null;
        }
        if (arrayList.contains("verify_via_call")) {
            kotlinx.coroutines.g.d(l0.a(this), v0.b().Q(new b(kotlinx.coroutines.f0.v0, this)), null, new ForgotPasswordOTPViewModel$onCallClicked$1(this, null), 2, null);
            return;
        }
        N8().run();
    }

    public final Function0<Unit> O9() {
        return new Function0<Unit>() {
            {
                super(0);
            }

            @Override
            public Unit invoke() {
                invoke2();
                return Unit.a;
            }

            public final void invoke2() {
                ForgotPasswordOTPViewModel.this.T9("Sms-manual");
            }
        };
    }

    public final void P8() {
        CountDownTimer countDownTimer = this.d1;
        if (countDownTimer != null) {
            countDownTimer.cancel();
        }
        this.V0.h("");
        S8();
    }

    public final void P9() {
        this.t1 = true;
        G9("click-resend-sms");
        Q8();
        this.b1.h(true);
        Y9();
    }

    public final void Q8() {
        this.f1.h(false);
        this.g1.h(false);
        this.h1.h(false);
    }

    public final void Q9(String errorMessage, boolean z) {
        String J;
        kotlin.jvm.internal.o.k(errorMessage, "errorMessage");
        this.K0.h(Boolean.FALSE);
        this.L0.h(true);
        if (z) {
            if (!this.s1.g()) {
                ha();
            }
            S8();
        } else {
            C9();
        }
        if (this.s1.g()) {
            errorMessage = errorMessage + ". " + r0().getString(R.string.retry_via_text);
        }
        this.P0.h(errorMessage);
        ObservableField<String> observableField = this.Q0;
        String lowerCase = errorMessage.toLowerCase();
        kotlin.jvm.internal.o.j(lowerCase, "toLowerCase(...)");
        J = kotlin.text.q.J(lowerCase, r0().getString(R.string.otp_smallcase), r0().getString(R.string.otp_content_description), false, 4, null);
        observableField.h(J);
        this.G0.h(false);
    }

    public final void R8(String otp, CloningSignalsProto.CloningSignals cloningSignals, String traceName, String otpSource) {
        kotlin.jvm.internal.o.k(otp, "otp");
        kotlin.jvm.internal.o.k(cloningSignals, "cloningSignals");
        kotlin.jvm.internal.o.k(traceName, "traceName");
        kotlin.jvm.internal.o.k(otpSource, "otpSource");
        kotlinx.coroutines.g.d(l0.a(this), null, null, new ForgotPasswordOTPViewModel$doSignIn$1(this, cloningSignals, otp, otpSource, traceName, null), 3, null);
    }

    public final void S8() {
        if (this.o1.g()) {
            this.f1.h(true);
            H9("impression-resend-sms");
        }
        if (this.q1.g()) {
            this.g1.h(true);
            H9("impression-verify-via-call");
        }
        if (this.p1.g()) {
            this.h1.h(true);
            H9("impression-verify-via-whatsapp");
        }
    }

    public final void S9() {
        this.t1 = true;
        G9("click-verify-via-whatsapp");
        Q8();
        kotlinx.coroutines.g.d(l0.a(this), v0.b().Q(new c(kotlinx.coroutines.f0.v0, this)), null, new ForgotPasswordOTPViewModel$onWhatsappClicked$1(this, null), 2, null);
    }

    public final void T8(String traceName, String status) {
        kotlin.jvm.internal.o.k(traceName, "traceName");
        kotlin.jvm.internal.o.k(status, "status");
        v7().i("otp-verify", traceName, "status", status);
        v7().l("otp-verify", traceName);
    }

    public final void T9(String otpSource) {
        kotlin.jvm.internal.o.k(otpSource, "otpSource");
        in.swiggy.android.commons.extension.a.b(r7(), "IS_OTP_AUTO_READ", Boolean.valueOf(kotlin.jvm.internal.o.f(otpSource, "Sms-consent")));
        G9("click-verify-otp");
        this.a1 = true;
        this.K0.h(Boolean.FALSE);
        this.z0.C3();
        String g2 = this.R0.g();
        if (this.U0.b(g2) && g2 != null) {
            na(g2, otpSource);
        } else {
            this.z0.n3("OTP cannot be left blank");
        }
        P8();
    }

    @Override
    public void U6() {
        s7().m("otp-verify");
    }

    public final ObservableBoolean U8() {
        return this.r1;
    }

    public final ObservableBoolean V8() {
        return this.s1;
    }

    public final CloningSignalsProto.CloningSignals W8() {
        Context applicationContext = this.B0.getApplicationContext();
        kotlin.jvm.internal.o.j(applicationContext, "getApplicationContext(...)");
        return in.swiggy.android.feature.fraudDetection.c.a(applicationContext);
    }

    public final void W9() {
        try {
            kotlinx.coroutines.g.d(l0.a(this), DispatchProviderKt.c().Q(DispatchProviderKt.b().q2()), null, new ForgotPasswordOTPViewModel$sendAccountDeleteRequest$$inlined$launch$1(null, this), 2, null);
        } catch (Throwable th) {
            ga(null);
            in.swiggy.android.commons.utils.x.i(x1, th);
        }
    }

    public final String X8() {
        return this.F0;
    }

    public final ObservableBoolean Y8() {
        return this.g1;
    }

    public final void Y9() {
        if (kotlin.jvm.internal.o.f(this.F0, "account_deletion")) {
            X9();
        } else {
            this.A0.sendOTPV2(this.E0, new SignUpResponseHandler() {
                @Override
                public void handleOnSuccess(SwiggyBaseResponse response) {
                    String str;
                    LoginSignupServices loginSignupServices;
                    CharSequence k1;
                    kotlin.jvm.internal.o.k(response, "response");
                    p.a aVar = in.swiggy.android.network.interceptors.p.e;
                    String tid = response.getTid();
                    if (tid != null) {
                        k1 = StringsKt__StringsKt.k1(tid);
                        str = k1.toString();
                    } else {
                        str = null;
                    }
                    aVar.c(str, "https://profile.swiggy.comapi/v2/app/sms_otp", ForgotPasswordOTPViewModel.this.u7());
                    loginSignupServices = ForgotPasswordOTPViewModel.this.z0;
                    final ForgotPasswordOTPViewModel forgotPasswordOTPViewModel = ForgotPasswordOTPViewModel.this;
                    loginSignupServices.H3(new Function1<String, Unit>() {
                        {
                            super(1);
                        }

                        @Override
                        public Unit invoke(String str2) {
                            invoke2(str2);
                            return Unit.a;
                        }

                        public final void invoke2(String otpCode) {
                            kotlin.jvm.internal.o.k(otpCode, "otpCode");
                            ForgotPasswordOTPViewModel.this.P8();
                            ForgotPasswordOTPViewModel.this.da(otpCode);
                        }
                    });
                    ForgotPasswordOTPViewModel.ka(ForgotPasswordOTPViewModel.this, false, 1, null);
                }

                @Override
                public void onEmailAlreadyRegistered(SwiggyBaseResponse response) {
                    kotlin.jvm.internal.o.k(response, "response");
                    ForgotPasswordOTPViewModel.this.S8();
                }

                @Override
                public void onOtherErrors(SwiggyBaseResponse response) {
                    kotlin.jvm.internal.o.k(response, "response");
                    ForgotPasswordOTPViewModel.this.S8();
                }

                @Override
                public void onOtpLimitExceeded(SwiggyBaseResponse swiggyBaseResponse) {
                    String string;
                    ForgotPasswordOTPViewModel forgotPasswordOTPViewModel = ForgotPasswordOTPViewModel.this;
                    if (swiggyBaseResponse == null || (string = swiggyBaseResponse.getStatusMessage()) == null) {
                        string = ForgotPasswordOTPViewModel.this.r0().getString(R.string.verification_limit_exceeded_try_later);
                    }
                    forgotPasswordOTPViewModel.Q9(string, false);
                }

                @Override
                public void onReferralCodeNotValid(SwiggyBaseResponse response) {
                    kotlin.jvm.internal.o.k(response, "response");
                    ForgotPasswordOTPViewModel.this.S8();
                }
            }, new io.reactivex.functions.d() {
                @Override
                public final void accept(Object obj) {
                    ForgotPasswordOTPViewModel.Z9(ForgotPasswordOTPViewModel.this, (Throwable) obj);
                }
            }, null);
        }
    }

    public final ObservableBoolean Z8() {
        return this.f1;
    }

    public final ObservableBoolean a9() {
        return this.h1;
    }

    public final LogoutUseCase b9() {
        LogoutUseCase logoutUseCase = this.J0;
        if (logoutUseCase != null) {
            return logoutUseCase;
        }
        kotlin.jvm.internal.o.C("logoutUseCase");
        return null;
    }

    public final in.swiggy.android.commons.validation.f<String> c9() {
        return this.U0;
    }

    public final void ca() {
        if (kotlin.jvm.internal.o.f(this.F0, "account_deletion")) {
            this.O0.h(r0().getString(R.string.verify_deletion));
        } else {
            this.O0.h(r0().getString(R.string.verify_detail_v2));
        }
    }

    public final void da(String otp) {
        kotlin.jvm.internal.o.k(otp, "otp");
        if (this.U0.b(otp)) {
            this.R0.h(otp);
        }
    }

    public final boolean e9() {
        return this.e1;
    }

    public final void ea(boolean z) {
        this.e1 = z;
    }

    public final String f9() {
        return this.E0;
    }

    public final ObservableBoolean g9() {
        return this.q1;
    }

    public final void ga(String str) {
        this.G0.h(false);
        ObservableField<String> observableField = this.P0;
        if (str == null) {
            str = r0().getString(R.string.something_went_wrong);
        }
        observableField.h(str);
        this.L0.h(true);
        ha();
        P8();
    }

    public final ObservableBoolean h9() {
        return this.o1;
    }

    public final void ha() {
        boolean z;
        this.o1.h(this.l1);
        this.p1.h(this.m1);
        this.q1.h(this.n1);
        ObservableBoolean observableBoolean = this.s1;
        if (!this.l1 && !this.m1 && !this.n1) {
            z = false;
        } else {
            z = true;
        }
        observableBoolean.h(z);
    }

    public final ObservableBoolean i9() {
        return this.p1;
    }

    public final void ia(String traceName) {
        kotlin.jvm.internal.o.k(traceName, "traceName");
        v7().d("otp-verify", traceName);
    }

    @Override
    public void init() {
        F9();
        ca();
        this.U0.c(new in.swiggy.android.commons.validation.d(r0().getString(R.string.enter_otp)));
        ObservableField<String> observableField = this.N0;
        kotlin.jvm.internal.v vVar = kotlin.jvm.internal.v.a;
        String format = String.format(r0().getString(R.string.forgot_password_enter_otp_received), Arrays.copyOf(new Object[]{this.E0}, 1));
        kotlin.jvm.internal.o.j(format, "format(...)");
        observableField.h(format);
        if (kotlin.jvm.internal.o.f(this.F0, "account_deletion")) {
            this.E0 = u7().getPhoneNumber();
        }
        ObservableField<String> observableField2 = this.N0;
        String format2 = String.format(r0().getString(R.string.forgot_password_enter_otp_received), Arrays.copyOf(new Object[]{this.E0}, 1));
        kotlin.jvm.internal.o.j(format2, "format(...)");
        observableField2.h(format2);
        if (this.E0 != null) {
            ba();
            this.z0.t3();
            String str = this.F0;
            if (str != null) {
                switch (str.hashCode()) {
                    case -1936417761:
                        if (str.equals("otpVerifySetPwd")) {
                            Y9();
                            break;
                        }
                        break;
                    case -902467304:
                        break;
                    case -889129909:
                        break;
                    case -137382600:
                        if (str.equals("onlyOTPVerify")) {
                            Y9();
                            break;
                        }
                        break;
                    case 629944030:
                        if (str.equals("forgotPassword")) {
                            Y9();
                            break;
                        }
                        break;
                    case 705737923:
                        break;
                    case 1639034272:
                        break;
                }
            }
            this.z0.H3(new Function1<String, Unit>() {
                {
                    super(1);
                }

                @Override
                public Unit invoke(String str2) {
                    invoke2(str2);
                    return Unit.a;
                }

                public final void invoke2(String otpCode) {
                    kotlin.jvm.internal.o.k(otpCode, "otpCode");
                    ForgotPasswordOTPViewModel.this.da(otpCode);
                }
            });
            C9();
        } else {
            this.z0.x(r0().getString(R.string.something_went_wrong_try_again), 0);
        }
        fa();
        io.reactivex.disposables.a aVar = this.L;
        io.reactivex.d<String> P = u7().p().P(io.reactivex.android.schedulers.a.a());
        final Function1<String, Unit> function1 = new Function1<String, Unit>() {
            {
                super(1);
            }

            @Override
            public Unit invoke(String str2) {
                invoke2(str2);
                return Unit.a;
            }

            public final void invoke2(String str2) {
                LoginSignupServices loginSignupServices;
                if (ForgotPasswordOTPViewModel.this.u7().F() || !ForgotPasswordOTPViewModel.this.c9().b(str2)) {
                    loginSignupServices = ForgotPasswordOTPViewModel.this.z0;
                    loginSignupServices.n3(ForgotPasswordOTPViewModel.this.r0().getString(R.string.something_went_wrong_try_again));
                    return;
                }
                ForgotPasswordOTPViewModel forgotPasswordOTPViewModel = ForgotPasswordOTPViewModel.this;
                kotlin.jvm.internal.o.h(str2);
                forgotPasswordOTPViewModel.V9(str2);
            }
        };
        io.reactivex.functions.d<? super String> dVar = new io.reactivex.functions.d() {
            @Override
            public final void accept(Object obj) {
                ForgotPasswordOTPViewModel.D9(Function1.this, obj);
            }
        };
        final ForgotPasswordOTPViewModel$init$3 forgotPasswordOTPViewModel$init$3 = new Function1<Throwable, Unit>() {
            @Override
            public Unit invoke(Throwable th) {
                invoke2(th);
                return Unit.a;
            }

            public final void invoke2(Throwable th) {
                in.swiggy.android.commons.utils.x.i(ForgotPasswordOTPViewModel.v1.a(), th);
            }
        };
        aVar.c(P.g0(dVar, new io.reactivex.functions.d() {
            @Override
            public final void accept(Object obj) {
                ForgotPasswordOTPViewModel.E9(Function1.this, obj);
            }
        }));
    }

    public final ObservableBoolean j9() {
        return this.G0;
    }

    public final void ja(boolean z) {
        Q8();
        this.b1.h(false);
        this.X0.h(1);
        h hVar = new h(z, 25000L);
        this.d1 = hVar;
        hVar.start();
    }

    public final UserDeleteCheckUseCase l9() {
        UserDeleteCheckUseCase userDeleteCheckUseCase = this.I0;
        if (userDeleteCheckUseCase != null) {
            return userDeleteCheckUseCase;
        }
        kotlin.jvm.internal.o.C("userDeleteCheckUserCase");
        return null;
    }

    public final UserDeleteUseCase m9() {
        UserDeleteUseCase userDeleteUseCase = this.H0;
        if (userDeleteUseCase != null) {
            return userDeleteUseCase;
        }
        kotlin.jvm.internal.o.C("userDeleteUserCase");
        return null;
    }

    public final void ma(SwiggyBaseResponse response) {
        kotlin.jvm.internal.o.k(response, "response");
        this.G0.h(false);
        Integer statusCode = response.getStatusCode();
        if (statusCode != null && statusCode.intValue() == 28) {
            ka(this, false, 1, null);
        } else {
            ga(response.getStatusMessage());
        }
    }

    public final void na(String otp, String otpSource) {
        boolean A;
        boolean z;
        kotlin.jvm.internal.o.k(otp, "otp");
        kotlin.jvm.internal.o.k(otpSource, "otpSource");
        this.G0.h(true);
        io.reactivex.functions.d<Throwable> dVar = new io.reactivex.functions.d() {
            @Override
            public final void accept(Object obj) {
                ForgotPasswordOTPViewModel.pa(ForgotPasswordOTPViewModel.this, (Throwable) obj);
            }
        };
        A = kotlin.text.q.A(this.F0, "account_deletion", false, 2, null);
        if (!A) {
            z = kotlin.text.q.z(this.F0, "editAccount", true);
            if (!z && !kotlin.jvm.internal.o.f(this.F0, "webEditProfile")) {
                String k9 = k9(this.F0);
                ia(k9);
                R8(otp, W8(), k9, otpSource);
                return;
            }
            PostableMobileNumberEditOTP postableMobileNumberEditOTP = new PostableMobileNumberEditOTP(otp, this.E0);
            ia("otp-verify-edit-number");
            this.A0.mobileEditOTPVerify(postableMobileNumberEditOTP, new SwiggyBaseResponseHandler<>(new SwiggyDataHandler() {
                @Override
                public final void handle(Object obj) {
                    ForgotPasswordOTPViewModel.qa(ForgotPasswordOTPViewModel.this, (SwiggyApiResponse) obj);
                }
            }, new SwiggyDataHandler() {
                @Override
                public final void handle(Object obj) {
                    ForgotPasswordOTPViewModel.oa(ForgotPasswordOTPViewModel.this, (SwiggyApiResponse) obj);
                }
            }), dVar, null);
            return;
        }
        W9();
    }

    public final q1 y9(String customerId, Function0<Unit> postLoginActions) {
        kotlin.jvm.internal.o.k(customerId, "customerId");
        kotlin.jvm.internal.o.k(postLoginActions, "postLoginActions");
        Function1<ArrayList<Address>, Unit> function1 = new Function1<ArrayList<Address>, Unit>() {
            {
                super(1);
            }

            public final void a(ArrayList<Address> it) {
                kotlin.jvm.internal.o.k(it, "it");
                ForgotPasswordOTPViewModel.this.u7().m0(it);
            }

            @Override
            public Unit invoke(ArrayList<Address> arrayList) {
                a(arrayList);
                return Unit.a;
            }
        };
        final kotlinx.coroutines.flow.d<in.swiggy.android.tejas.Response<SwiggyApiResponse<AllAddress>>> invoke = e8().invoke(customerId);
        final kotlinx.coroutines.flow.d<in.swiggy.android.tejas.Response<? extends SwiggyApiResponse<AllAddress>>> dVar = new kotlinx.coroutines.flow.d<in.swiggy.android.tejas.Response<? extends SwiggyApiResponse<AllAddress>>>() {

            public static final class AnonymousClass2<T> implements kotlinx.coroutines.flow.e {
                final kotlinx.coroutines.flow.e a;

                @kotlin.coroutines.jvm.internal.d(c = "in.swiggy.android.mvvm.viewmodels.loginsignup.ForgotPasswordOTPViewModel$handleSignInAndAddressSync$$inlined$filter$1$2", f = "ForgotPasswordOTPViewModel.kt", l = {223}, m = "emit")
                public static final class AnonymousClass1 extends ContinuationImpl {
                    Object a;
                    int b;

                    public AnonymousClass1(kotlin.coroutines.c cVar) {
                        super(cVar);
                    }

                    @Override
                    public final Object invokeSuspend(Object obj) {
                        this.a = obj;
                        this.b |= Integer.MIN_VALUE;
                        return AnonymousClass2.this.emit(null, this);
                    }
                }

                public AnonymousClass2(kotlinx.coroutines.flow.e eVar) {
                    this.a = eVar;
                }

                @Override
                public final Object emit(Object obj, kotlin.coroutines.c cVar) {
                    AnonymousClass1 anonymousClass1;
                    Object f;
                    int i;
                    if (cVar instanceof AnonymousClass1) {
                        anonymousClass1 = (AnonymousClass1) cVar;
                        int i2 = anonymousClass1.b;
                        if ((i2 & Integer.MIN_VALUE) != 0) {
                            anonymousClass1.b = i2 - Integer.MIN_VALUE;
                            Object obj2 = anonymousClass1.a;
                            f = kotlin.coroutines.intrinsics.b.f();
                            i = anonymousClass1.b;
                            if (i == 0) {
                                if (i == 1) {
                                    kotlin.n.b(obj2);
                                } else {
                                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                                }
                            } else {
                                kotlin.n.b(obj2);
                                kotlinx.coroutines.flow.e eVar = this.a;
                                if (((in.swiggy.android.tejas.Response) obj) instanceof Response.Success) {
                                    anonymousClass1.b = 1;
                                    if (eVar.emit(obj, anonymousClass1) == f) {
                                        return f;
                                    }
                                }
                            }
                            return Unit.a;
                        }
                    }
                    anonymousClass1 = new AnonymousClass1(cVar);
                    Object obj22 = anonymousClass1.a;
                    f = kotlin.coroutines.intrinsics.b.f();
                    i = anonymousClass1.b;
                    if (i == 0) {
                    }
                    return Unit.a;
                }
            }

            @Override
            public Object collect(kotlinx.coroutines.flow.e<? super in.swiggy.android.tejas.Response<? extends SwiggyApiResponse<AllAddress>>> eVar, kotlin.coroutines.c cVar) {
                Object f2;
                Object collect = kotlinx.coroutines.flow.d.this.collect(new AnonymousClass2(eVar), cVar);
                f2 = kotlin.coroutines.intrinsics.b.f();
                if (collect == f2) {
                    return collect;
                }
                return Unit.a;
            }
        };
        return LoginAddressSyncKt.b(new kotlinx.coroutines.flow.d<AllAddress>() {

            public static final class AnonymousClass2<T> implements kotlinx.coroutines.flow.e {
                final kotlinx.coroutines.flow.e a;

                @kotlin.coroutines.jvm.internal.d(c = "in.swiggy.android.mvvm.viewmodels.loginsignup.ForgotPasswordOTPViewModel$handleSignInAndAddressSync$$inlined$map$1$2", f = "ForgotPasswordOTPViewModel.kt", l = {223}, m = "emit")
                public static final class AnonymousClass1 extends ContinuationImpl {
                    Object a;
                    int b;

                    public AnonymousClass1(kotlin.coroutines.c cVar) {
                        super(cVar);
                    }

                    @Override
                    public final Object invokeSuspend(Object obj) {
                        this.a = obj;
                        this.b |= Integer.MIN_VALUE;
                        return AnonymousClass2.this.emit(null, this);
                    }
                }

                public AnonymousClass2(kotlinx.coroutines.flow.e eVar) {
                    this.a = eVar;
                }

                @Override
                public final Object emit(Object obj, kotlin.coroutines.c cVar) {
                    AnonymousClass1 anonymousClass1;
                    Object f;
                    int i;
                    Response.Success success;
                    AllAddress allAddress;
                    SwiggyApiResponse swiggyApiResponse;
                    if (cVar instanceof AnonymousClass1) {
                        anonymousClass1 = (AnonymousClass1) cVar;
                        int i2 = anonymousClass1.b;
                        if ((i2 & Integer.MIN_VALUE) != 0) {
                            anonymousClass1.b = i2 - Integer.MIN_VALUE;
                            Object obj2 = anonymousClass1.a;
                            f = kotlin.coroutines.intrinsics.b.f();
                            i = anonymousClass1.b;
                            if (i == 0) {
                                if (i == 1) {
                                    kotlin.n.b(obj2);
                                } else {
                                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                                }
                            } else {
                                kotlin.n.b(obj2);
                                kotlinx.coroutines.flow.e eVar = this.a;
                                in.swiggy.android.tejas.Response response = (in.swiggy.android.tejas.Response) obj;
                                if (response instanceof Response.Success) {
                                    success = (Response.Success) response;
                                } else {
                                    success = null;
                                }
                                if (success == null || (swiggyApiResponse = (SwiggyApiResponse) success.getResponse()) == null || (allAddress = (AllAddress) swiggyApiResponse.getData()) == null) {
                                    allAddress = new AllAddress(null, 1, null);
                                }
                                anonymousClass1.b = 1;
                                if (eVar.emit(allAddress, anonymousClass1) == f) {
                                    return f;
                                }
                            }
                            return Unit.a;
                        }
                    }
                    anonymousClass1 = new AnonymousClass1(cVar);
                    Object obj22 = anonymousClass1.a;
                    f = kotlin.coroutines.intrinsics.b.f();
                    i = anonymousClass1.b;
                    if (i == 0) {
                    }
                    return Unit.a;
                }
            }

            @Override
            public Object collect(kotlinx.coroutines.flow.e<? super AllAddress> eVar, kotlin.coroutines.c cVar) {
                Object f2;
                Object collect = kotlinx.coroutines.flow.d.this.collect(new AnonymousClass2(eVar), cVar);
                f2 = kotlin.coroutines.intrinsics.b.f();
                if (collect == f2) {
                    return collect;
                }
                return Unit.a;
            }
        }, postLoginActions, function1, 0L, 0L, 12, null);
    }
}