"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
Object.defineProperty(exports, "default", {
    enumerable: true,
    get: function() {
        return _default;
    }
});
const _jsxruntime = require("react/jsx-runtime");
const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
const _table = require("../../../table");
const _text = require("../../../text");
const _hooks = require("@orderly.network/hooks");
const _icon = require("../../../icon");
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;
}
function getData(data) {
    return data.positions_by_perp?.[0] || {};
}
const mockData = [
    {
        liquidation_id: 101,
        timestamp: 1663313562090,
        transfer_amount_to_insurance_fund: 123,
        positions_by_perp: [
            {
                abs_liquidator_fee: 1.152279,
                cost_position_transfer: 65.84448,
                liquidator_fee: 0.0175,
                position_qty: 41.6,
                symbol: "PERP_NEAR_USDC",
                transfer_price: 1.5828
            }
        ]
    }
];
const Liquidations = (props)=>{
    const { data: fundings, isLoading } = (0, _hooks.usePrivateQuery)("/v1/liquidations");
    const columns = (0, _react.useMemo)(()=>{
        return [
            {
                title: "Instrument",
                dataIndex: "",
                render (value, record, index) {
                    const { symbol } = getData(record);
                    return /*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
                        className: " orderly-flex orderly-items-center",
                        children: [
                            /*#__PURE__*/ (0, _jsxruntime.jsx)(_icon.NetworkImage, {
                                type: "symbol",
                                symbol: symbol,
                                size: "small",
                                rounded: true
                            }),
                            /*#__PURE__*/ (0, _jsxruntime.jsx)(_text.Text, {
                                rule: "symbol",
                                className: "orderly-ml-[6px]",
                                children: symbol
                            })
                        ]
                    });
                }
            },
            {
                title: "Time",
                dataIndex: "timestamp",
                render (value, record, index) {
                    return /*#__PURE__*/ (0, _jsxruntime.jsx)(_text.Text, {
                        rule: "date",
                        formatString: "YYYY-MM-DD HH:mm:ss",
                        className: "orderly-text-base-contrast-98 orderly-text-3xs",
                        children: value
                    });
                }
            },
            {
                title: "Qty.",
                dataIndex: "",
                render (value, record, index) {
                    const { position_qty } = getData(record);
                    return /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
                        children: position_qty
                    });
                }
            },
            {
                title: "Price",
                dataIndex: "",
                render (value, record, index) {
                    const { transfer_price } = getData(record);
                    return /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
                        className: "orderly-text-base-contrast-98",
                        children: transfer_price
                    });
                }
            },
            {
                title: "Total value",
                dataIndex: "",
                render (value, record, index) {
                    const { cost_position_transfer, symbol } = getData(record);
                    return /*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
                        className: "orderly-text-base-contrast-98",
                        children: [
                            cost_position_transfer,
                            /*#__PURE__*/ (0, _jsxruntime.jsx)(_text.Text, {
                                rule: "symbol",
                                symbolElement: "quote",
                                className: "orderly-text-base-contrast-36 orderly-ml-[4px]",
                                children: symbol
                            })
                        ]
                    });
                }
            },
            {
                title: "Liquidation fee",
                dataIndex: "",
                render (value, record, index) {
                    const { liquidator_fee, symbol } = getData(record);
                    return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_jsxruntime.Fragment, {
                        children: [
                            liquidator_fee,
                            /*#__PURE__*/ (0, _jsxruntime.jsx)(_text.Text, {
                                rule: "symbol",
                                symbolElement: "quote",
                                className: "orderly-text-base-contrast-36 orderly-ml-[4px]",
                                children: symbol
                            })
                        ]
                    });
                }
            },
            {
                title: "Transferred to insurance",
                dataIndex: "transfer_amount_to_insurance_fund",
                render (value, record, index) {
                    const { symbol } = getData(record);
                    return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_jsxruntime.Fragment, {
                        children: [
                            value,
                            /*#__PURE__*/ (0, _jsxruntime.jsx)(_text.Text, {
                                rule: "symbol",
                                symbolElement: "quote",
                                className: "orderly-text-base-contrast-36 orderly-ml-[4px]",
                                children: symbol
                            })
                        ]
                    });
                }
            },
            {
                title: "Total loss",
                dataIndex: "",
                align: "right",
                render (value, record, index) {
                    const { liquidator_fee, symbol } = getData(record);
                    const totalLoss = record.transfer_amount_to_insurance_fund + liquidator_fee;
                    return /*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
                        className: "orderly-text-danger-light",
                        children: [
                            "-",
                            /*#__PURE__*/ (0, _jsxruntime.jsx)(_text.Numeral, {
                                children: Math.abs(totalLoss)
                            }),
                            /*#__PURE__*/ (0, _jsxruntime.jsx)(_text.Text, {
                                rule: "symbol",
                                symbolElement: "quote",
                                className: "orderly-text-base-contrast-36 orderly-ml-[4px]",
                                children: symbol
                            })
                        ]
                    });
                }
            }
        ];
    }, []);
    return /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
        className: "orderly-h-[500px]",
        children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_table.Table, {
            dataSource: mockData,
            columns: columns,
            loading: isLoading,
            className: "orderly-text-2xs orderly-text-base-contrast-80",
            headerClassName: "orderly-h-[40px] orderly-text-base-contrast-54 orderly-border-b-[1px] orderly-border-b-solid orderly-border-[rgba(255,255,255,0.04)]",
            generatedRowKey: (record)=>record.liquidation_id,
            onRow: (record)=>({
                    className: "orderly-h-[50px]"
                })
        })
    });
};
const _default = Liquidations;

//# sourceMappingURL=liquidations.js.map