'use client'
import { __awaiter } from '../../../../_virtual/_tslib.js';
import { jsx, jsxs } from 'react/jsx-runtime';
import { useTranslation } from 'react-i18next';
import '@dynamic-labs/utils';
import '../Accordion/components/AccordionItem/AccordionItem.js';
import 'react';
import { ReactComponent as SvgCheckBlue } from '../../shared/assets/check-blue.js';
import { ReactComponent as SvgClose } from '../../shared/assets/close.js';
import '@dynamic-labs/iconic';
import '../../context/ViewContext/ViewContext.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 '@dynamic-labs/sdk-api-core';
import '../../shared/consts/index.js';
import { Alert } from '../Alert/Alert.js';
import { AnimatePresence } from '../AnimatePresence/AnimatePresence.js';
import { Typography } from '../Typography/Typography.js';
import '../../context/AccessDeniedContext/AccessDeniedContext.js';
import '../../context/DynamicContext/DynamicContext.js';
import '../../store/state/loadingAndLifecycle/loadingAndLifecycle.js';
import '../../events/dynamicEvents.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 { getTotalFiatCost } from '../../utils/functions/fiatUtils/fiatUtils.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/AccountExistsContext/AccountExistsContext.js';
import '../../context/UserWalletsContext/UserWalletsContext.js';
import '../../store/state/authMode/authMode.js';
import '../../context/VerificationContext/VerificationContext.js';
import 'react-dom';
import '../../utils/functions/compareChains/compareChains.js';
import '../../views/Passkey/utils/findPrimaryEmbeddedChain/findPrimaryEmbeddedChain.js';
import '../../context/ThemeContext/ThemeContext.js';
import '../../utils/hooks/useUserUpdateRequest/useUpdateUser/userFieldsSchema.js';
import 'bs58';
import { usePromise } from '../../utils/hooks/usePromise/usePromise.js';
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 '../../views/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 { PoweredByDynamic } from '../PoweredByDynamic/PoweredByDynamic.js';
import '../../context/FooterAnimationContext/index.js';
import '../ShadowDOM/ShadowDOM.js';
import '../Transition/ZoomTransition/ZoomTransition.js';
import '../Transition/SlideInUpTransition/SlideInUpTransition.js';
import '../Transition/OpacityTransition/OpacityTransition.js';
import { VerticalDrawerTransition } from '../Transition/VerticalDrawerTransition/VerticalDrawerTransition.js';
import '../OverlayCardBase/OverlayCardTarget/OverlayCardTarget.js';
import '../../context/WalletGroupContext/WalletGroupContext.js';
import '../../widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetHeader.js';
import 'react-focus-lock';
import { Icon } from '../Icon/Icon.js';
import { shortenWalletAddress } from '../../shared/utils/functions/shortenWalletAddress/shortenWalletAddress.js';
import '../../widgets/DynamicWidget/context/DynamicWidgetContext.js';
import { IconButton } from '../IconButton/IconButton.js';
import { ModalHeader } from '../ModalHeader/ModalHeader.js';
import { TypographyButton } from '../TypographyButton/TypographyButton.js';
import '../MenuList/Dropdown/Dropdown.js';
import 'formik';
import '../../utils/hooks/useSubdomainCheck/useSubdomainCheck.js';
import { useSendBalanceState } from '../../store/state/sendBalances.js';
import '../Input/Input.js';
import '../OverlayCard/OverlayCard.js';
import { getValueRounded } from '../TransactionConfirmationPageLayout/utils.js';
import { getTransactionLink } from '../../utils/functions/getTransactionLink/getTransactionLink.js';
import '../../views/TransactionConfirmationView/TransactionConfirmationView.js';
import '../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 '../../widgets/DynamicWidget/helpers/convertExchangeKeyAndProviderEnum.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 '../../views/ExchangeWhitelistWarning/ExchangeWhitelistWarning.js';
import '../../context/ErrorContext/hooks/useErrorText/useErrorText.js';
import '../../views/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 { useInternalDynamicContext } from '../../context/DynamicContext/useDynamicContext/useInternalDynamicContext/useInternalDynamicContext.js';
import '../InlineWidget/InlineWidget.js';
import '../IsBrowser/IsBrowser.js';
import '../Popper/Popper/Popper.js';
import '../Popper/PopperContext/PopperContext.js';

