"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
Object.defineProperty(exports, "AccountStatus", {
    enumerable: true,
    get: function() {
        return AccountStatus;
    }
});
const _jsxruntime = require("react/jsx-runtime");
const _react = require("react");
const _types = require("@orderly.network/types");
const _chainsdesktop = require("../sections/desktop/chains.desktop");
const _css = require("../../../utils/css");
const _hooks = require("@orderly.network/hooks");
const _provider = require("../../../provider");
const _walletConnectButtondesktop = require("./walletConnectButton.desktop");
const _utils = require("@orderly.network/utils");
const AccountStatus = (props)=>{
    const { status = _types.AccountStatusEnum.NotConnected } = props;
    const { account, state } = (0, _hooks.useAccount)();
    const [open, setOpen] = (0, _react.useState)(false);
    const { onWalletDisconnect } = (0, _react.useContext)(_provider.OrderlyAppContext);
    const { connectedChain } = (0, _hooks.useWalletConnector)();
    const [allChains, { findByChainId }] = (0, _hooks.useChains)(undefined, {
        pick: "network_infos",
        filter: (chain)=>chain.network_infos?.bridge_enable || chain.network_infos?.bridgeless
    });
    const chains = (0, _react.useMemo)(()=>{
        if (Array.isArray(allChains)) return allChains;
        if (allChains === undefined) return [];
        // @ts-ignore
        if (connectedChain && (0, _utils.isTestnet)(parseInt(connectedChain.id))) {
            return allChains.testnet ?? [];
        }
        return allChains.mainnet;
    }, [
        allChains,
        connectedChain
    ]);
    return /*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
        className: (0, _css.cn)("orderly-h-full orderly-flex orderly-items-center orderly-space-x-2", props.className),
        children: [
            /*#__PURE__*/ (0, _jsxruntime.jsx)(_chainsdesktop.Chains, {
                disabled: status < _types.AccountStatusEnum.NotConnected,
                className: "orderly-rounded-full"
            }),
            /*#__PURE__*/ (0, _jsxruntime.jsx)(_walletConnectButtondesktop.DesktopWalletConnnectButton, {
                status: status,
                // @ts-ignore
                chains: chains,
                address: props.address,
                balance: props.balance,
                currency: props.currency,
                totalValue: props.totalValue,
                accountInfo: account,
                loading: props.loading,
                onConnect: props.onConnect,
                onDisconnect: props.onDisconnect,
                showGetTestUSDC: props.showGetTestUSDC,
                className: props.className,
                dropMenuItem: props.dropMenuItem,
                onClickDropMenuItem: props.onClickDropMenuItem
            })
        ]
    });
};

//# sourceMappingURL=accountStatus.desktop.js.map