导航菜单

页面标题

页面副标题

Crafto v9.3.3 - BaseSheetViewModel.java 源代码

正在查看: Crafto v9.3.3 应用的 BaseSheetViewModel.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package com.stripe.android.paymentsheet.viewmodels;

import Hk.p;
import Hk.q;
import Mk.e;
import Mk.i;
import android.app.Application;
import androidx.lifecycle.N;
import androidx.lifecycle.Q;
import androidx.lifecycle.S;
import androidx.lifecycle.T;
import androidx.lifecycle.e0;
import androidx.lifecycle.q0;
import androidx.lifecycle.s0;
import c0.u0;
import com.stripe.android.core.Logger;
import com.stripe.android.core.injection.InjectorKey;
import com.stripe.android.link.LinkActivityContract;
import com.stripe.android.link.LinkActivityResult;
import com.stripe.android.link.LinkPaymentDetails;
import com.stripe.android.link.LinkPaymentLauncher;
import com.stripe.android.link.injection.LinkPaymentLauncherFactory;
import com.stripe.android.link.model.AccountStatus;
import com.stripe.android.link.ui.inline.UserInput;
import com.stripe.android.model.PaymentIntent;
import com.stripe.android.model.PaymentMethod;
import com.stripe.android.model.PaymentMethodCreateParams;
import com.stripe.android.model.StripeIntent;
import com.stripe.android.payments.paymentlauncher.PaymentResult;
import com.stripe.android.paymentsheet.PaymentSheet;
import com.stripe.android.paymentsheet.PrefsRepository;
import com.stripe.android.paymentsheet.analytics.EventReporter;
import com.stripe.android.paymentsheet.model.FragmentConfig;
import com.stripe.android.paymentsheet.model.PaymentSelection;
import com.stripe.android.paymentsheet.model.SavedSelection;
import com.stripe.android.paymentsheet.model.SupportedPaymentMethodKtxKt;
import com.stripe.android.paymentsheet.paymentdatacollection.ach.USBankAccountFormScreenState;
import com.stripe.android.paymentsheet.repositories.CustomerRepository;
import com.stripe.android.paymentsheet.ui.PrimaryButton;
import com.stripe.android.paymentsheet.viewmodels.BaseSheetViewModel;
import com.stripe.android.ui.core.Amount;
import com.stripe.android.ui.core.forms.resources.LpmRepository;
import com.stripe.android.ui.core.forms.resources.ResourceRepository;
import dl.H;
import dl.J;
import dl.g;
import i.c;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import kotlin.Metadata;
import kotlin.NoWhenBranchMatchedException;
import kotlin.Unit;
import kotlin.collections.CollectionsKt;
import kotlin.collections.F;
import kotlin.collections.t;
import kotlin.collections.u;
import kotlin.coroutines.CoroutineContext;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.functions.Function2;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.jvm.internal.Intrinsics;
import org.jetbrains.annotations.NotNull;

@Metadata
public abstract class BaseSheetViewModel<TransitionTargetType> extends androidx.lifecycle.b {

    @NotNull
    public static final Companion Companion = new Companion(null);

    @NotNull
    public static final String SAVE_AMOUNT = "amount";

    @NotNull
    public static final String SAVE_GOOGLE_PAY_READY = "google_pay_ready";

    @NotNull
    public static final String SAVE_PAYMENT_METHODS = "customer_payment_methods";

    @NotNull
    public static final String SAVE_PROCESSING = "processing";

    @NotNull
    public static final String SAVE_RESOURCE_REPOSITORY_READY = "resource_repository_ready";

    @NotNull
    public static final String SAVE_SAVED_SELECTION = "saved_selection";

    @NotNull
    public static final String SAVE_SELECTED_ADD_LPM = "selected_add_lpm";

    @NotNull
    public static final String SAVE_SELECTION = "selection";

    @NotNull
    public static final String SAVE_STRIPE_INTENT = "stripe_intent";

    @NotNull
    public static final String SAVE_SUPPORTED_PAYMENT_METHOD = "supported_payment_methods";

    @NotNull
    private final S<Amount> _amount;

    @NotNull
    private final S<Boolean> _contentVisible;

    @NotNull
    private final S<Throwable> _fatal;

    @NotNull
    private final S<Boolean> _isGooglePayReady;

    @NotNull
    private final S<Boolean> _isLinkEnabled;

    @NotNull
    private final S<Boolean> _isResourceRepositoryReady;

    @NotNull
    private final S<Boolean> _liveMode;

    @NotNull
    private final S<String> _notesText;

    @NotNull
    private final S<List<PaymentMethod>> _paymentMethods;

    @NotNull
    private final S<PrimaryButton.State> _primaryButtonState;

    @NotNull
    private final S<PrimaryButton.UIState> _primaryButtonUIState;

    @NotNull
    private final S<Boolean> _processing;

    @NotNull
    private final S<SavedSelection> _savedSelection;

    @NotNull
    private final S<PaymentSelection> _selection;

    @NotNull
    private final S<Boolean> _showLinkVerificationDialog;

    @NotNull
    private final S<StripeIntent> _stripeIntent;

    @NotNull
    private final S<Event<TransitionTargetType>> _transition;

    @NotNull
    private final N<Amount> amount;

    @NotNull
    private final N<Boolean> buttonsEnabled;
    private final PaymentSheet.Configuration config;

    @NotNull
    private final N<Boolean> contentVisible;

    @NotNull
    private final N<Boolean> ctaEnabled;
    private final PaymentSheet.CustomerConfiguration customerConfig;

    @NotNull
    private final CustomerRepository customerRepository;

    @NotNull
    private final S<Boolean> editing;

    @NotNull
    private final EventReporter eventReporter;

    @NotNull
    private final N<Event<FragmentConfig>> fragmentConfigEvent;

