import { jsx as _jsx } from "react/jsx-runtime";
import { useContext, useMemo } from "react";
import Button from "../../../button";
import { Text } from "../../../text";
import { AccountStatusEnum } from "@orderly.network/types";
import { OrderlyAppContext } from "../../../provider";
import { cn } from "../../../utils/css";
export const WalletConnectButton = (props)=>{
    const { status = AccountStatusEnum.NotConnected, address } = props;
    const { errors } = useContext(OrderlyAppContext);
    const buttonLabel = useMemo(()=>{
        switch(status){
            case AccountStatusEnum.NotConnected:
                return "Connect wallet";
            case AccountStatusEnum.Connected:
            case AccountStatusEnum.NotSignedIn:
            case AccountStatusEnum.SignedIn:
            case AccountStatusEnum.DisabledTrading:
            case AccountStatusEnum.EnableTrading:
                return /*#__PURE__*/ _jsx(Text, {
                    rule: "address",
                    range: [
                        4,
                        4
                    ],
                    children: props.address
                });
        }
    }, [
        status,
        address
    ]);
    if (status === AccountStatusEnum.NotConnected) {
        return /*#__PURE__*/ _jsx(Button, {
            size: "small",
            loading: props.loading,
            // variant={"gradient"}
            className: cn("orderly-bg-primary orderly-text-base-contrast orderly-text-4xs hover:orderly-text-base-80 orderly-h-[30px]", props.className),
            onClick: ()=>props.onConnect?.(),
            children: buttonLabel
        });
    }
    return /*#__PURE__*/ _jsx(Button, {
        id: "orderly-bottom-nav-bar-connect-button",
        size: "small",
        // variant={"gradient"}
        className: cn("orderly-bg-primary orderly-text-base-contrast orderly-text-4xs hover:orderly-text-base-80 orderly-h-[30px]", props.className),
        loading: props.loading,
        disabled: props.loading || errors?.ChainNetworkNotSupport,
        children: buttonLabel
    });
};

//# sourceMappingURL=walletConnectButton.js.map