import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
import { useCallback, useContext } from "react";
import { StatusContext, useAccount } from "@orderly.network/hooks";
import { AccountStatus } from "../../block/accountStatus/desktop/accountStatus.desktop";
import { AccountStatusEnum } from "@orderly.network/types";
import { OrderlyAppContext } from "../../provider/appProvider";
import { showAccountConnectorModal } from "../../block/walletConnect/walletModal";
import { Logo } from "../../logo";
import TopTips from "../../block/accountStatus/sections/topTips";
export const TopNavbar = (props)=>{
    const { state } = useAccount();
    const { errors, accountMenuItems, onClickAccountMenuItem, topBar, topBarProps } = useContext(OrderlyAppContext);
    const { left, nav, right } = topBarProps || {};
    const { ws: wsStatus } = useContext(StatusContext);
    const { onWalletConnect, onSetChain, onWalletDisconnect } = useContext(OrderlyAppContext);
    const onConnect = useCallback(()=>{
        onWalletConnect().then((result)=>{
            if (result && result.status < AccountStatusEnum.EnableTrading) {
                showAccountConnectorModal({
                    status: result.status
                }).catch((err)=>{
                    ;
                });
            }
        });
    }, []);
    return /*#__PURE__*/ _jsxs(_Fragment, {
        children: [
            topBar || /*#__PURE__*/ _jsxs("div", {
                className: "orderly-h-[48px] orderly-flex",
                children: [
                    /*#__PURE__*/ _jsxs("div", {
                        className: "orderly-flex orderly-flex-1",
                        children: [
                            /*#__PURE__*/ _jsx(Logo, {}),
                            left,
                            /*#__PURE__*/ _jsx("div", {
                                className: "orderly-flex-1",
                                children: nav
                            })
                        ]
                    }),
                    right || /*#__PURE__*/ _jsx(AccountStatus, {
                        status: state.status,
                        address: state.address,
                        accountInfo: undefined,
                        className: "orderly-mr-3",
                        onConnect: onConnect,
                        dropMenuItem: accountMenuItems,
                        onClickDropMenuItem: onClickAccountMenuItem
                    })
                ]
            }),
            /*#__PURE__*/ _jsx(TopTips, {})
        ]
    });
};

//# sourceMappingURL=topNavbar.js.map