    @NotNull
    private final S<Boolean> googlePayDividerVisibilility;

    @NotNull
    private final S<String> headerText;

    @NotNull
    private final String injectorKey;

    @NotNull
    private final N<Boolean> isGooglePayReady;

    @NotNull
    private final N<Boolean> isLinkEnabled;

    @NotNull
    private final N<Boolean> isResourceRepositoryReady;
    private c<LinkActivityContract.Args> linkActivityResultLauncher;

    @NotNull
    private final LinkPaymentLauncher linkLauncher;

    @NotNull
    private final LinkPaymentLauncherFactory linkPaymentLauncherFactory;
    private Function1<? super Boolean, Unit> linkVerificationCallback;

    @NotNull
    private final N<Boolean> liveMode;

    @NotNull
    private final Logger logger;

    @NotNull
    private final String merchantName;

    @NotNull
    private final N<String> notesText;

    @NotNull
    private final N<List<PaymentMethod>> paymentMethods;

    @NotNull
    private final PrefsRepository prefsRepository;

    @NotNull
    private final N<PrimaryButton.State> primaryButtonState;

    @NotNull
    private final N<PrimaryButton.UIState> primaryButtonUIState;

    @NotNull
    private final N<Boolean> processing;

    @NotNull
    private final ResourceRepository resourceRepository;

    @NotNull
    private final N<SavedSelection> savedSelection;

    @NotNull
    private final e0 savedStateHandle;

    @NotNull
    private final N<PaymentSelection> selection;

    @NotNull
    private final N<Boolean> showLinkVerificationDialog;

    @NotNull
    private final N<StripeIntent> stripeIntent;

    @NotNull
    private final N<Event<TransitionTargetType>> transition;
    private USBankAccountFormScreenState usBankAccountSavedScreenState;

    @NotNull
    private final CoroutineContext workContext;

    @Metadata
    @e(c = "com.stripe.android.paymentsheet.viewmodels.BaseSheetViewModel$1", f = "BaseSheetViewModel.kt", l = {240}, m = "invokeSuspend")
    public static final class AnonymousClass1 extends i implements Function2<H, Kk.c<? super Unit>, Object> {
        int label;
        final BaseSheetViewModel<TransitionTargetType> this$0;

        public AnonymousClass1(BaseSheetViewModel<TransitionTargetType> baseSheetViewModel, Kk.c<? super AnonymousClass1> cVar) {
            super(2, cVar);
            this.this$0 = baseSheetViewModel;
        }

        @NotNull
        public final Kk.c<Unit> create(Object obj, @NotNull Kk.c<?> cVar) {
            return new AnonymousClass1(this.this$0, cVar);
        }

        public final Object invoke(@NotNull H h, Kk.c<? super Unit> cVar) {
            return create(h, cVar).invokeSuspend(Unit.a);
        }

        public final Object invokeSuspend(@NotNull Object obj) {
            Lk.a aVar = Lk.a.COROUTINE_SUSPENDED;
            int i = this.label;
            if (i == 0) {
                q.b(obj);
                CoroutineContext workContext = this.this$0.getWorkContext();
                BaseSheetViewModel$1$savedSelection$1 baseSheetViewModel$1$savedSelection$1 = new BaseSheetViewModel$1$savedSelection$1(this.this$0, null);
                this.label = 1;
                obj = g.e(this, workContext, baseSheetViewModel$1$savedSelection$1);
                if (obj == aVar) {
                    return aVar;
                }
            } else {
                if (i != 1) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                q.b(obj);
            }
            this.this$0.getSavedStateHandle().e((SavedSelection) obj, BaseSheetViewModel.SAVE_SAVED_SELECTION);
            return Unit.a;
        }
    }

    @Metadata
    @e(c = "com.stripe.android.paymentsheet.viewmodels.BaseSheetViewModel$2", f = "BaseSheetViewModel.kt", l = {249}, m = "invokeSuspend")
    public static final class AnonymousClass2 extends i implements Function2<H, Kk.c<? super Unit>, Object> {
        int label;
        final BaseSheetViewModel<TransitionTargetType> this$0;

        public AnonymousClass2(BaseSheetViewModel<TransitionTargetType> baseSheetViewModel, Kk.c<? super AnonymousClass2> cVar) {
            super(2, cVar);
            this.this$0 = baseSheetViewModel;
        }

        @NotNull
        public final Kk.c<Unit> create(Object obj, @NotNull Kk.c<?> cVar) {
            return new AnonymousClass2(this.this$0, cVar);
        }

        public final Object invoke(@NotNull H h, Kk.c<? super Unit> cVar) {
            return create(h, cVar).invokeSuspend(Unit.a);
        }

        public final Object invokeSuspend(@NotNull Object obj) {
            Lk.a aVar = Lk.a.COROUTINE_SUSPENDED;
            int i = this.label;
            if (i == 0) {
                q.b(obj);
                ResourceRepository resourceRepository = this.this$0.getResourceRepository();
                this.label = 1;
                if (resourceRepository.waitUntilLoaded(this) == aVar) {
                    return aVar;
                }
            } else {
                if (i != 1) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                q.b(obj);
            }
            this.this$0.getSavedStateHandle().e(Boolean.TRUE, BaseSheetViewModel.SAVE_RESOURCE_REPOSITORY_READY);
            return Unit.a;
        }
    }

    @Metadata
    public static final class Companion {
        public Companion(DefaultConstructorMarker defaultConstructorMarker) {
            this();
        }

        private Companion() {
        }
    }

    @Metadata
    public static final class Event<T> {
        public static final int $stable = 8;
        private final T content;
        private boolean hasBeenHandled;

        public Event(T t) {
            this.content = t;
        }

