'use client'
import { jsx, jsxs } from 'react/jsx-runtime';
import { useTranslation } from 'react-i18next';
import { SocialIcon } from '@dynamic-labs/iconic';
import { ExchangeKeyEnum } from '@dynamic-labs/sdk-api-core';
import '@dynamic-labs/utils';
import '../../components/Accordion/components/AccordionItem/AccordionItem.js';
import 'react';
import { ReactComponent as SvgClose } from '../../shared/assets/close.js';
import { ReactComponent as SvgCopy } from '../../shared/assets/copy.js';
import { ReactComponent as SvgExternalLink } from '../../shared/assets/externalLink.js';
import '../../context/ViewContext/ViewContext.js';
import { Button } from '../../components/Button/Button.js';
import '../../components/Alert/Alert.js';
import '../../events/dynamicEvents.js';
import '../../../../_virtual/_tslib.js';
import '../../context/DynamicContext/DynamicContext.js';
import '../../store/state/loadingAndLifecycle/loadingAndLifecycle.js';
import '@dynamic-labs/wallet-connector-core';
import '../../shared/logger.js';
import '@dynamic-labs/wallet-book';
import '../../utils/constants/colors.js';
import '../../utils/constants/values.js';
import '../../shared/consts/index.js';
import '../../store/state/authMode/authMode.js';
import { useInternalDynamicContext } from '../../context/DynamicContext/useDynamicContext/useInternalDynamicContext/useInternalDynamicContext.js';
import '../../context/CaptchaContext/CaptchaContext.js';
import '../../context/ErrorContext/ErrorContext.js';
import '@dynamic-labs/multi-wallet';
import 'react-international-phone';
import '../../store/state/nonce/nonce.js';
import { pixelToRem } from '../../utils/functions/pixelToRem/pixelToRem.js';
import '@dynamic-labs-sdk/client/core';
import '../../client/client.js';
import '@dynamic-labs-sdk/client';
import '../../config/ApiEndpoint.js';
import '@dynamic-labs/locale';
import '../../store/state/dynamicContextProps/dynamicContextProps.js';
import '../../store/state/primaryWalletId/primaryWalletId.js';
import '../../store/state/connectedWalletsInfo/connectedWalletsInfo.js';
import '../../context/AccessDeniedContext/AccessDeniedContext.js';
import '../../context/AccountExistsContext/AccountExistsContext.js';
import '../../context/UserWalletsContext/UserWalletsContext.js';
import '../../context/VerificationContext/VerificationContext.js';
import 'react-dom';
import '../../utils/functions/compareChains/compareChains.js';
import '../Passkey/utils/findPrimaryEmbeddedChain/findPrimaryEmbeddedChain.js';
import { useIconThemeVariant } from '../../utils/hooks/useIconThemeVariant/useIconThemeVariant.js';
import '../../utils/hooks/useUserUpdateRequest/useUpdateUser/userFieldsSchema.js';
import 'bs58';
import '@dynamic-labs/types';
import '../../context/SocialRedirectContext/SocialRedirectContext.js';
import '../../context/LoadingContext/LoadingContext.js';
import '../../context/WalletContext/WalletContext.js';
import '../../utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/constants.js';
import 'yup';
import '../../context/MockContext/MockContext.js';
import '../CollectUserDataView/useFields.js';
import '../../context/FieldsStateContext/FieldsStateContext.js';
import '../../context/UserFieldEditorContext/UserFieldEditorContext.js';
import '@dynamic-labs/rpc-providers';
import '../../store/state/walletOptions/walletOptions.js';
import { Typography } from '../../components/Typography/Typography.js';
import '../../context/FooterAnimationContext/index.js';
import '../../components/ShadowDOM/ShadowDOM.js';
import '../../components/Transition/ZoomTransition/ZoomTransition.js';
import '../../components/Transition/SlideInUpTransition/SlideInUpTransition.js';
import '../../components/Transition/OpacityTransition/OpacityTransition.js';
import '../../components/OverlayCardBase/OverlayCardTarget/OverlayCardTarget.js';
import '../../context/WalletGroupContext/WalletGroupContext.js';
import '../../widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetHeader.js';
import 'react-focus-lock';
import { iconRatio } from '../../components/IconWithSpinner/IconWithSpinner.js';
import { shortenWalletAddress } from '../../shared/utils/functions/shortenWalletAddress/shortenWalletAddress.js';
import '../../context/ThemeContext/ThemeContext.js';
import '../../widgets/DynamicWidget/context/DynamicWidgetContext.js';
import { IconButton } from '../../components/IconButton/IconButton.js';
import { ModalHeader } from '../../components/ModalHeader/ModalHeader.js';
import { TypographyButton } from '../../components/TypographyButton/TypographyButton.js';
import '../../components/MenuList/Dropdown/Dropdown.js';
import 'formik';
import '../../utils/hooks/useSubdomainCheck/useSubdomainCheck.js';
import '../../store/state/sendBalances.js';
import { Input } from '../../components/Input/Input.js';
import '../../components/OverlayCard/OverlayCard.js';
import '../TransactionConfirmationView/TransactionConfirmationView.js';
import '../../components/PasskeyCreatedSuccessBanner/PasskeyCreatedSuccessBanner.js';
import '../../context/PasskeyContext/PasskeyContext.js';
import '../../widgets/DynamicWidget/components/PasskeyCard/PasskeyCard.js';
import '../../widgets/DynamicWidget/views/CryptoComOnramp/CryptoComOnramp.js';
import '../../context/OnrampContext/OnrampContext.js';
import '../../../index.js';
import { convertExchangeKeytoProviderEnum } from '../../widgets/DynamicWidget/helpers/convertExchangeKeyAndProviderEnum.js';
import { CopyButton } from '../../components/CopyButton/CopyButton.js';
import 'qrcode';
import '../../widgets/DynamicWidget/views/ReceiveWalletFunds/ReceiveWalletFunds.js';
import '../../context/IpConfigurationContext/IpConfigurationContext.js';
import '../../context/ConnectWithOtpContext/ConnectWithOtpContext.js';
import '../../widgets/DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.js';
import '@hcaptcha/react-hcaptcha';
import '../../context/ErrorContext/hooks/useErrorText/useErrorText.js';
import '../MfaChooseDeviceView/useGetMfaOptions/useGetMfaOptions.js';
import '../../store/state/connectorsInitializing/connectorsInitializing.js';
import '../../store/state/tokenBalances.js';
import '../../store/state/multichainBalances.js';
import '../../shared/utils/functions/getInitialUrl/getInitialUrl.js';
import '../../components/InlineWidget/InlineWidget.js';
import '../../components/IsBrowser/IsBrowser.js';
import '../../components/Popper/Popper/Popper.js';
import '../../components/Popper/PopperContext/PopperContext.js';

