import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import Button from "../../../button";
import { modal } from "../../../modal";
import { AssetsContext } from "../../../provider/assetsProvider";
import { Numeral } from "../../../text";
import { RotateCw } from "lucide-react";
import { useCallback, useContext } from "react";
import { SettlePnlContent } from "../settlePnlContent";
export const UnsettledInfo = (props)=>{
    const { onSettle } = useContext(AssetsContext);
    const onSettleClick = useCallback(()=>{
        modal.confirm({
            title: "Settle PnL",
            content: /*#__PURE__*/ _jsx(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__*/ _jsxs("div", {
        className: "orderly-flex orderly-items-center orderly-justify-between orderly-mt-1",
        children: [
            /*#__PURE__*/ _jsxs("div", {
                className: "orderly-text-4xs orderly-flex orderly-items-center orderly-space-x-1 orderly-text-base-contrast-36",
                children: [
                    /*#__PURE__*/ _jsx("span", {
                        children: `Unsettled:`
                    }),
                    /*#__PURE__*/ _jsx(Numeral, {
                        coloring: true,
                        precision: 6,
                        children: props.unsettledPnL
                    }),
                    /*#__PURE__*/ _jsx("span", {
                        children: "USDC"
                    })
                ]
            }),
            /*#__PURE__*/ _jsx(Button, {
                id: "orderly-deposit-content-settle-button",
                className: "orderly-text-primary-light orderly-text-4xs desktop:orderly-text-3xs",
                size: "small",
                variant: "text",
                // @ts-ignore
                leftIcon: /*#__PURE__*/ _jsx(RotateCw, {
                    size: 15
                }),
                onClick: onSettleClick,
                children: "Settle"
            })
        ]
    });
};

//# sourceMappingURL=settledInfo.js.map