"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
Object.defineProperty(exports, "TPSLOrderTag", {
    enumerable: true,
    get: function() {
        return TPSLOrderTag;
    }
});
const _jsxruntime = require("react/jsx-runtime");
const _tag = require("../../tag/tag");
const _hooks = require("@orderly.network/hooks");
const _types = require("@orderly.network/types");
const _react = require("react");
const TPSLOrderTag = (props)=>{
    const { order } = props;
    const tpslInfo = (0, _react.useMemo)(()=>{
        if (!("algo_type" in order) || !Array.isArray(order.child_orders)) {
            return null;
        }
        const tp_sl = _hooks.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__*/ (0, _jsxruntime.jsxs)("div", {
            className: "orderly-flex orderly-items-center orderly-gap-1 orderly-mt-1",
            children: [
                order.algo_type === _types.AlgoOrderRootType.POSITIONAL_TP_SL ? /*#__PURE__*/ (0, _jsxruntime.jsx)(_tag.Tag, {
                    className: "orderly-bg-primary/20",
                    children: "Position"
                }) : null,
                /*#__PURE__*/ (0, _jsxruntime.jsx)(_tag.Tag, {
                    className: "orderly-bg-white/10 orderly-text-base-contrast-54",
                    children: keys.map((key)=>/*#__PURE__*/ (0, _jsxruntime.jsx)("span", {
                            children: key
                        }, key))
                })
            ]
        });
    }, [
        order
    ]);
    return tpslInfo;
};

//# sourceMappingURL=orderTPSLTag.js.map