import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
import { ArrowRightIcon } from "../../../icon/icons";
import { Numeral } from "../../../text/numeral";
import { useAccount, useMarginRatio } from "@orderly.network/hooks";
import { AccountStatusEnum } from "@orderly.network/types";
import { useMemo } from "react";
export const EstInfo = ({ estLeverage, estLiqPrice, precision })=>{
    const { currentLeverage } = useMarginRatio();
    const { state } = useAccount();
    const leverageElement = useMemo(()=>{
        if (state.status < AccountStatusEnum.EnableTrading) {
            return "0.00x";
        }
        if (typeof estLeverage === "undefined" || estLeverage === null) {
            return /*#__PURE__*/ _jsx(Numeral, {
                className: "orderly-text-base-contrast",
                surfix: "x",
                children: currentLeverage
            });
        }
        return /*#__PURE__*/ _jsxs(_Fragment, {
            children: [
                /*#__PURE__*/ _jsx(Numeral, {
                    className: "orderly-text-base-contrast",
                    surfix: "x",
                    children: currentLeverage
                }),
                /*#__PURE__*/ _jsx(ArrowRightIcon, {
                    size: 8
                }),
                /*#__PURE__*/ _jsx(Numeral, {
                    className: "orderly-text-base-contrast",
                    surfix: "x",
                    children: Math.abs(estLeverage)
                })
            ]
        });
    }, [
        currentLeverage,
        estLeverage,
        state.status
    ]);
    return /*#__PURE__*/ _jsxs(_Fragment, {
        children: [
            /*#__PURE__*/ _jsxs("div", {
                className: "orderly-flex orderly-justify-between orderly-text-base-contrast-54",
                children: [
                    /*#__PURE__*/ _jsx("span", {
                        children: "Est. Liq. price"
                    }),
                    /*#__PURE__*/ _jsxs("span", {
                        className: "orderly-flex orderly-gap-1",
                        children: [
                            /*#__PURE__*/ _jsx("span", {
                                className: "orderly-text-base-contrast",
                                children: /*#__PURE__*/ _jsx(Numeral, {
                                    precision: precision,
                                    children: estLiqPrice ?? "--"
                                })
                            }),
                            /*#__PURE__*/ _jsx("span", {
                                children: "USDC"
                            })
                        ]
                    })
                ]
            }),
            /*#__PURE__*/ _jsxs("div", {
                className: "orderly-flex orderly-justify-between orderly-text-base-contrast-54",
                children: [
                    /*#__PURE__*/ _jsx("span", {
                        children: "Account leverage"
                    }),
                    /*#__PURE__*/ _jsx("span", {
                        className: "orderly-flex orderly-items-center orderly-gap-1",
                        children: leverageElement
                    })
                ]
            })
        ]
    });
};

//# sourceMappingURL=setInfo.js.map