        public final T getContentIfNotHandled() {
            if (this.hasBeenHandled) {
                return null;
            }
            this.hasBeenHandled = true;
            return this.content;
        }

        public final boolean getHasBeenHandled() {
            return this.hasBeenHandled;
        }

        public final T peekContent() {
            return this.content;
        }
    }

    @Metadata
    public static final class UserErrorMessage {
        public static final int $stable = 0;

        @NotNull
        private final String message;

        public UserErrorMessage(@NotNull String str) {
            Intrinsics.checkNotNullParameter(str, "message");
            this.message = str;
        }

        public static UserErrorMessage copy$default(UserErrorMessage userErrorMessage, String str, int i, Object obj) {
            if ((i & 1) != 0) {
                str = userErrorMessage.message;
            }
            return userErrorMessage.copy(str);
        }

        @NotNull
        public final String component1() {
            return this.message;
        }

        @NotNull
        public final UserErrorMessage copy(@NotNull String str) {
            Intrinsics.checkNotNullParameter(str, "message");
            return new UserErrorMessage(str);
        }

        public boolean equals(Object obj) {
            if (this == obj) {
                return true;
            }
            return (obj instanceof UserErrorMessage) && Intrinsics.areEqual(this.message, ((UserErrorMessage) obj).message);
        }

        @NotNull
        public final String getMessage() {
            return this.message;
        }

        public int hashCode() {
            return this.message.hashCode();
        }

        @NotNull
        public String toString() {
            return u0.a(new StringBuilder("UserErrorMessage(message="), this.message, ')');
        }
    }

    @Metadata
    public class WhenMappings {
        public static final int[] $EnumSwitchMapping$0;

        static {
            int[] iArr = new int[AccountStatus.values().length];
            iArr[AccountStatus.Verified.ordinal()] = 1;
            iArr[AccountStatus.VerificationStarted.ordinal()] = 2;
            iArr[AccountStatus.NeedsVerification.ordinal()] = 3;
            iArr[AccountStatus.SignedOut.ordinal()] = 4;
            $EnumSwitchMapping$0 = iArr;
        }
    }

    public BaseSheetViewModel(android.app.Application r14, com.stripe.android.paymentsheet.PaymentSheet.Configuration r15, com.stripe.android.paymentsheet.analytics.EventReporter r16, com.stripe.android.paymentsheet.repositories.CustomerRepository r17, com.stripe.android.paymentsheet.PrefsRepository r18, kotlin.coroutines.CoroutineContext r19, com.stripe.android.core.Logger r20, java.lang.String r21, com.stripe.android.ui.core.forms.resources.ResourceRepository r22, androidx.lifecycle.e0 r23, com.stripe.android.link.injection.LinkPaymentLauncherFactory r24, int r25, kotlin.jvm.internal.DefaultConstructorMarker r26) {
        throw new UnsupportedOperationException("Method not decompiled: com.stripe.android.paymentsheet.viewmodels.BaseSheetViewModel.<init>(android.app.Application, com.stripe.android.paymentsheet.PaymentSheet$Configuration, com.stripe.android.paymentsheet.analytics.EventReporter, com.stripe.android.paymentsheet.repositories.CustomerRepository, com.stripe.android.paymentsheet.PrefsRepository, kotlin.coroutines.CoroutineContext, com.stripe.android.core.Logger, java.lang.String, com.stripe.android.ui.core.forms.resources.ResourceRepository, androidx.lifecycle.e0, com.stripe.android.link.injection.LinkPaymentLauncherFactory, int, kotlin.jvm.internal.DefaultConstructorMarker):void");
    }

    public static final void m786buttonsEnabled$lambda4$lambda3$lambda2(Q q, BaseSheetViewModel baseSheetViewModel, Boolean bool) {
        Intrinsics.checkNotNullParameter(q, "$this_apply");
        Intrinsics.checkNotNullParameter(baseSheetViewModel, "this$0");
        Object value = baseSheetViewModel.processing.getValue();
        Boolean bool2 = Boolean.TRUE;
        q.setValue(Boolean.valueOf((Intrinsics.areEqual(value, bool2) || Intrinsics.areEqual(baseSheetViewModel.editing.getValue(), bool2)) ? false : true));
    }

    public final FragmentConfig createFragmentConfig() {
        StripeIntent stripeIntent = (StripeIntent) this.stripeIntent.getValue();
        Boolean bool = (Boolean) this.isGooglePayReady.getValue();
        Boolean bool2 = (Boolean) this.isResourceRepositoryReady.getValue();
        Boolean bool3 = (Boolean) this.isLinkEnabled.getValue();
        SavedSelection savedSelection = (SavedSelection) this.savedSelection.getValue();
        List list = (List) this.paymentMethods.getValue();
        if (stripeIntent == null || list == null || bool == null || bool2 == null || bool3 == null || savedSelection == null) {
            return null;
        }
        return new FragmentConfig(stripeIntent, bool.booleanValue(), savedSelection);
    }

    public final void createLinkPaymentDetails(PaymentMethodCreateParams paymentMethodCreateParams) {
        g.b(s0.a(this), (CoroutineContext) null, (J) null, new BaseSheetViewModel$createLinkPaymentDetails$1(this, paymentMethodCreateParams, null), 3);
    }

    public static void onError$default(BaseSheetViewModel baseSheetViewModel, Integer num, int i, Object obj) {
        if (obj != null) {
            throw new UnsupportedOperationException("Super calls with default arguments not supported in this target, function: onError");
        }
        if ((i & 1) != 0) {
            num = null;
        }
        baseSheetViewModel.onError(num);
    }

    private final void warnUnactivatedIfNeeded(List<String> list) {
        if (list.isEmpty()) {
            return;
        }
        this.logger.warning("[Stripe SDK] Warning: Your Intent contains the following payment method types which are activated for test mode but not activated for live mode: " + list + ". These payment method types will not be displayed in live mode until they are activated. To activate these payment method types visit your Stripe dashboard.More information: https://support.stripe.com/questions/activate-a-new-payment-method");
    }

