'use client'
'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var jsxRuntime = require('react/jsx-runtime');
var React = require('react');
var reactI18next = require('react-i18next');
var utils = require('@dynamic-labs/utils');
var walletBook = require('@dynamic-labs/wallet-book');
var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
var Icon = require('../../components/Icon/Icon.cjs');
var IconWithSpinner = require('../../components/IconWithSpinner/IconWithSpinner.cjs');
var Typography = require('../../components/Typography/Typography.cjs');
var TypographyButton = require('../../components/TypographyButton/TypographyButton.cjs');
require('../../context/DynamicContext/DynamicContext.cjs');
require('../../store/state/loadingAndLifecycle/loadingAndLifecycle.cjs');
require('@dynamic-labs/iconic');
var externalLink = require('../../shared/assets/externalLink.cjs');
require('../../context/ViewContext/ViewContext.cjs');
require('../../shared/logger.cjs');
require('../../utils/constants/colors.cjs');
require('../../utils/constants/values.cjs');
require('@dynamic-labs/sdk-api-core');
require('../../shared/consts/index.cjs');
require('../../events/dynamicEvents.cjs');
require('../../../../_virtual/_tslib.cjs');
require('../../context/CaptchaContext/CaptchaContext.cjs');
require('../../context/ErrorContext/ErrorContext.cjs');
require('@dynamic-labs/multi-wallet');
require('react-international-phone');
require('../../store/state/nonce/nonce.cjs');
var pixelToRem = require('../../utils/functions/pixelToRem/pixelToRem.cjs');
require('@dynamic-labs-sdk/client/core');
require('../../client/client.cjs');
require('@dynamic-labs-sdk/client');
require('../../config/ApiEndpoint.cjs');
require('@dynamic-labs/locale');
require('../../store/state/dynamicContextProps/dynamicContextProps.cjs');
require('../../store/state/primaryWalletId/primaryWalletId.cjs');
require('../../store/state/connectedWalletsInfo/connectedWalletsInfo.cjs');
require('../../context/AccessDeniedContext/AccessDeniedContext.cjs');
require('../../context/AccountExistsContext/AccountExistsContext.cjs');
require('../../context/UserWalletsContext/UserWalletsContext.cjs');
require('../../store/state/authMode/authMode.cjs');
require('../../context/VerificationContext/VerificationContext.cjs');
require('react-dom');
require('../../utils/functions/compareChains/compareChains.cjs');
require('../Passkey/utils/findPrimaryEmbeddedChain/findPrimaryEmbeddedChain.cjs');
require('../../context/ThemeContext/ThemeContext.cjs');
require('../../utils/hooks/useUserUpdateRequest/useUpdateUser/userFieldsSchema.cjs');
require('bs58');
require('@dynamic-labs/types');
require('../../context/SocialRedirectContext/SocialRedirectContext.cjs');
require('../../context/LoadingContext/LoadingContext.cjs');
require('../../context/WalletContext/WalletContext.cjs');
require('../../utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/constants.cjs');
require('yup');
require('../../context/MockContext/MockContext.cjs');
require('../CollectUserDataView/useFields.cjs');
require('../../context/FieldsStateContext/FieldsStateContext.cjs');
require('../../context/UserFieldEditorContext/UserFieldEditorContext.cjs');
require('@dynamic-labs/rpc-providers');
require('../../store/state/walletOptions/walletOptions.cjs');
require('../../components/Accordion/components/AccordionItem/AccordionItem.cjs');
require('../../components/Alert/Alert.cjs');
require('../../components/ShadowDOM/ShadowDOM.cjs');
require('../../components/IconButton/IconButton.cjs');
require('../../components/InlineWidget/InlineWidget.cjs');
require('../../components/Input/Input.cjs');
require('../../components/IsBrowser/IsBrowser.cjs');
require('../../components/MenuList/Dropdown/Dropdown.cjs');
require('../../components/OverlayCard/OverlayCard.cjs');
require('../../components/Transition/ZoomTransition/ZoomTransition.cjs');
require('../../components/Transition/SlideInUpTransition/SlideInUpTransition.cjs');
require('../../components/Transition/OpacityTransition/OpacityTransition.cjs');
require('../../components/PasskeyCreatedSuccessBanner/PasskeyCreatedSuccessBanner.cjs');
require('../../components/Popper/Popper/Popper.cjs');
require('../../components/Popper/PopperContext/PopperContext.cjs');
require('react-focus-lock');
require('qrcode');
require('formik');
require('../../utils/hooks/useSubdomainCheck/useSubdomainCheck.cjs');
require('../../context/WalletGroupContext/WalletGroupContext.cjs');
require('../../context/IpConfigurationContext/IpConfigurationContext.cjs');
require('../../context/ConnectWithOtpContext/ConnectWithOtpContext.cjs');
require('../../widgets/DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.cjs');
require('@hcaptcha/react-hcaptcha');
require('../../widgets/DynamicWidget/context/DynamicWidgetContext.cjs');
require('../../widgets/DynamicWidget/helpers/convertExchangeKeyAndProviderEnum.cjs');
require('../ExchangeWhitelistWarning/ExchangeWhitelistWarning.cjs');
require('../../context/ErrorContext/hooks/useErrorText/useErrorText.cjs');
require('../../context/FooterAnimationContext/index.cjs');
require('../MfaChooseDeviceView/useGetMfaOptions/useGetMfaOptions.cjs');
require('../../context/PasskeyContext/PasskeyContext.cjs');
require('../../context/OnrampContext/OnrampContext.cjs');
require('../../store/state/sendBalances.cjs');
require('../../store/state/connectorsInitializing/connectorsInitializing.cjs');
require('../../components/OverlayCardBase/OverlayCardTarget/OverlayCardTarget.cjs');
require('../../widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetHeader.cjs');
require('../TransactionConfirmationView/TransactionConfirmationView.cjs');
require('../../widgets/DynamicWidget/components/PasskeyCard/PasskeyCard.cjs');
require('../../widgets/DynamicWidget/views/CryptoComOnramp/CryptoComOnramp.cjs');
require('../../../index.cjs');
require('../../widgets/DynamicWidget/views/ReceiveWalletFunds/ReceiveWalletFunds.cjs');
require('../../store/state/tokenBalances.cjs');
require('../../store/state/multichainBalances.cjs');
require('../../shared/utils/functions/getInitialUrl/getInitialUrl.cjs');
var useInternalDynamicContext = require('../../context/DynamicContext/useDynamicContext/useInternalDynamicContext/useInternalDynamicContext.cjs');

