'use client'
'use strict';

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

var jsxRuntime = require('react/jsx-runtime');
var walletBook = require('@dynamic-labs/wallet-book');
var utils = require('@dynamic-labs/utils');
require('../../../../components/Accordion/components/AccordionItem/AccordionItem.cjs');
require('react-i18next');
require('react');
var externalLink = require('../../../../shared/assets/externalLink.cjs');
var link = require('../../../../shared/assets/link.cjs');
require('@dynamic-labs/iconic');
require('../../../../context/ViewContext/ViewContext.cjs');
require('../../../../../../_virtual/_tslib.cjs');
require('@dynamic-labs/wallet-connector-core');
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('../../../../components/Alert/Alert.cjs');
require('../../../../events/dynamicEvents.cjs');
require('../../../../context/DynamicContext/DynamicContext.cjs');
require('../../../../store/state/loadingAndLifecycle/loadingAndLifecycle.cjs');
require('../../../../store/state/authMode/authMode.cjs');
var useInternalDynamicContext = require('../../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext/useInternalDynamicContext.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('../../../../context/VerificationContext/VerificationContext.cjs');
require('react-dom');
require('../../../../utils/functions/compareChains/compareChains.cjs');
require('../../../../views/Passkey/utils/findPrimaryEmbeddedChain/findPrimaryEmbeddedChain.cjs');
var ThemeContext = 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('../../../../views/CollectUserDataView/useFields.cjs');
require('../../../../context/FieldsStateContext/FieldsStateContext.cjs');
require('../../../../context/UserFieldEditorContext/UserFieldEditorContext.cjs');
require('@dynamic-labs/rpc-providers');
require('../../../../store/state/walletOptions/walletOptions.cjs');
var Typography = require('../../../../components/Typography/Typography.cjs');
require('../../../../context/FooterAnimationContext/index.cjs');
require('../../../../components/ShadowDOM/ShadowDOM.cjs');
require('../../../../components/Transition/ZoomTransition/ZoomTransition.cjs');
require('../../../../components/Transition/SlideInUpTransition/SlideInUpTransition.cjs');
require('../../../../components/Transition/OpacityTransition/OpacityTransition.cjs');
require('../../../../components/OverlayCardBase/OverlayCardTarget/OverlayCardTarget.cjs');
require('../../../../context/WalletGroupContext/WalletGroupContext.cjs');
require('../../components/DynamicWidgetHeader/DynamicWidgetHeader.cjs');
require('react-focus-lock');
var Icon = require('../../../../components/Icon/Icon.cjs');
var shortenWalletAddress = require('../../../../shared/utils/functions/shortenWalletAddress/shortenWalletAddress.cjs');
require('../../context/DynamicWidgetContext.cjs');
require('../../../../components/IconButton/IconButton.cjs');
require('../../../../components/MenuList/Dropdown/Dropdown.cjs');
require('formik');
require('../../../../utils/hooks/useSubdomainCheck/useSubdomainCheck.cjs');
require('../../../../store/state/sendBalances.cjs');
require('../../../../components/Input/Input.cjs');
require('../../../../components/OverlayCard/OverlayCard.cjs');
require('../../../../views/TransactionConfirmationView/TransactionConfirmationView.cjs');
require('../../../../components/PasskeyCreatedSuccessBanner/PasskeyCreatedSuccessBanner.cjs');
require('../../../../context/PasskeyContext/PasskeyContext.cjs');
require('../../components/PasskeyCard/PasskeyCard.cjs');
require('../../views/CryptoComOnramp/CryptoComOnramp.cjs');
require('../../../../context/OnrampContext/OnrampContext.cjs');
require('../../../../../index.cjs');
require('../../helpers/convertExchangeKeyAndProviderEnum.cjs');
var CopyButton = require('../../../../components/CopyButton/CopyButton.cjs');
var QRCode = require('../../../../components/QRCode/QRCode.cjs');
require('../../views/ReceiveWalletFunds/ReceiveWalletFunds.cjs');
var TextButton = require('../../../../components/TextButton/TextButton.cjs');
require('../../../../context/IpConfigurationContext/IpConfigurationContext.cjs');
require('../../../../context/ConnectWithOtpContext/ConnectWithOtpContext.cjs');
require('../../../DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.cjs');
require('@hcaptcha/react-hcaptcha');
require('../../../../views/ExchangeWhitelistWarning/ExchangeWhitelistWarning.cjs');
require('../../../../context/ErrorContext/hooks/useErrorText/useErrorText.cjs');
require('../../../../views/MfaChooseDeviceView/useGetMfaOptions/useGetMfaOptions.cjs');
require('../../../../store/state/connectorsInitializing/connectorsInitializing.cjs');
require('../../../../store/state/tokenBalances.cjs');
require('../../../../store/state/multichainBalances.cjs');
require('../../../../shared/utils/functions/getInitialUrl/getInitialUrl.cjs');
require('../../../../components/InlineWidget/InlineWidget.cjs');
require('../../../../components/IsBrowser/IsBrowser.cjs');
require('../../../../components/Popper/Popper/Popper.cjs');
require('../../../../components/Popper/PopperContext/PopperContext.cjs');

const QrCodeModalView = ({ walletId }) => {
    var _a, _b, _c;
    const { secondaryWallets, qrcodeUri, desktopUri } = useInternalDynamicContext.useInternalDynamicContext();
    const newPrimaryWallet = secondaryWallets.find(({ id }) => id === walletId);
    const walletKey = ((_a = newPrimaryWallet === null || newPrimaryWallet === void 0 ? void 0 : newPrimaryWallet.connector) === null || _a === void 0 ? void 0 : _a.key) || '';
    const walletName = ((_b = newPrimaryWallet === null || newPrimaryWallet === void 0 ? void 0 : newPrimaryWallet.connector) === null || _b === void 0 ? void 0 : _b.name) || '';
    const walletMetadata = (_c = newPrimaryWallet === null || newPrimaryWallet === void 0 ? void 0 : newPrimaryWallet.connector) === null || _c === void 0 ? void 0 : _c.metadata;
    const { theme } = ThemeContext.useThemeContext();
    const qrCodeColorsByTheme = {
        dark: {
            accentColor: 'var(--dynamic-text-primary)',
        },
        light: {
            accentColor: (walletMetadata === null || walletMetadata === void 0 ? void 0 : walletMetadata.brandColor) || 'var(--dynamic-text-primary)',
        },
    };
    // can't use theme because it's string instead of 'light' | 'dark'
    const typedTheme = theme.theme.name === 'light' ? 'light' : 'dark';
    const icon = (jsxRuntime.jsx(walletBook.WalletIcon, { icon: walletMetadata === null || walletMetadata === void 0 ? void 0 : walletMetadata.icon, walletKey: walletKey, style: { height: pixelToRem.pixelToRem(24), width: pixelToRem.pixelToRem(24) } }));
    return (jsxRuntime.jsxs("div", { className: 'qr-code-modal-view', children: [jsxRuntime.jsxs(Typography.Typography, { variant: 'button_primary', color: 'primary', className: 'qr-code-modal-view__title', children: ["Connect with ", walletName] }), jsxRuntime.jsxs(Typography.Typography, { variant: 'body_small', color: 'secondary', className: 'qr-code-modal-view__title', children: ["Connect wallet", ' ', jsxRuntime.jsx(Typography.Typography, { as: 'span', weight: 'medium', color: 'primary', children: shortenWalletAddress.shortenWalletAddress(newPrimaryWallet === null || newPrimaryWallet === void 0 ? void 0 : newPrimaryWallet.address) }), ' ', "to switch active account."] }), jsxRuntime.jsx("div", { className: 'qr-code-modal-view__container', children: jsxRuntime.jsx("div", { className: 'qr-code-modal-view__wrapper', children: qrcodeUri ? (jsxRuntime.jsx(QRCode.QRCode, { Icon: icon, accentColor: qrCodeColorsByTheme[typedTheme].accentColor, value: qrcodeUri, size: 175, logoSize: 40, walletKey: walletKey })) : (
                    // this div exists to give the parent a child, so that the parent
                    // takes on its given width and height. the result is stable
                    // rendering of this component, without this there is a brief flash
                    jsxRuntime.jsx("div", { "data-testid": 'no-qrcode' })) }) }), jsxRuntime.jsxs("div", { className: 'button__container', children: [(newPrimaryWallet === null || newPrimaryWallet === void 0 ? void 0 : newPrimaryWallet.connector.isWalletConnect) && qrcodeUri && (jsxRuntime.jsxs(CopyButton.CopyButton, { textToCopy: qrcodeUri, children: [jsxRuntime.jsx(Icon.Icon, { size: 'small', color: 'text-tertiary', children: jsxRuntime.jsx(link.ReactComponent, {}) }), "Copy QR URI"] })), desktopUri && (jsxRuntime.jsxs(TextButton.TextButton, { className: 'button--open-app', onClick: () => utils.PlatformService.openURL(desktopUri, 'blank'), children: [jsxRuntime.jsx(Icon.Icon, { size: 'xsmall', color: 'text-tertiary', children: jsxRuntime.jsx(externalLink.ReactComponent, {}) }), "Open ", walletName, " App"] }))] })] }));
};

exports.QrCodeModalView = QrCodeModalView;
