"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
Object.defineProperty(exports, "UnsettledInfo", {
    enumerable: true,
    get: function() {
        return UnsettledInfo;
    }
});
const _jsxruntime = require("react/jsx-runtime");
const _button = /*#__PURE__*/ _interop_require_default(require("../../../button"));
const _modal = require("../../../modal");
const _assetsProvider = require("../../../provider/assetsProvider");
const _text = require("../../../text");
const _lucidereact = require("lucide-react");
const _react = require("react");
const _settlePnlContent = require("../settlePnlContent");
function _interop_require_default(obj) {
    return obj && obj.__esModule ? obj : {
        default: obj
    };
}
const UnsettledInfo = (props)=>{
    const { onSettle } = (0, _react.useContext)(_assetsProvider.AssetsContext);
    const onSettleClick = (0, _react.useCallback)(()=>{
        _modal.modal.confirm({
            title: "Settle PnL",
            content: /*#__PURE__*/ (0, _jsxruntime.jsx)(_settlePnlContent.SettlePnlContent, {}),
            maxWidth: "xs",
            onCancel () {
                return Promise.reject("cancel");
            },
            onOk () {
                return onSettle().catch((e)=>{});
            }
        }).then(()=>{}, (error)=>{});
    }, []);
    if (props.unsettledPnL === 0 && props.hasPositions === false) return null;
    return /*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
        className: "orderly-flex orderly-items-center orderly-justify-between orderly-mt-1",
        children: [
            /*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
                className: "orderly-text-4xs orderly-flex orderly-items-center orderly-space-x-1 orderly-text-base-contrast-36",
                children: [
                    /*#__PURE__*/ (0, _jsxruntime.jsx)("span", {
                        children: `Unsettled:`
                    }),
                    /*#__PURE__*/ (0, _jsxruntime.jsx)(_text.Numeral, {
                        coloring: true,
                        precision: 6,
                        children: props.unsettledPnL
                    }),
                    /*#__PURE__*/ (0, _jsxruntime.jsx)("span", {
                        children: "USDC"
                    })
                ]
            }),
            /*#__PURE__*/ (0, _jsxruntime.jsx)(_button.default, {
                className: "orderly-text-primary-light orderly-text-4xs desktop:orderly-text-3xs",
                size: "small",
                variant: "text",
                // @ts-ignore
                leftIcon: /*#__PURE__*/ (0, _jsxruntime.jsx)(_lucidereact.RotateCw, {
                    size: 15
                }),
                onClick: onSettleClick,
                children: "Settle"
            })
        ]
    });
};

//# sourceMappingURL=settledInfo.js.map