import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
import { useMemo, useState } from "react";
import { NATIVE_TOKEN_ADDRESS } from "../../../../../../constants/addresses.js";
import { isSwapRequiredPostOnramp } from "../../../../../../pay/buyWithFiat/isSwapRequiredPostOnramp.js";
import { formatNumber } from "../../../../../../utils/formatNumber.js";
import { toEther } from "../../../../../../utils/units.js";
import { fontSize, spacing, } from "../../../../../core/design-system/index.js";
import { useChainQuery, useChainsQuery, } from "../../../../../core/hooks/others/useChainQuery.js";
import { useWalletBalance } from "../../../../../core/hooks/others/useWalletBalance.js";
import { useBuyWithCryptoQuote } from "../../../../../core/hooks/pay/useBuyWithCryptoQuote.js";
import { useBuyWithFiatQuote } from "../../../../../core/hooks/pay/useBuyWithFiatQuote.js";
import { useActiveAccount, useActiveWalletChain, } from "../../../../../core/hooks/wallets/wallet-hooks.js";
import { LoadingScreen } from "../../../../wallets/shared/LoadingScreen.js";
import { Drawer, DrawerOverlay, useDrawer, } from "../../../components/Drawer.js";
import { DynamicHeight } from "../../../components/DynamicHeight.js";
import { Skeleton } from "../../../components/Skeleton.js";
import { Spacer } from "../../../components/Spacer.js";
import { Spinner } from "../../../components/Spinner.js";
import { SwitchNetworkButton } from "../../../components/SwitchNetwork.js";
import { TokenIcon } from "../../../components/TokenIcon.js";
import { Container, Line, ModalHeader } from "../../../components/basic.js";
import { Button } from "../../../components/buttons.js";
import { Text } from "../../../components/text.js";
import { ChainButton, NetworkSelectorContent } from "../../NetworkSelector.js";
import { TokenSelector } from "../TokenSelector.js";
import { NATIVE_TOKEN, isNativeToken, } from "../nativeToken.js";
import { EstimatedTimeAndFees } from "./EstimatedTimeAndFees.js";
import { PayWithCreditCard } from "./PayWIthCreditCard.js";
import { PaymentSelection } from "./PaymentSelection.js";
import { FiatFlow } from "./fiat/FiatFlow.js";
import { useBuyTxStates } from "./main/useBuyTxStates.js";
import { useEnabledPaymentMethods } from "./main/useEnabledPaymentMethods.js";
import { useUISelectionStates } from "./main/useUISelectionStates.js";
import { openOnrampPopup } from "./openOnRamppopup.js";
import { BuyTokenInput } from "./swap/BuyTokenInput.js";
import { FiatFees, SwapFees } from "./swap/Fees.js";
import { PayWithCrypto } from "./swap/PayWithCrypto.js";
import { SwapFlow } from "./swap/SwapFlow.js";
import { addPendingTx } from "./swap/pendingSwapTx.js";
import { useBuySupportedDestinations, useBuySupportedSources, } from "./swap/useSwapSupportedChains.js";
/**
 * @internal
 */
export default function BuyScreen(props) {
    const supportedDestinationsQuery = useBuySupportedDestinations(props.client);
    if (!supportedDestinationsQuery.data) {
        return _jsx(LoadingScreen, {});
    }
    return (_jsx(BuyScreenContent, { ...props, onViewPendingTx: props.onViewPendingTx, supportedDestinations: supportedDestinationsQuery.data, buyForTx: props.buyForTx }));
}
function useBuyScreenStates(options) {
    const { payOptions } = options;
    const [method, setMethod] = useState(payOptions.buyWithCrypto === false
        ? "creditCard"
        : payOptions.buyWithFiat === false
            ? "crypto"
            : "creditCard");
    const [screen, setScreen] = useState({
        type: "main",
    });
    const [drawerScreen, setDrawerScreen] = useState();
    const { drawerRef, drawerOverlayRef, onClose } = useDrawer();
    function closeDrawer() {
        onClose(() => {
            setDrawerScreen(undefined);
        });
    }
    function showMainScreen() {
        setScreen({
            type: "main",
        });
    }
    return {
        method,
        setMethod,
        screen,
        setScreen,
        drawerScreen,
        setDrawerScreen,
        drawerRef,
        drawerOverlayRef,
        closeDrawer,
        showMainScreen,
    };
}
/**
 * @internal
 */