    @NotNull
    public final LpmRepository.SupportedPaymentMethod getAddFragmentSelectedLPM$paymentsheet_release() {
        PaymentMethodCreateParams paymentMethodCreateParams;
        LpmRepository lpmRepository = this.resourceRepository.getLpmRepository();
        String str = (String) this.savedStateHandle.b(SAVE_SELECTED_ADD_LPM);
        if (str == null) {
            PaymentSelection.New newPaymentSelection = getNewPaymentSelection();
            str = (newPaymentSelection == null || (paymentMethodCreateParams = newPaymentSelection.getPaymentMethodCreateParams()) == null) ? null : paymentMethodCreateParams.getTypeCode();
        }
        LpmRepository.SupportedPaymentMethod fromCode = lpmRepository.fromCode(str);
        if (fromCode == null) {
            fromCode = (LpmRepository.SupportedPaymentMethod) CollectionsKt.E(getSupportedPaymentMethods$paymentsheet_release());
        }
        if (fromCode != null) {
            return fromCode;
        }
        throw new IllegalArgumentException("Required value was null.".toString());
    }

    @NotNull
    public final N<LpmRepository.SupportedPaymentMethod> getAddFragmentSelectedLpm() {
        PaymentMethodCreateParams paymentMethodCreateParams;
        e0 e0Var = this.savedStateHandle;
        PaymentSelection.New newPaymentSelection = getNewPaymentSelection();
        String typeCode = (newPaymentSelection == null || (paymentMethodCreateParams = newPaymentSelection.getPaymentMethodCreateParams()) == null) ? null : paymentMethodCreateParams.getTypeCode();
        e0Var.getClass();
        Intrinsics.checkNotNullParameter(SAVE_SELECTED_ADD_LPM, "key");
        S d = e0Var.d(SAVE_SELECTED_ADD_LPM, typeCode, true);
        Intrinsics.checkNotNullExpressionValue(d, "savedStateHandle.getLive…arams?.typeCode\n        )");
        Q b = q0.b(d, new u.a() {
            public final LpmRepository.SupportedPaymentMethod apply(String str) {
                LpmRepository.SupportedPaymentMethod fromCode = BaseSheetViewModel.this.getResourceRepository().getLpmRepository().fromCode(str);
                return fromCode == null ? (LpmRepository.SupportedPaymentMethod) CollectionsKt.E(BaseSheetViewModel.this.getSupportedPaymentMethods$paymentsheet_release()) : fromCode;
            }
        });
        Intrinsics.checkNotNullExpressionValue(b, "crossinline transform: (…p(this) { transform(it) }");
        return b;
    }

    @NotNull
    public final N<Amount> getAmount$paymentsheet_release() {
        return this.amount;
    }

    @NotNull
    public final N<Boolean> getButtonsEnabled() {
        return this.buttonsEnabled;
    }

    public final PaymentSheet.Configuration getConfig$paymentsheet_release() {
        return this.config;
    }

    @NotNull
    public final N<Boolean> getContentVisible$paymentsheet_release() {
        return this.contentVisible;
    }

    @NotNull
    public final N<Boolean> getCtaEnabled() {
        return this.ctaEnabled;
    }

    public final PaymentSheet.CustomerConfiguration getCustomerConfig$paymentsheet_release() {
        return this.customerConfig;
    }

    @NotNull
    public final CustomerRepository getCustomerRepository() {
        return this.customerRepository;
    }

    @NotNull
    public final EventReporter getEventReporter$paymentsheet_release() {
        return this.eventReporter;
    }

    @NotNull
    public final N<Event<FragmentConfig>> getFragmentConfigEvent() {
        return this.fragmentConfigEvent;
    }

    @NotNull
    public final S<Boolean> getGooglePayDividerVisibilility$paymentsheet_release() {
        return this.googlePayDividerVisibilility;
    }

    @NotNull
    public final S<String> getHeaderText$paymentsheet_release() {
        return this.headerText;
    }

    @NotNull
    public final String getInjectorKey() {
        return this.injectorKey;
    }

    @NotNull
    public final LinkPaymentLauncher getLinkLauncher() {
        return this.linkLauncher;
    }

    @NotNull
    public final LinkPaymentLauncherFactory getLinkPaymentLauncherFactory$paymentsheet_release() {
        return this.linkPaymentLauncherFactory;
    }

    public final Function1<Boolean, Unit> getLinkVerificationCallback() {
        return this.linkVerificationCallback;
    }

    @NotNull
    public final N<Boolean> getLiveMode$paymentsheet_release() {
        return this.liveMode;
    }

    @NotNull
    public final Logger getLogger() {
        return this.logger;
    }

    @NotNull
    public final String getMerchantName$paymentsheet_release() {
        return this.merchantName;
    }

    public abstract PaymentSelection.New getNewPaymentSelection();

    @NotNull
    public final N<String> getNotesText$paymentsheet_release() {
        return this.notesText;
    }

    @NotNull
    public final N<List<PaymentMethod>> getPaymentMethods$paymentsheet_release() {
        return this.paymentMethods;
    }

    @NotNull
    public final PrefsRepository getPrefsRepository() {
        return this.prefsRepository;
    }

    @NotNull
    public final N<PrimaryButton.State> getPrimaryButtonState() {
        return this.primaryButtonState;
    }

    @NotNull
    public final N<PrimaryButton.UIState> getPrimaryButtonUIState() {
        return this.primaryButtonUIState;
    }

    @NotNull
    public final N<Boolean> getProcessing() {
        return this.processing;
    }

