"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
Object.defineProperty(exports, "OrderTypeTag", {
    enumerable: true,
    get: function() {
        return OrderTypeTag;
    }
});
const _jsxruntime = require("react/jsx-runtime");
const _tag = require("../../tag/tag");
const _types = require("@orderly.network/types");
const _react = require("react");
const OrderTypeTag = (props)=>{
    const positionType = (0, _react.useMemo)(()=>{
        if (!("parent_algo_type" in props.order)) {
            return null;
        }
        if (props.order.parent_algo_type === _types.AlgoOrderRootType.POSITIONAL_TP_SL) {
            return /*#__PURE__*/ (0, _jsxruntime.jsx)(_tag.Tag, {
                className: "orderly-bg-primary/20",
                children: "Position"
            });
        }
    }, [
        props.order
    ]);
    const orderType = (0, _react.useMemo)(()=>{
        // if (!("algo_type" in props.order)) {
        //   return null;
        // }
        let type;
        if ("algo_type" in props.order) {
            if (props.order.algo_type === _types.AlgoOrderType.TAKE_PROFIT) {
                // need check if it is STOP LIMIT or STOP MARKET
                if (props.order.type === _types.OrderType.MARKET) {
                    type = "Stop market";
                } else if (props.order.type === _types.OrderType.LIMIT) {
                    type = "Stop limit";
                } else {
                    type = "TP";
                }
            }
            if (props.order.algo_type === _types.AlgoOrderType.STOP_LOSS) {
                type = "SL";
            }
        } else {
            if (props.order.type === _types.OrderType.MARKET) {
                type = "Market";
            } else if (props.order.type === _types.OrderType.LIMIT) {
                type = "Limit";
            }
        }
        if (!type) {
            return null;
        }
        return /*#__PURE__*/ (0, _jsxruntime.jsx)(_tag.Tag, {
            className: "orderly-bg-white/10 orderly-text-base-contrast-54",
            children: type
        });
    }, [
        props.order
    ]);
    return /*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
        className: "orderly-flex orderly-mt-1 orderly-space-x-1",
        children: [
            positionType,
            orderType
        ]
    });
};

//# sourceMappingURL=typeTag.js.map