function BuyScreenContent(props) {
    const { client, supportedDestinations, connectLocale, payOptions, buyForTx } = props;
    const account = useActiveAccount();
    const activeChain = useActiveWalletChain();
    // prefetch chains metadata for destination chains
    useChainsQuery(supportedDestinations.map((x) => x.chain) || [], 50);
    // screen
    const { method, setMethod, screen, setScreen, drawerScreen, setDrawerScreen, drawerRef, drawerOverlayRef, closeDrawer, showMainScreen, } = useBuyScreenStates({ payOptions });
    // UI selection
    const { tokenAmount, setTokenAmount, setHasEditedAmount, hasEditedAmount, toChain, setToChain, deferredTokenAmount, fromChain, setFromChain, toToken, setToToken, fromToken, setFromToken, selectedCurrency, } = useUISelectionStates({
        payOptions,
        buyForTx,
        supportedDestinations,
    });
    // Buy Transaction flow states
    const { amountNeeded } = useBuyTxStates({
        setTokenAmount,
        buyForTx,
        hasEditedAmount,
        isMainScreen: screen.type === "main",
        account,
    });
    // check if the screen is expanded or not
    const isExpanded = activeChain && tokenAmount;
    // update supportedSources whenever toToken or toChain is updated
    const supportedSourcesQuery = useBuySupportedSources({
        client: props.client,
        destinationChainId: toChain.id,
        destinationTokenAddress: isNativeToken(toToken)
            ? NATIVE_TOKEN_ADDRESS
            : toToken.address,
    });
    const destinationSupportedTokens = useMemo(() => {
        return createSupportedTokens(supportedDestinations, payOptions, props.supportedTokens);
    }, [props.supportedTokens, supportedDestinations, payOptions]);
    const sourceSupportedTokens = useMemo(() => {
        if (!supportedSourcesQuery.data) {
            return undefined;
        }
        return createSupportedTokens(supportedSourcesQuery.data, payOptions, props.supportedTokens);
    }, [props.supportedTokens, supportedSourcesQuery.data, payOptions]);
    const { showPaymentSelection } = useEnabledPaymentMethods({
        payOptions,
        supportedDestinations,
        toChain,
        toToken,
        method,
        setMethod,
    });
    // screens ----------------------------
    if (screen.type === "node") {
        return screen.node;
    }
    if (screen.type === "screen-id" && screen.name === "select-to-token") {
        const chains = supportedDestinations.map((x) => x.chain);
        // if token selection is disabled - only show network selector screen
        if (payOptions.prefillBuy?.allowEdits?.token === false) {
            return (_jsx(ChainSelectionScreen, { chains: chains, client: props.client, connectLocale: props.connectLocale, setChain: setToChain, showMainScreen: showMainScreen }));
        }
        return (_jsx(TokenSelector, { onBack: showMainScreen, tokenList: ((toChain?.id ? destinationSupportedTokens[toChain.id] : undefined) ||
                []).filter((x) => x.address !== NATIVE_TOKEN_ADDRESS), onTokenSelect: (tokenInfo) => {
                setToToken(tokenInfo);
                showMainScreen();
            }, chain: toChain, chainSelection: 
            // hide chain selection if it's disabled
            payOptions.prefillBuy?.allowEdits?.chain !== false
                ? {
                    chains: chains,
                    select: (c) => {
                        setToChain(c);
                    },
                }
                : undefined, connectLocale: connectLocale, client: client }));
    }
    if (screen.type === "screen-id" &&
        screen.name === "select-from-token" &&
        supportedSourcesQuery.data &&
        sourceSupportedTokens) {
        const chains = supportedSourcesQuery.data.map((x) => x.chain);
        // if token selection is disabled - only show network selector screen
        if (payOptions.buyWithCrypto !== false &&
            payOptions.buyWithCrypto?.prefillSource?.allowEdits?.token === false) {
            return (_jsx(ChainSelectionScreen, { chains: chains, client: props.client, connectLocale: props.connectLocale, setChain: setFromChain, showMainScreen: showMainScreen }));
        }
        return (_jsx(TokenSelector, { onBack: showMainScreen, tokenList: ((fromChain?.id ? sourceSupportedTokens[fromChain.id] : undefined) ||
                []).filter((x) => x.address !== NATIVE_TOKEN_ADDRESS), onTokenSelect: (tokenInfo) => {
                setFromToken(tokenInfo);
                setScreen({
                    type: "main",
                });
            }, chain: fromChain, chainSelection: 
            // hide chain selection if it's disabled
            payOptions.buyWithCrypto !== false &&
                payOptions.buyWithCrypto?.prefillSource?.allowEdits?.chain !== false
                ? {
                    chains: supportedSourcesQuery.data.map((x) => x.chain),
                    select: (c) => setFromChain(c),
                }
                : undefined, connectLocale: connectLocale, client: client }));
    }
    return (_jsx(Container, { animate: "fadein", children: _jsxs("div", { onClick: (e) => {
                if (drawerScreen &&
                    drawerRef.current &&
                    !drawerRef.current.contains(e.target)) {
                    e.preventDefault();
                    e.stopPropagation();
                    closeDrawer();
                }
            }, children: [drawerScreen && (_jsxs(_Fragment, { children: [_jsx(DrawerOverlay, { ref: drawerOverlayRef }), _jsx(Drawer, { ref: drawerRef, close: closeDrawer, children: _jsx(DynamicHeight, { children: drawerScreen }) })] })), _jsxs(Container, { p: "lg", style: {
                        paddingBottom: 0,
                    }, children: [_jsx(ModalHeader, { title: props.buyForTx
                                ? `Not enough ${props.buyForTx.tokenSymbol}`
                                : "Buy", onBack: props.onBack }), _jsx(Spacer, { y: "lg" }), !isExpanded && _jsx(Spacer, { y: "xl" }), amountNeeded && props.buyForTx ? (_jsx(BuyForTxUI, { amountNeeded: String(formatNumber(Number(toEther(amountNeeded)), 4)), buyForTx: props.buyForTx, client: client })) : null, _jsx(BuyTokenInput, { value: tokenAmount, onChange: async (value) => {
                                setHasEditedAmount(true);
                                setTokenAmount(value);
                            }, freezeAmount: payOptions.prefillBuy?.allowEdits?.amount === false, freezeChainAndToken: payOptions.prefillBuy?.allowEdits?.chain === false &&
                                payOptions.prefillBuy?.allowEdits?.token === false, token: toToken, chain: toChain, onSelectToken: () => {
                                setScreen({
                                    type: "screen-id",
                                    name: "select-to-token",
                                });
                            }, client: props.client, hideTokenSelector: !!props.buyForTx })] }), showPaymentSelection ? _jsx(Spacer, { y: "lg" }) : _jsx(Spacer, { y: "md" }), isExpanded && (_jsxs(_Fragment, { children: [showPaymentSelection && (_jsxs(Container, { px: "lg", children: [_jsx(PaymentSelection, { selected: method, onSelect: setMethod }), _jsx(Spacer, { y: "md" })] })), method === "crypto" && account && activeChain && (_jsx(SwapScreenContent, { ...props, setScreen: setScreen, setDrawerScreen: setDrawerScreen, tokenAmount: deferredTokenAmount, toChain: toChain, toToken: toToken, fromChain: fromChain, fromToken: fromToken, showFromTokenSelector: () => {
                                setScreen({
                                    type: "screen-id",
                                    name: "select-from-token",
                                });
                            }, account: account, activeChain: activeChain })), method === "creditCard" && account && (_jsx(FiatScreenContent, { ...props, setScreen: setScreen, setDrawerScreen: setDrawerScreen, tokenAmount: deferredTokenAmount, toChain: toChain, toToken: toToken, closeDrawer: closeDrawer, selectedCurrency: selectedCurrency, showCurrencySelector: () => {
                                // currently disabled because we are only using Stripe
                            }, account: account })), _jsx(Spacer, { y: "sm" })] })), _jsxs(Container, { px: "lg", flex: "column", gap: "sm", children: [!isExpanded && (_jsx(_Fragment, { children: !account && props.connectButton ? (_jsx("div", { children: props.connectButton })) : (_jsx(Button, { variant: "accent", fullWidth: true, disabled: true, "data-disable": true, children: "Continue" })) })), account && (_jsx(Button, { variant: "outline", fullWidth: true, style: {
                                padding: spacing.xs,
                                fontSize: fontSize.sm,
                            }, onClick: props.onViewPendingTx, children: "View all transactions" }))] }), _jsx(Spacer, { y: "lg" })] }) }));
}
function SwapScreenContent(props) {
    const { setDrawerScreen, setScreen, account, client, toChain, tokenAmount, toToken, fromChain, fromToken, showFromTokenSelector, payOptions, } = props;
    const fromTokenBalanceQuery = useWalletBalance({
        address: account.address,
        chain: fromChain,
        tokenAddress: isNativeToken(fromToken) ? undefined : fromToken.address,
        client,
    });
    const quoteParams = tokenAmount && !(fromChain.id === toChain.id && fromToken === toToken)
        ? {
            // wallet
            fromAddress: account.address,
            // from
            fromChainId: fromChain.id,
            fromTokenAddress: isNativeToken(fromToken)
                ? NATIVE_TOKEN_ADDRESS
                : fromToken.address,
            // to
            toChainId: toChain.id,
            toTokenAddress: isNativeToken(toToken)
                ? NATIVE_TOKEN_ADDRESS
                : toToken.address,
            toAmount: tokenAmount,
            client,
        }
        : undefined;
    const quoteQuery = useBuyWithCryptoQuote(quoteParams, {
        // refetch every 30 seconds
        staleTime: 30 * 1000,
        refetchInterval: 30 * 1000,
        gcTime: 30 * 1000,
    });
    const sourceTokenAmount = quoteQuery.data?.swapDetails.fromAmount;
    const isNotEnoughBalance = !!sourceTokenAmount &&
        !!fromTokenBalanceQuery.data &&
        Number(fromTokenBalanceQuery.data.displayValue) < Number(sourceTokenAmount);
    const disableContinue = !quoteQuery.data || isNotEnoughBalance;
    const switchChainRequired = props.activeChain.id !== fromChain.id;
    function getErrorMessage(err) {
        const defaultMessage = "Unable to get price quote";
        try {
            if (err instanceof Error) {
                if (err.message.includes("Minimum")) {
                    const msg = err.message;
                    return msg.replace("Fetch failed: Error: ", "");
                }
            }
            return defaultMessage;
        }
        catch {
            return defaultMessage;
        }
    }
    function showSwapFlow() {
        if (!quoteQuery.data) {
            return;
        }
        setScreen({
            type: "node",
            node: (_jsx(SwapFlow, { isBuyForTx: !!props.buyForTx, isEmbed: props.isEmbed, client: client, onBack: () => {
                    setScreen({
                        type: "main",
                    });
                }, buyWithCryptoQuote: quoteQuery.data, account: account, onViewPendingTx: props.onViewPendingTx, isFiatFlow: false, onDone: props.onDone, onTryAgain: () => {
                    setScreen({
                        type: "main",
                    });
                    quoteQuery.refetch();
                } })),
        });
    }
    function showFees() {
        if (!quoteQuery.data) {
            return;
        }
        setDrawerScreen(_jsxs("div", { children: [_jsx(Text, { size: "lg", color: "primaryText", children: "Fees" }), _jsx(Spacer, { y: "lg" }), _jsx(SwapFees, { quote: quoteQuery.data, align: "left" })] }));
    }
    const prefillSource = payOptions.buyWithCrypto !== false
        ? payOptions.buyWithCrypto?.prefillSource
        : undefined;
    return (_jsxs(Container, { px: "lg", flex: "column", gap: "md", children: [_jsxs("div", { children: [_jsx(PayWithCrypto, { value: sourceTokenAmount || "", onSelectToken: showFromTokenSelector, chain: fromChain, token: fromToken, isLoading: quoteQuery.isLoading && !sourceTokenAmount, client: client, freezeChainAndTokenSelection: prefillSource?.allowEdits?.chain === false &&
                            prefillSource?.allowEdits?.token === false }), _jsx(EstimatedTimeAndFees, { quoteIsLoading: quoteQuery.isLoading, estimatedSeconds: quoteQuery.data?.swapDetails.estimated.durationSeconds, onViewFees: showFees })] }), quoteQuery.error && (_jsx(Text, { color: "danger", size: "sm", center: true, children: getErrorMessage(quoteQuery.error) })), switchChainRequired &&
                !quoteQuery.isLoading &&
                !isNotEnoughBalance &&
                !quoteQuery.error ? (_jsx(SwitchNetworkButton, { variant: "accent", fullWidth: true, chain: fromChain })) : (_jsx(Button, { variant: disableContinue ? "outline" : "accent", fullWidth: true, "data-disabled": disableContinue, disabled: disableContinue, onClick: async () => {
                    if (!disableContinue) {
                        showSwapFlow();
                    }
                }, gap: "xs", children: isNotEnoughBalance ? (_jsx(Text, { color: "danger", children: "Not Enough Funds" })) : quoteQuery.isLoading ? (_jsxs(_Fragment, { children: [_jsx(Spinner, { size: "sm", color: "accentText" }), "Getting price quote"] })) : ("Continue") }))] }));
}
function FiatScreenContent(props) {
    const { toToken, tokenAmount, account, client, setScreen, setDrawerScreen, toChain, showCurrencySelector, selectedCurrency, } = props;
    const buyWithFiatOptions = props.payOptions.buyWithFiat;
    const fiatQuoteQuery = useBuyWithFiatQuote(buyWithFiatOptions !== false && tokenAmount
        ? {
            fromCurrencySymbol: "USD", // STRIPE only supports USD
            toChainId: toChain.id,
            toAddress: account.address,
            toTokenAddress: isNativeToken(toToken)
                ? NATIVE_TOKEN_ADDRESS
                : toToken.address,
            toAmount: tokenAmount,
            client,
            isTestMode: buyWithFiatOptions?.testMode,
        }
        : undefined);
    function handleSubmit() {
        if (!fiatQuoteQuery.data) {
            return;
        }
        const hasTwoSteps = isSwapRequiredPostOnramp(fiatQuoteQuery.data);
        let openedWindow = null;
        if (!hasTwoSteps) {
            openedWindow = openOnrampPopup(fiatQuoteQuery.data.onRampLink, typeof props.theme === "string" ? props.theme : props.theme.type);
            addPendingTx({
                type: "fiat",
                intentId: fiatQuoteQuery.data.intentId,
            });
        }
        setScreen({
            type: "node",
            node: (_jsx(FiatFlow, { isBuyForTx: !!props.buyForTx, quote: fiatQuoteQuery.data, onBack: () => {
                    setScreen({
                        type: "main",
                    });
                }, client: client, testMode: buyWithFiatOptions !== false
                    ? buyWithFiatOptions?.testMode || false
                    : false, theme: typeof props.theme === "string" ? props.theme : props.theme.type, onViewPendingTx: props.onViewPendingTx, openedWindow: openedWindow, onDone: props.onDone, isEmbed: props.isEmbed })),
        });
    }
    function showFees() {
        if (!fiatQuoteQuery.data) {
            return;
        }
        setDrawerScreen(_jsxs("div", { children: [_jsx(Text, { size: "lg", color: "primaryText", children: "Fees" }), _jsx(Spacer, { y: "lg" }), _jsx(FiatFees, { quote: fiatQuoteQuery.data })] }));
    }
    // biome-ignore lint/suspicious/noExplicitAny: <explanation>
    function getErrorMessage(err) {
        const defaultMessage = "Unable to get price quote";
        try {
            if (err.error.code === "MINIMUM_PURCHASE_AMOUNT") {
                const obj = err.error;
                return [
                    `Minimum purchase amount is $${obj.data.minimumAmountUSDCents / 100}`,
                    `Requested amount is $${obj.data.requestedAmountUSDCents / 100}`,
                ];
            }
        }
        catch { }
        return [defaultMessage];
    }
    const disableSubmit = !fiatQuoteQuery.data;
    return (_jsxs(Container, { px: "lg", flex: "column", gap: "md", children: [_jsxs("div", { children: [_jsx(PayWithCreditCard, { isLoading: fiatQuoteQuery.isLoading, value: fiatQuoteQuery.data?.fromCurrencyWithFees.amount, client: client, currency: selectedCurrency, onSelectCurrency: showCurrencySelector, disableCurrencySelection: true }), _jsx(EstimatedTimeAndFees, { quoteIsLoading: fiatQuoteQuery.isLoading, estimatedSeconds: fiatQuoteQuery.data?.estimatedDurationSeconds, onViewFees: showFees })] }), fiatQuoteQuery.error && (_jsx("div", { children: getErrorMessage(fiatQuoteQuery.error).map((msg) => (_jsx(Text, { color: "danger", size: "sm", center: true, multiline: true, children: msg }, msg))) })), _jsx(Button, { variant: disableSubmit ? "outline" : "accent", "data-disabled": disableSubmit, disabled: disableSubmit, fullWidth: true, onClick: handleSubmit, gap: "xs", children: fiatQuoteQuery.isLoading ? (_jsxs(_Fragment, { children: [_jsx(Spinner, { size: "sm", color: "accentText" }), "Getting price quote"] })) : ("Continue") })] }));
}
function BuyForTxUI(props) {
    const chainQuery = useChainQuery(props.buyForTx.tx.chain);
    return (_jsxs(Container, { children: [_jsx(Spacer, { y: "xs" }), _jsxs(Container, { flex: "row", style: {
                    justifyContent: "space-between",
                }, children: [_jsx(Text, { size: "sm", children: "Amount Needed" }), _jsxs(Container, { flex: "column", style: {
                            alignItems: "flex-end",
                        }, children: [_jsxs(Container, { flex: "row", gap: "xs", center: "y", children: [_jsxs(Text, { color: "primaryText", size: "sm", children: [props.amountNeeded, " ", props.buyForTx.tokenSymbol] }), _jsx(TokenIcon, { chain: props.buyForTx.tx.chain, client: props.client, size: "sm", token: NATIVE_TOKEN })] }), _jsx(Spacer, { y: "xxs" }), chainQuery.data ? (_jsxs(Text, { size: "sm", children: [" ", chainQuery.data.name] })) : (_jsx(Skeleton, { height: fontSize.sm, width: "50px" }))] })] }), _jsx(Spacer, { y: "md" }), _jsx(Line, {}), _jsx(Spacer, { y: "md" }), _jsxs(Container, { flex: "row", style: {
                    justifyContent: "space-between",
                }, children: [_jsx(Text, { size: "sm", children: "Your Balance" }), _jsxs(Container, { flex: "row", gap: "xs", children: [_jsxs(Text, { color: "primaryText", size: "sm", children: [formatNumber(Number(toEther(props.buyForTx.balance)), 4), " ", props.buyForTx.tokenSymbol] }), _jsx(TokenIcon, { chain: props.buyForTx.tx.chain, client: props.client, size: "sm", token: NATIVE_TOKEN })] })] }), _jsx(Spacer, { y: "md" }), _jsx(Line, {}), _jsx(Spacer, { y: "lg" }), _jsx(Text, { center: true, size: "sm", children: "Purchase" }), _jsx(Spacer, { y: "xxs" })] }));
}
function createSupportedTokens(data, payOptions, supportedTokensOverrides) {
    const tokens = {};
    const isBuyWithFiatDisabled = payOptions.buyWithFiat === false;
    const isBuyWithCryptoDisabled = payOptions.buyWithCrypto === false;
    for (const x of data) {
        tokens[x.chain.id] = x.tokens.filter((t) => {
            // it token supports both - include it
            if (t.buyWithCryptoEnabled && t.buyWithFiatEnabled) {
                return true;
            }
            // if buyWithFiat is disabled, and buyWithCrypto is not supported by token - exclude the token
            if (!t.buyWithCryptoEnabled && isBuyWithFiatDisabled) {
                return false;
            }
            // if buyWithCrypto is disabled, and buyWithFiat is not supported by token - exclude the token
            if (!t.buyWithFiatEnabled && isBuyWithCryptoDisabled) {
                return false;
            }
            return true; // include the token
        });
    }
    // override with props.supportedTokens
    if (supportedTokensOverrides) {
        for (const k in supportedTokensOverrides) {
            const key = Number(k);
            const tokenList = supportedTokensOverrides[key];
            if (tokenList) {
                tokens[key] = tokenList;
            }
        }
    }
    return tokens;
}
function ChainSelectionScreen(props) {
    return (_jsx(NetworkSelectorContent, { client: props.client, connectLocale: props.connectLocale, showTabs: false, onBack: props.showMainScreen, chains: props.chains, closeModal: props.showMainScreen, networkSelector: {
            renderChain(renderChainProps) {
                return (_jsx(ChainButton, { chain: renderChainProps.chain, confirming: false, switchingFailed: false, onClick: () => {
                        props.setChain(renderChainProps.chain);
                        props.showMainScreen();
                    }, client: props.client, connectLocale: props.connectLocale }));
            },
        } }));
}
//# sourceMappingURL=BuyScreen.js.map