    @NotNull
    public final ResourceRepository getResourceRepository() {
        return this.resourceRepository;
    }

    @NotNull
    public final e0 getSavedStateHandle() {
        return this.savedStateHandle;
    }

    @NotNull
    public final N<PaymentSelection> getSelection$paymentsheet_release() {
        return this.selection;
    }

    @NotNull
    public final N<Boolean> getShowLinkVerificationDialog() {
        return this.showLinkVerificationDialog;
    }

    @NotNull
    public final N<StripeIntent> getStripeIntent$paymentsheet_release() {
        return this.stripeIntent;
    }

    @NotNull
    public final List<LpmRepository.SupportedPaymentMethod> getSupportedPaymentMethods$paymentsheet_release() {
        List list = (List) this.savedStateHandle.b(SAVE_SUPPORTED_PAYMENT_METHOD);
        if (list == null) {
            return F.a;
        }
        ArrayList arrayList = new ArrayList();
        Iterator it = list.iterator();
        while (it.hasNext()) {
            LpmRepository.SupportedPaymentMethod fromCode = this.resourceRepository.getLpmRepository().fromCode((String) it.next());
            if (fromCode != null) {
                arrayList.add(fromCode);
            }
        }
        return arrayList;
    }

    @NotNull
    public final N<Event<TransitionTargetType>> getTransition$paymentsheet_release() {
        return this.transition;
    }

    public final USBankAccountFormScreenState getUsBankAccountSavedScreenState() {
        return this.usBankAccountSavedScreenState;
    }

    @NotNull
    public final CoroutineContext getWorkContext() {
        return this.workContext;
    }

    @NotNull
    public final S<Amount> get_amount$paymentsheet_release() {
        return this._amount;
    }

    @NotNull
    public final S<Boolean> get_contentVisible$paymentsheet_release() {
        return this._contentVisible;
    }

    @NotNull
    public final S<Throwable> get_fatal() {
        return this._fatal;
    }

    @NotNull
    public final S<Boolean> get_isGooglePayReady$paymentsheet_release() {
        return this._isGooglePayReady;
    }

    @NotNull
    public final S<Boolean> get_liveMode$paymentsheet_release() {
        return this._liveMode;
    }

    @NotNull
    public final S<List<PaymentMethod>> get_paymentMethods$paymentsheet_release() {
        return this._paymentMethods;
    }

    @NotNull
    public final S<Boolean> get_processing$paymentsheet_release() {
        return this._processing;
    }

    @NotNull
    public final N<Boolean> isGooglePayReady$paymentsheet_release() {
        return this.isGooglePayReady;
    }

    @NotNull
    public final N<Boolean> isLinkEnabled$paymentsheet_release() {
        return this.isLinkEnabled;
    }

    @NotNull
    public final N<Boolean> isResourceRepositoryReady$paymentsheet_release() {
        return this.isResourceRepositoryReady;
    }

    public final void launchLink() {
        c<LinkActivityContract.Args> cVar = this.linkActivityResultLauncher;
        if (cVar != null) {
            this.linkLauncher.present(cVar);
            onLinkLaunched();
        }
    }

    public abstract void onError(Integer num);

    public abstract void onError(String str);

    public abstract void onFatal(@NotNull Throwable th);

    public abstract void onFinish();

    public void onLinkActivityResult(@NotNull LinkActivityResult linkActivityResult) {
        Intrinsics.checkNotNullParameter(linkActivityResult, "result");
        setContentVisible(true);
    }

    public void onLinkLaunched() {
        setContentVisible(false);
    }

    public abstract void onLinkPaymentDetailsCollected(LinkPaymentDetails linkPaymentDetails);

    public abstract void onPaymentResult(@NotNull PaymentResult paymentResult);

    public abstract void onUserCancel();

    public final void payWithLink(@NotNull UserInput userInput) {
        final PaymentMethodCreateParams paymentMethodCreateParams;
        Intrinsics.checkNotNullParameter(userInput, "userInput");
        Object value = this.selection.getValue();
        PaymentSelection.New.Card card = value instanceof PaymentSelection.New.Card ? (PaymentSelection.New.Card) value : null;
        if (card == null || (paymentMethodCreateParams = card.getPaymentMethodCreateParams()) == null) {
            return;
        }
        e0 e0Var = this.savedStateHandle;
        Boolean bool = Boolean.TRUE;
        e0Var.e(bool, SAVE_PROCESSING);
        updatePrimaryButtonState(PrimaryButton.State.StartProcessing.INSTANCE);
        int i = WhenMappings.$EnumSwitchMapping$0[((AccountStatus) this.linkLauncher.getAccountStatus().getValue()).ordinal()];
        if (i == 1) {
            createLinkPaymentDetails(paymentMethodCreateParams);
            return;
        }
        if (i == 2 || i == 3) {
            this.linkVerificationCallback = new Function1<Boolean, Unit>(this) {
                final BaseSheetViewModel<TransitionTargetType> this$0;

                {
                    super(1);
                    this.this$0 = this;
                }

                public Object invoke(Object obj) {
                    invoke(((Boolean) obj).booleanValue());
                    return Unit.a;
                }

                public final void invoke(boolean z) {
                    S s;
                    this.this$0.setLinkVerificationCallback(null);
                    s = ((BaseSheetViewModel) this.this$0)._showLinkVerificationDialog;
                    Boolean bool2 = Boolean.FALSE;
                    s.setValue(bool2);
                    if (z) {
                        this.this$0.createLinkPaymentDetails(paymentMethodCreateParams);
                    } else {
                        this.this$0.getSavedStateHandle().e(bool2, BaseSheetViewModel.SAVE_PROCESSING);
                        this.this$0.updatePrimaryButtonState(PrimaryButton.State.Ready.INSTANCE);
                    }
                }
            };
            this._showLinkVerificationDialog.setValue(bool);
        } else {
            if (i != 4) {
                throw new NoWhenBranchMatchedException();
            }
            g.b(s0.a(this), (CoroutineContext) null, (J) null, new BaseSheetViewModel$payWithLink$1$2(this, userInput, null), 3);
        }
    }