const docsLink = (exchange) => {
    if (exchange === ExchangeKeyEnum.Kraken) {
        return 'https://support.kraken.com/articles/360000672863-adding-and-confirming-a-new-cryptocurrency-withdrawal-address';
    }
    return undefined;
};
const exchangeAppUrlMap = {
    [ExchangeKeyEnum.Kraken]: 'https://www.kraken.com/',
    [ExchangeKeyEnum.Coinbase]: 'https://www.coinbase.com/',
};
const openExchangeApp = (exchange) => {
    const url = exchangeAppUrlMap[exchange];
    if (url)
        window.open(url, '_blank', 'noopener,noreferrer');
};
const iconSize = 96;
const ExchangeWhitelistWarning = ({ onContinue, exchange, onClose, }) => {
    var _a;
    const { t } = useTranslation();
    const iconThemeVariant = useIconThemeVariant();
    const { primaryWallet } = useInternalDynamicContext();
    const closeButton = (jsx(IconButton, { onClick: onClose, type: 'button', id: 'close-button', "data-testid": 'close-button', children: jsx(SvgClose, {}) }));
    const link = docsLink(exchange);
    const exchangeDisplayName = exchange.charAt(0).toUpperCase() + exchange.slice(1);
    return (jsxs("div", { className: 'exchange-whitelist-warning', children: [jsx(ModalHeader, { trailing: closeButton, children: jsx(Typography, { variant: 'title', copykey: 'dyn_exchange_whitelist_warning.title', children: t('dyn_exchange_whitelist_warning.title') }) }), jsxs("div", { className: 'exchange-whitelist-warning__content', children: [jsx("div", { className: 'exchange-whitelist-warning__content__icon-holder', children: jsx(SocialIcon, { name: convertExchangeKeytoProviderEnum(exchange), variant: iconThemeVariant, style: {
                                height: pixelToRem(iconSize * iconRatio),
                                width: pixelToRem(iconSize * iconRatio),
                            } }) }), jsx(Typography, { variant: 'body_normal', color: 'primary', className: 'exchange-whitelist-warning__content__description', copykey: 'dyn_exchange_whitelist_warning.description', children: t('dyn_exchange_whitelist_warning.description', {
                            exchange: exchangeDisplayName,
                        }) }), jsxs("div", { className: 'exchange-whitelist-warning__content__steps', children: [jsxs("div", { className: 'exchange-whitelist-warning__content__steps__step', children: [jsx("div", { className: 'exchange-whitelist-warning__content__steps__step__number-badge', children: "1" }), jsx(Typography, { variant: 'body_small', color: 'primary', copykey: 'dyn_exchange_whitelist_warning.step1', children: t(`dyn_exchange_whitelist_warning.step1.${exchange}`) })] }), jsxs("div", { className: 'exchange-whitelist-warning__content__steps__step', children: [jsx("div", { className: 'exchange-whitelist-warning__content__steps__step__number-badge', children: "2" }), jsx(Typography, { variant: 'body_small', color: 'primary', copykey: 'dyn_exchange_whitelist_warning.step2', children: t('dyn_exchange_whitelist_warning.step2') })] }), jsxs("div", { className: 'exchange-whitelist-warning__content__steps__step', children: [jsx("div", { className: 'exchange-whitelist-warning__content__steps__step__number-badge', children: "3" }), jsx(Typography, { variant: 'body_small', color: 'primary', copykey: 'dyn_exchange_whitelist_warning.step3', children: t('dyn_exchange_whitelist_warning.step3', {
                                            exchange: exchangeDisplayName,
                                        }) })] })] }), jsxs("div", { className: 'exchange-whitelist-warning__content__address', children: [jsx(Typography, { variant: 'body_normal', color: 'primary', copykey: 'dyn_exchange_whitelist_warning.address', children: t('dyn_exchange_whitelist_warning.address') }), jsxs("div", { className: 'exchange-whitelist-warning__content__address__copy', children: [jsx("div", { className: 'exchange-whitelist-warning__content__address__copy__copy-input', children: jsx(Input, { id: 'wallet_address', "data-testid": 'wallet_address', label: shortenWalletAddress(primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.address), disabled: true }) }), jsx(CopyButton, { textToCopy: (_a = primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.address) !== null && _a !== void 0 ? _a : '', children: jsx(SvgCopy, {}) })] })] }), link && (jsxs("div", { className: 'exchange-whitelist-warning__content__instructions', children: [jsx(Typography, { as: 'a', weight: 'bold', href: link, target: '_blank', rel: 'noreferrer', className: 'exchange-whitelist-warning__content__instructions__link', variant: 'body_small', children: t('dyn_exchange_whitelist_warning.view_instructions') }), jsx(SvgExternalLink, { style: {
                                    height: pixelToRem(12),
                                    marginLeft: pixelToRem(8),
                                    width: pixelToRem(12),
                                }, className: 'exchange-whitelist-warning__content__steps__step__icon' })] })), jsx("div", { className: 'exchange-whitelist-warning__content__open', children: jsxs(Button, { onClick: () => openExchangeApp(exchange), buttonVariant: 'primary', className: 'exchange-whitelist-warning__content__open__button', children: [jsx(Typography, { variant: 'body_normal', children: t('dyn_exchange_whitelist_warning.open', {
                                        exchange: exchangeDisplayName,
                                    }) }), jsx(SvgExternalLink, { style: {
                                        height: pixelToRem(14),
                                        marginLeft: pixelToRem(8),
                                        width: pixelToRem(14),
                                    } })] }) }), jsx("div", { className: 'exchange-whitelist-warning__content__done', children: jsx(TypographyButton, { dataTestId: 'continue-button', buttonVariant: 'brand-primary', typographyProps: { color: 'white', weight: 'regular' }, className: 'exchange-whitelist-warning__content__done__button', onClick: () => {
                                onContinue();
                            }, copykey: 'dyn_exchange_whitelist_warning.done', children: t('dyn_exchange_whitelist_warning.done') }) })] })] }));
};

export { ExchangeWhitelistWarning };