const MobileWalletRedirectView = ({ onRetry, connector, }) => {
    const { selectedWalletConnector } = useInternalDynamicContext.useInternalDynamicContext();
    const currentConnector = React.useMemo(() => connector || selectedWalletConnector, [connector, selectedWalletConnector]);
    const { t } = reactI18next.useTranslation();
    const { storeName, walletLink } = React.useMemo(() => {
        const walletLinks = walletConnectorCore.getWalletLinks(currentConnector === null || currentConnector === void 0 ? void 0 : currentConnector.metadata.downloadLinks);
        if ((walletLinks === null || walletLinks === void 0 ? void 0 : walletLinks.ios) && utils.isIOS())
            return {
                storeName: 'App Store',
                walletLink: walletLinks.ios,
            };
        if ((walletLinks === null || walletLinks === void 0 ? void 0 : walletLinks.android) && (utils.isAndroid() || utils.isSamsungBrowser()))
            return {
                storeName: 'Play Store',
                walletLink: walletLinks.android,
            };
        return {
            storeName: undefined,
            walletLink: undefined,
        };
    }, [currentConnector]);
    const openWalletApp = () => walletLink &&
        utils.PlatformService.openURL(walletLink, 'blank', 'noopener,noreferrer');
    const makeIcon = (size) => (jsxRuntime.jsx(walletBook.WalletIcon, { icon: currentConnector === null || currentConnector === void 0 ? void 0 : currentConnector.metadata.icon, walletKey: currentConnector === null || currentConnector === void 0 ? void 0 : currentConnector.key, style: {
            height: pixelToRem.pixelToRem(size),
            width: pixelToRem.pixelToRem(size),
        } }));
    return (jsxRuntime.jsxs("div", { className: 'mobile-wallet-redirect', children: [jsxRuntime.jsx(IconWithSpinner.IconWithSpinner, { Icon: makeIcon(94 * IconWithSpinner.iconRatio), iconSize: 94, isSpinning: true, className: 'mobile-wallet-redirect__icon-with-spinner' }), jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', weight: 'regular', className: 'mobile-wallet-redirect__copy-text', copykey: 'dyn_login.mobile_wallet_redirect.prompt', children: t('dyn_login.mobile_wallet_redirect.prompt') }), jsxRuntime.jsxs(TypographyButton.TypographyButton, { buttonVariant: 'brand-primary', typographyProps: { color: 'white', variant: 'button_secondary' }, onClick: onRetry, buttonPadding: 'small', copykey: 'dyn_login.mobile_wallet_redirect.open_prompt', children: [t('dyn_login.mobile_wallet_redirect.open_prompt'), ' ', currentConnector === null || currentConnector === void 0 ? void 0 : currentConnector.name] }), storeName && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Typography.Typography, { variant: 'body_small', color: 'secondary', className: 'mobile-wallet-redirect__alert', copykey: 'dyn_login.mobile_wallet_redirect.redirect_fail_message', children: t('dyn_login.mobile_wallet_redirect.redirect_fail_message', {
                            walletName: currentConnector === null || currentConnector === void 0 ? void 0 : currentConnector.name,
                        }) }), jsxRuntime.jsxs("div", { className: 'mobile-wallet-redirect__wallet-app', onClick: openWalletApp, children: [jsxRuntime.jsxs("div", { className: 'mobile-wallet-redirect__wallet-app__group', children: [makeIcon(26), jsxRuntime.jsxs(Typography.Typography, { variant: 'body_small', weight: 'bold', copykey: 'dyn_login.mobile_wallet_redirect.get_app_prompt', children: [t('dyn_login.mobile_wallet_redirect.get_app_prompt'), ' ', currentConnector === null || currentConnector === void 0 ? void 0 : currentConnector.name] })] }), jsxRuntime.jsxs("div", { className: 'mobile-wallet-redirect__wallet-app__group', children: [jsxRuntime.jsx(Typography.Typography, { className: 'mobile-wallet-redirect__wallet-app__group__app-store', variant: 'body_small', weight: 'bold', color: 'secondary', children: storeName }), jsxRuntime.jsx(Icon.Icon, { color: 'text-secondary', size: 'small', children: jsxRuntime.jsx(externalLink.ReactComponent, {}) })] })] })] }))] }));
};

exports.MobileWalletRedirectView = MobileWalletRedirectView;