    public void registerFromActivity(@NotNull i.b bVar) {
        Intrinsics.checkNotNullParameter(bVar, "activityResultCaller");
        this.linkActivityResultLauncher = bVar.registerForActivityResult(new LinkActivityContract(), new i.a() {
            public final void onActivityResult(Object obj) {
                BaseSheetViewModel.this.onLinkActivityResult((LinkActivityResult) obj);
            }
        });
    }

    @NotNull
    public final dl.u0 removePaymentMethod(@NotNull PaymentMethod paymentMethod) {
        Intrinsics.checkNotNullParameter(paymentMethod, "paymentMethod");
        return (dl.u0) g.c(kotlin.coroutines.e.a, new BaseSheetViewModel$removePaymentMethod$1(paymentMethod, this, null));
    }

    public final void setAddFragmentSelectedLPM$paymentsheet_release(@NotNull LpmRepository.SupportedPaymentMethod supportedPaymentMethod) {
        Intrinsics.checkNotNullParameter(supportedPaymentMethod, "value");
        this.savedStateHandle.e(supportedPaymentMethod.getCode(), SAVE_SELECTED_ADD_LPM);
    }

    public final void setContentVisible(boolean z) {
        this._contentVisible.setValue(Boolean.valueOf(z));
    }

    public final void setEditing(boolean z) {
        this.editing.setValue(Boolean.valueOf(z));
    }

    public final void setLinkVerificationCallback(Function1<? super Boolean, Unit> function1) {
        this.linkVerificationCallback = function1;
    }

    public abstract void setNewPaymentSelection(PaymentSelection.New r1);

    public final void setStripeIntent(StripeIntent stripeIntent) {
        Unit a;
        e0 e0Var;
        Long amount;
        this.savedStateHandle.e(stripeIntent, SAVE_STRIPE_INTENT);
        setSupportedPaymentMethods$paymentsheet_release(SupportedPaymentMethodKtxKt.getPMsToAdd(stripeIntent, this.config, this.resourceRepository.getLpmRepository()));
        if (stripeIntent != null && getSupportedPaymentMethods$paymentsheet_release().isEmpty()) {
            StringBuilder sb = new StringBuilder("None of the requested payment methods (");
            sb.append(stripeIntent.getPaymentMethodTypes());
            sb.append(") match the supported payment types (");
            Collection values = this.resourceRepository.getLpmRepository().values();
            ArrayList arrayList = new ArrayList(u.n(values, 10));
            Iterator it = values.iterator();
            while (it.hasNext()) {
                arrayList.add(((LpmRepository.SupportedPaymentMethod) it.next()).getCode());
            }
            sb.append(CollectionsKt.c0(arrayList));
            sb.append(')');
            onFatal(new IllegalArgumentException(sb.toString()));
        }
        if (stripeIntent instanceof PaymentIntent) {
            try {
                p.a aVar = p.b;
                e0Var = this.savedStateHandle;
                amount = ((PaymentIntent) stripeIntent).getAmount();
            } catch (Throwable th) {
                p.a aVar2 = p.b;
                a = q.a(th);
            }
            if (amount == null) {
                throw new IllegalArgumentException("Required value was null.".toString());
            }
            long longValue = amount.longValue();
            String currency = ((PaymentIntent) stripeIntent).getCurrency();
            if (currency == null) {
                throw new IllegalArgumentException("Required value was null.".toString());
            }
            e0Var.e(new Amount(longValue, currency), SAVE_AMOUNT);
            this._primaryButtonUIState.setValue((Object) null);
            a = Unit.a;
            if (p.a(a) != null) {
                onFatal(new IllegalStateException("PaymentIntent must contain amount and currency."));
            }
        }
        if (stripeIntent != null) {
            this._liveMode.postValue(Boolean.valueOf(stripeIntent.isLiveMode()));
            warnUnactivatedIfNeeded(stripeIntent.getUnactivatedPaymentMethods());
        }
    }

    public final void setSupportedPaymentMethods$paymentsheet_release(@NotNull List<LpmRepository.SupportedPaymentMethod> list) {
        Intrinsics.checkNotNullParameter(list, "value");
        e0 e0Var = this.savedStateHandle;
        List<LpmRepository.SupportedPaymentMethod> list2 = list;
        ArrayList arrayList = new ArrayList(u.n(list2, 10));
        Iterator<T> it = list2.iterator();
        while (it.hasNext()) {
            arrayList.add(((LpmRepository.SupportedPaymentMethod) it.next()).getCode());
        }
        e0Var.e(arrayList, SAVE_SUPPORTED_PAYMENT_METHOD);
    }

    public final void setUsBankAccountSavedScreenState(USBankAccountFormScreenState uSBankAccountFormScreenState) {
        this.usBankAccountSavedScreenState = uSBankAccountFormScreenState;
    }

    public final void setupLink(@NotNull StripeIntent stripeIntent, boolean z) {
        Intrinsics.checkNotNullParameter(stripeIntent, "stripeIntent");
        this._isLinkEnabled.setValue(Boolean.FALSE);
    }

    public void transitionTo(TransitionTargetType transitiontargettype) {
        this._transition.postValue(new Event(transitiontargettype));
    }

    public void unregisterFromActivity() {
        this.linkActivityResultLauncher = null;
    }

    public final void updateBelowButtonText(String str) {
        this._notesText.setValue(str);
    }