const TransactionStatusLayout = ({ destinationAddress, transactionValue, networkCurrency, onDone, displayPoweredByDynamicFooter = true, onClickClose, transaction, currentToken, isNativeToken, transactionHash, }) => {
    const { t } = useTranslation();
    const { showFiat, primaryWallet } = useInternalDynamicContext();
    const { nativePrice } = useSendBalanceState();
    const { data: txLink } = usePromise(() => __awaiter(void 0, void 0, void 0, function* () {
        if (!(primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector) || !transactionHash)
            return;
        return getTransactionLink({
            transactionHash,
            walletConnector: primaryWallet.connector,
        });
    }));
    const closeButton = onClickClose && (jsx(IconButton, { type: 'button', onClick: onClickClose, "data-testid": 'close', children: jsx(SvgClose, {}) }));
    const totalFiatCost = getTotalFiatCost(currentToken, transaction, nativePrice, transactionValue);
    return (jsxs("div", { className: 'transaction-status-layout', children: [jsx(ModalHeader, { trailing: closeButton, alignContent: 'bottom', children: jsx(Icon, { size: 'large', className: 'transaction-status-layout__status-icon', children: jsx(SvgCheckBlue, {}) }) }), jsxs("div", { className: 'transaction-status-layout__body', children: [jsxs("div", { className: 'transaction-status-layout__sent_to', children: [jsxs(Typography, { variant: 'body_small', color: 'secondary', className: 'transaction-status-layout__title', copykey: 'dyn_send_transaction.succeeded.title', children: [t('dyn_send_transaction.succeeded.title'), ' '] }), jsx(Typography, { variant: 'body_small', color: 'primary', className: 'transaction-status-layout__title', copykey: 'dyn_send_transaction.succeeded.title', children: shortenWalletAddress(destinationAddress) })] }), jsx("div", { className: 'transaction-status-layout__content', children: jsx("div", { className: 'transaction-status-layout__rows', children: jsxs(Typography, { variant: 'title', color: 'primary', className: 'transaction-status-layout__title', copykey: 'dyn_send_transaction.succeeded.title', children: [`${getValueRounded(isNativeToken, transaction)} ${networkCurrency} `, showFiat &&
                                        (currentToken === null || currentToken === void 0 ? void 0 : currentToken.price) &&
                                        totalFiatCost !== undefined &&
                                        `($${Number(totalFiatCost) <= 0.01 ? '<0.01' : totalFiatCost})`] }) }) }), jsx(AnimatePresence, { animationComponent: jsx(VerticalDrawerTransition, {}), children: jsx("div", { className: 'transaction-confirmation__warning', children: jsx(Alert, { variant: 'info', copykey: 'dyn_send_transaction.info_message.refresh_balance_time', children: t('dyn_send_transaction.info_message.refresh_balance_time') }) }) }), jsx("div", { className: 'transaction-status-layout__transaction-link-container', children: txLink && (jsx(Typography, { as: 'a', href: txLink, target: '_blank', rel: 'noreferrer', className: 'transaction-status-layout__transaction-link-container__transaction-link', variant: 'body_small', children: t('dyn_wallet_funding.success_txn_link') })) }), jsx("div", { className: 'transaction-status-layout__actions', children: jsx(TypographyButton, { buttonVariant: 'brand-primary', buttonPadding: 'small', expanded: true, onClick: onDone, loading: false, copykey: 'dyn_send_transaction.succeeded.continue_button', dataTestId: 'transaction-done-continue', children: t('dyn_send_transaction.succeeded.continue_button') }) }), displayPoweredByDynamicFooter && (jsx(PoweredByDynamic, { classNameRoot: 'transaction-status-layout__footer' }))] })] }));
};

export { TransactionStatusLayout };
