import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { Tag } from "../../tag/tag";
import { utils } from "@orderly.network/hooks";
import { AlgoOrderRootType } from "@orderly.network/types";
import { useMemo } from "react";
export const TPSLOrderTag = (props)=>{
    const { order } = props;
    const tpslInfo = useMemo(()=>{
        if (!("algo_type" in order) || !Array.isArray(order.child_orders)) {
            return null;
        }
        const tp_sl = utils.findTPSLFromOrder(order);
        const keys = [];
        if (tp_sl.tp_trigger_price) {
            keys.push("TP");
        }
        if (tp_sl.sl_trigger_price) {
            keys.push("SL");
        }
        if (keys.length === 0) {
            return null;
        }
        if (keys.length === 2) {
            keys.splice(1, 0, "/");
        }
        return /*#__PURE__*/ _jsxs("div", {
            className: "orderly-flex orderly-items-center orderly-gap-1 orderly-mt-1",
            children: [
                order.algo_type === AlgoOrderRootType.POSITIONAL_TP_SL ? /*#__PURE__*/ _jsx(Tag, {
                    className: "orderly-bg-primary/20",
                    children: "Position"
                }) : null,
                /*#__PURE__*/ _jsx(Tag, {
                    className: "orderly-bg-white/10 orderly-text-base-contrast-54",
                    children: keys.map((key)=>/*#__PURE__*/ _jsx("span", {
                            children: key
                        }, key))
                })
            ]
        });
    }, [
        order
    ]);
    return tpslInfo;
};

//# sourceMappingURL=orderTPSLTag.js.map