    public final void updatePrimaryButtonState(@NotNull PrimaryButton.State state) {
        Intrinsics.checkNotNullParameter(state, "state");
        this._primaryButtonState.setValue(state);
    }

    public final void updatePrimaryButtonUIState(PrimaryButton.UIState uIState) {
        this._primaryButtonUIState.setValue(uIState);
    }

    public void updateSelection(PaymentSelection paymentSelection) {
        if (paymentSelection instanceof PaymentSelection.New) {
            setNewPaymentSelection((PaymentSelection.New) paymentSelection);
        }
        this.savedStateHandle.e(paymentSelection, SAVE_SELECTION);
        updateBelowButtonText(null);
    }

    public static void onError$default(BaseSheetViewModel baseSheetViewModel, String str, int i, Object obj) {
        if (obj != null) {
            throw new UnsupportedOperationException("Super calls with default arguments not supported in this target, function: onError");
        }
        if ((i & 1) != 0) {
            str = null;
        }
        baseSheetViewModel.onError(str);
    }

    public BaseSheetViewModel(@NotNull Application application, PaymentSheet.Configuration configuration, @NotNull EventReporter eventReporter, @NotNull CustomerRepository customerRepository, @NotNull PrefsRepository prefsRepository, @NotNull CoroutineContext coroutineContext, @NotNull Logger logger, @InjectorKey @NotNull String str, @NotNull ResourceRepository resourceRepository, @NotNull e0 e0Var, @NotNull LinkPaymentLauncherFactory linkPaymentLauncherFactory) {
        super(application);
        int i;
        PaymentSheet.BillingDetails defaultBillingDetails;
        PaymentSheet.BillingDetails defaultBillingDetails2;
        Intrinsics.checkNotNullParameter(application, "application");
        Intrinsics.checkNotNullParameter(eventReporter, "eventReporter");
        Intrinsics.checkNotNullParameter(customerRepository, "customerRepository");
        Intrinsics.checkNotNullParameter(prefsRepository, "prefsRepository");
        Intrinsics.checkNotNullParameter(coroutineContext, "workContext");
        Intrinsics.checkNotNullParameter(logger, "logger");
        Intrinsics.checkNotNullParameter(str, "injectorKey");
        Intrinsics.checkNotNullParameter(resourceRepository, "resourceRepository");
        Intrinsics.checkNotNullParameter(e0Var, "savedStateHandle");
        Intrinsics.checkNotNullParameter(linkPaymentLauncherFactory, "linkPaymentLauncherFactory");
        this.config = configuration;
        this.eventReporter = eventReporter;
        this.customerRepository = customerRepository;
        this.prefsRepository = prefsRepository;
        this.workContext = coroutineContext;
        this.logger = logger;
        this.injectorKey = str;
        this.resourceRepository = resourceRepository;
        this.savedStateHandle = e0Var;
        this.linkPaymentLauncherFactory = linkPaymentLauncherFactory;
        this.customerConfig = configuration != null ? configuration.getCustomer() : null;
        String obj = (configuration == null || (obj = configuration.getMerchantDisplayName()) == null) ? application.getApplicationInfo().loadLabel(application.getPackageManager()).toString() : obj;
        this.merchantName = obj;
        this._fatal = new S<>();
        S<Boolean> c = e0Var.c(SAVE_GOOGLE_PAY_READY);
        Intrinsics.checkNotNullExpressionValue(c, "savedStateHandle.getLive…n>(SAVE_GOOGLE_PAY_READY)");
        this._isGooglePayReady = c;
        Q a = q0.a(c);
        Intrinsics.checkNotNullExpressionValue(a, "distinctUntilChanged(this)");
        this.isGooglePayReady = a;
        S<Boolean> c2 = e0Var.c(SAVE_RESOURCE_REPOSITORY_READY);
        Intrinsics.checkNotNullExpressionValue(c2, "savedStateHandle.getLive…CE_REPOSITORY_READY\n    )");
        this._isResourceRepositoryReady = c2;
        Q a2 = q0.a(c2);
        Intrinsics.checkNotNullExpressionValue(a2, "distinctUntilChanged(this)");
        this.isResourceRepositoryReady = a2;
        S<Boolean> s = new S<>();
        this._isLinkEnabled = s;
        Q a3 = q0.a(s);
        Intrinsics.checkNotNullExpressionValue(a3, "distinctUntilChanged(this)");
        this.isLinkEnabled = a3;
        S<StripeIntent> c3 = e0Var.c(SAVE_STRIPE_INTENT);
        Intrinsics.checkNotNullExpressionValue(c3, "savedStateHandle.getLive…tent>(SAVE_STRIPE_INTENT)");
        this._stripeIntent = c3;
        this.stripeIntent = c3;
        S<List<PaymentMethod>> c4 = e0Var.c(SAVE_PAYMENT_METHODS);
        Intrinsics.checkNotNullExpressionValue(c4, "savedStateHandle.getLive…d>>(SAVE_PAYMENT_METHODS)");
        this._paymentMethods = c4;
        this.paymentMethods = c4;
        S<Amount> c5 = e0Var.c(SAVE_AMOUNT);
        Intrinsics.checkNotNullExpressionValue(c5, "savedStateHandle.getLiveData<Amount>(SAVE_AMOUNT)");
        this._amount = c5;
        this.amount = c5;
        this.headerText = new S<>();
        Boolean bool = Boolean.FALSE;
        this.googlePayDividerVisibilility = new S<>(bool);
        S<SavedSelection> c6 = e0Var.c(SAVE_SAVED_SELECTION);
        Intrinsics.checkNotNullExpressionValue(c6, "savedStateHandle.getLive…on>(SAVE_SAVED_SELECTION)");
        this._savedSelection = c6;
        this.savedSelection = c6;
        S<Event<TransitionTargetType>> s2 = new S<>(new Event(null));
        this._transition = s2;
        this.transition = s2;
        S<Boolean> s3 = new S<>();
        this._liveMode = s3;
        this.liveMode = s3;
        S<PaymentSelection> c7 = e0Var.c(SAVE_SELECTION);
        Intrinsics.checkNotNullExpressionValue(c7, "savedStateHandle.getLive…election>(SAVE_SELECTION)");
        this._selection = c7;
        this.selection = c7;
        N s4 = new S(bool);
        this.editing = s4;
        N c8 = e0Var.c(SAVE_PROCESSING);
        Intrinsics.checkNotNullExpressionValue(c8, "savedStateHandle.getLive…Boolean>(SAVE_PROCESSING)");
        this._processing = c8;
        this.processing = c8;
        S<Boolean> s5 = new S<>(Boolean.TRUE);
        this._contentVisible = s5;
        Q a4 = q0.a(s5);
        Intrinsics.checkNotNullExpressionValue(a4, "distinctUntilChanged(this)");
        this.contentVisible = a4;
        S<PrimaryButton.UIState> s6 = new S<>();
        this._primaryButtonUIState = s6;
        this.primaryButtonUIState = s6;
        S<PrimaryButton.State> s7 = new S<>();
        this._primaryButtonState = s7;
        this.primaryButtonState = s7;
        S<String> s8 = new S<>();
        this._notesText = s8;
        this.notesText = s8;
        this.linkLauncher = linkPaymentLauncherFactory.create(obj, (configuration == null || (defaultBillingDetails2 = configuration.getDefaultBillingDetails()) == null) ? null : defaultBillingDetails2.getEmail(), (configuration == null || (defaultBillingDetails = configuration.getDefaultBillingDetails()) == null) ? null : defaultBillingDetails.getPhone());
        S<Boolean> s9 = new S<>(bool);
        this._showLinkVerificationDialog = s9;
        this.showLinkVerificationDialog = s9;
        final Q q = new Q();
        Iterator it = t.i(new N[]{c8, s4}).iterator();
        while (it.hasNext()) {
            q.a((N) it.next(), new T() {
                public final void onChanged(Object obj2) {
                    BaseSheetViewModel.m786buttonsEnabled$lambda4$lambda3$lambda2(q, this, (Boolean) obj2);
                }
            });
        }
        N a5 = q0.a(q);
        Intrinsics.checkNotNullExpressionValue(a5, "distinctUntilChanged(this)");
        this.buttonsEnabled = a5;
        final Q q2 = new Q();
        Iterator it2 = t.i(new N[]{this.primaryButtonUIState, a5, this.selection}).iterator();
        while (it2.hasNext()) {
            q2.a((N) it2.next(), new T() {
                public final void onChanged(Object obj2) {
                    Boolean valueOf;
                    Q<Boolean> q3 = q2;
                    boolean z = false;
                    if (this.getPrimaryButtonUIState().getValue() != null) {
                        PrimaryButton.UIState uIState = (PrimaryButton.UIState) this.getPrimaryButtonUIState().getValue();
                        if (uIState != null && uIState.getEnabled() && Intrinsics.areEqual(this.getButtonsEnabled().getValue(), Boolean.TRUE)) {
                            z = true;
                        }
                        valueOf = Boolean.valueOf(z);
                    } else {
                        if (Intrinsics.areEqual(this.getButtonsEnabled().getValue(), Boolean.TRUE) && this.getSelection$paymentsheet_release().getValue() != null) {
                            z = true;
                        }
                        valueOf = Boolean.valueOf(z);
                    }
                    q3.setValue(valueOf);
                }
            });
        }
        Q a6 = q0.a(q2);
        Intrinsics.checkNotNullExpressionValue(a6, "distinctUntilChanged(this)");
        this.ctaEnabled = a6;
        if (this._savedSelection.getValue() == null) {
            i = 3;
            g.b(s0.a(this), (CoroutineContext) null, (J) null, new AnonymousClass1(this, null), 3);
        } else {
            i = 3;
        }
        if (this._isResourceRepositoryReady.getValue() == null) {
            g.b(s0.a(this), (CoroutineContext) null, (J) null, new AnonymousClass2(this, null), i);
        }
        final Q q3 = new Q();
        Iterator it3 = t.i(new N[]{this.savedSelection, this.stripeIntent, this.paymentMethods, this.isGooglePayReady, this.isResourceRepositoryReady, this.isLinkEnabled}).iterator();
        while (it3.hasNext()) {
            q3.a((N) it3.next(), new T() {
                public final void onChanged(Object obj2) {
                    FragmentConfig createFragmentConfig;
                    Q<FragmentConfig> q4 = q3;
                    createFragmentConfig = this.createFragmentConfig();
                    q4.setValue(createFragmentConfig);
                }
            });
        }
        Q a7 = q0.a(q3);
        Intrinsics.checkNotNullExpressionValue(a7, "distinctUntilChanged(this)");
        Q b = q0.b(a7, new u.a() {
            public final BaseSheetViewModel.Event<? extends FragmentConfig> apply(FragmentConfig fragmentConfig) {
                return new BaseSheetViewModel.Event<>(fragmentConfig);
            }
        });
        Intrinsics.checkNotNullExpressionValue(b, "crossinline transform: (…p(this) { transform(it) }");
        this.fragmentConfigEvent = b;
    }

    public static void get_amount$paymentsheet_release$annotations() {
    }

    public static void get_contentVisible$paymentsheet_release$annotations() {
    }

    public static void get_isGooglePayReady$paymentsheet_release$annotations() {
    }

    public static void get_liveMode$paymentsheet_release$annotations() {
    }

    public static void get_paymentMethods$paymentsheet_release$annotations() {
    }

    public static void get_processing$paymentsheet_release$annotations() {
    }
}