"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
Object.defineProperty(exports, "TradeHistory", {
    enumerable: true,
    get: function() {
        return TradeHistory;
    }
});
const _jsxruntime = require("react/jsx-runtime");
const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
const _table = require("../../table");
const _text = require("../../text");
const _types = require("@orderly.network/types");
const _provider = require("../../provider");
const _css = require("../../utils/css");
function _getRequireWildcardCache(nodeInterop) {
    if (typeof WeakMap !== "function") return null;
    var cacheBabelInterop = new WeakMap();
    var cacheNodeInterop = new WeakMap();
    return (_getRequireWildcardCache = function(nodeInterop) {
        return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
    })(nodeInterop);
}
function _interop_require_wildcard(obj, nodeInterop) {
    if (!nodeInterop && obj && obj.__esModule) {
        return obj;
    }
    if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
        return {
            default: obj
        };
    }
    var cache = _getRequireWildcardCache(nodeInterop);
    if (cache && cache.has(obj)) {
        return cache.get(obj);
    }
    var newObj = {
        __proto__: null
    };
    var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
    for(var key in obj){
        if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
            var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
            if (desc && (desc.get || desc.set)) {
                Object.defineProperty(newObj, key, desc);
            } else {
                newObj[key] = obj[key];
            }
        }
    }
    newObj.default = obj;
    if (cache) {
        cache.set(obj, newObj);
    }
    return newObj;
}
const TradeHistory = (props)=>{
    const { quote, quote_dp, base, base_dp } = (0, _react.useContext)(_provider.SymbolContext);
    const columns = (0, _react.useMemo)(()=>{
        return [
            {
                title: "Time",
                dataIndex: "ts",
                render (value, record, index) {
                    return /*#__PURE__*/ (0, _jsxruntime.jsx)(_text.Text, {
                        rule: "date",
                        formatString: "HH:mm:ss",
                        className: "orderly-text-base-contrast-80 orderly-text-3xs",
                        children: value
                    });
                }
            },
            {
                title: `Price(${quote})`,
                dataIndex: "price",
                render (value, record, index) {
                    return /*#__PURE__*/ (0, _jsxruntime.jsx)(_text.Numeral, {
                        precision: quote_dp,
                        className: record.side === _types.OrderSide.BUY ? "orderly-text-trade-profit orderly-text-3xs" : "orderly-text-trade-loss orderly-text-3xs",
                        children: value
                    });
                }
            },
            {
                title: `Qty(${base})`,
                dataIndex: "size",
                align: "right",
                render (value, record, index) {
                    return /*#__PURE__*/ (0, _jsxruntime.jsx)(_text.Numeral, {
                        precision: base_dp,
                        className: record.side === _types.OrderSide.BUY ? "orderly-text-trade-profit orderly-text-3xs" : "orderly-text-trade-loss orderly-text-3xs",
                        children: value
                    });
                }
            }
        ];
    }, [
        base,
        quote
    ]);
    return /*#__PURE__*/ (0, _jsxruntime.jsx)(_table.Table, {
        dataSource: props.dataSource,
        columns: columns,
        loading: props.loading,
        className: "orderly-text-3xs desktop:orderly-text-2xs",
        headerClassName: (0, _css.cn)("orderly-text-base-contrast-36 orderly-bg-base-900 orderly-p-0", props.headerClassName),
        generatedRowKey: (record, index)=>// @ts-ignore
            `record.ts_${record.price}_${record.size}_${index}`
    });
};

//# sourceMappingURL=tradeHistory.js.map