"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
Object.defineProperty(exports, "AccountStatusBar", {
    enumerable: true,
    get: function() {
        return AccountStatusBar;
    }
});
const _jsxruntime = require("react/jsx-runtime");
const _react = require("react");
const _button = /*#__PURE__*/ _interop_require_default(require("../../button"));
const _sheet = require("../../sheet");
const _accountInfo = require("./sections/accountInfo");
const _text = require("../../text");
const _accountTotal = require("./sections/accountTotal");
const _types = require("@orderly.network/types");
const _logo = require("../../logo");
const _chains = require("./sections/chains");
const _provider = require("../../provider");
function _interop_require_default(obj) {
    return obj && obj.__esModule ? obj : {
        default: obj
    };
}
const AccountStatusBar = (props)=>{
    const { status = _types.AccountStatusEnum.NotConnected } = props;
    const { errors } = (0, _react.useContext)(_provider.OrderlyAppContext);
    const [infoOpen, setInfoOpen] = (0, _react.useState)(false);
    const buttonLabel = (0, _react.useMemo)(()=>{
        switch(status){
            case _types.AccountStatusEnum.NotConnected:
                return "Connect wallet";
            case _types.AccountStatusEnum.Connected:
            case _types.AccountStatusEnum.NotSignedIn:
            case _types.AccountStatusEnum.SignedIn:
            case _types.AccountStatusEnum.DisabledTrading:
            case _types.AccountStatusEnum.EnableTrading:
                return /*#__PURE__*/ (0, _jsxruntime.jsx)(_text.Text, {
                    rule: "address",
                    range: [
                        4,
                        4
                    ],
                    children: props.address
                });
        }
    }, [
        status,
        props.address
    ]);
    return /*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
        id: "orderly-bottom-bar",
        className: "orderly-flex orderly-items-center orderly-justify-between orderly-w-full",
        children: [
            status !== _types.AccountStatusEnum.NotConnected && !errors?.ChainNetworkNotSupport ? /*#__PURE__*/ (0, _jsxruntime.jsx)(_accountTotal.AccountTotal, {
                status: status,
                currency: props.currency,
                totalValue: props.totalValue,
                accountInfo: props.accountInfo
            }) : /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {}),
            /*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
                className: "orderly-flex orderly-gap-2",
                children: [
                    /*#__PURE__*/ (0, _jsxruntime.jsx)(_chains.Chains, {
                        disabled: status < _types.AccountStatusEnum.NotConnected
                    }),
                    status === _types.AccountStatusEnum.NotConnected ? /*#__PURE__*/ (0, _jsxruntime.jsx)(_button.default, {
                        id: "orderly-botom-bar-not-connect-button",
                        size: "small",
                        loading: props.loading,
                        // variant={"gradient"}
                        className: "orderly-bg-primary orderly-text-base-contrast orderly-text-4xs hover:orderly-text-base-80 orderly-h-[30px]",
                        onClick: ()=>props.onConnect?.(),
                        children: buttonLabel
                    }) : /*#__PURE__*/ (0, _jsxruntime.jsxs)(_sheet.Sheet, {
                        open: infoOpen,
                        onOpenChange: setInfoOpen,
                        children: [
                            /*#__PURE__*/ (0, _jsxruntime.jsx)(_sheet.SheetTrigger, {
                                asChild: true,
                                children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_button.default, {
                                    id: "orderly-botom-bar-connect-button",
                                    size: "small",
                                    // variant={"gradient"}
                                    className: "orderly-bg-primary orderly-text-base-contrast orderly-text-4xs hover:orderly-text-base-80 orderly-h-[30px]",
                                    loading: props.loading,
                                    disabled: props.loading || errors?.ChainNetworkNotSupport,
                                    children: buttonLabel
                                })
                            }),
                            /*#__PURE__*/ (0, _jsxruntime.jsxs)(_sheet.SheetContent, {
                                id: "my-account",
                                forceMount: true,
                                children: [
                                    /*#__PURE__*/ (0, _jsxruntime.jsx)(_sheet.SheetHeader, {
                                        id: "my-account-sheet-title",
                                        leading: /*#__PURE__*/ (0, _jsxruntime.jsx)(_logo.Logo.secondary, {
                                            size: 30
                                        }),
                                        children: "My account"
                                    }),
                                    /*#__PURE__*/ (0, _jsxruntime.jsx)(_accountInfo.AccountInfo, {
                                        onDisconnect: props.onDisconnect,
                                        close: ()=>setInfoOpen(false),
                                        showGetTestUSDC: props.showGetTestUSDC
                                    })
                                ]
                            })
                        ]
                    })
                ]
            })
        ]
    });
};

//# sourceMappingURL=accountStatusBar.js.map