import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { memo, useCallback, useContext } from "react";
import { Numeral } from "../../../text";
import { useCollateral, usePositionStream } from "@orderly.network/hooks";
import { AssetsContext } from "../../../provider";
import { modal } from "../../../modal";
import { SettlePnlContent } from "../../../block/withdraw";
import { DesktopFreeCollat } from "../../../block/orderEntry/sections/freeCollat";
const AssetsDetail = ()=>{
    const { freeCollateral } = useCollateral({
        dp: 2
    });
    const [{ aggregated }] = usePositionStream();
    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)=>{});
    }, []);
    return /*#__PURE__*/ _jsx("div", {
        className: "orderly-text-xs orderly-pb-4 orderly-mb-4 orderly-border-b orderly-border-divider orderly-space-y-2 orderly-tabular-nums",
        children: /*#__PURE__*/ _jsxs("div", {
            className: "orderly-flex orderly-justify-between orderly-text-base-contrast-54",
            children: [
                /*#__PURE__*/ _jsx(DesktopFreeCollat, {
                    title: "Free collateral",
                    className: "orderly-text-xs"
                }),
                /*#__PURE__*/ _jsx("div", {
                    className: "orderly-flex orderly-justify-end orderly-gap-1",
                    children: /*#__PURE__*/ _jsx(Numeral, {
                        surfix: /*#__PURE__*/ _jsx("span", {
                            className: "orderly-text-base-contrast-36",
                            children: "USDC"
                        }),
                        children: freeCollateral
                    })
                })
            ]
        })
    });
};
export const MemorizedAssetsDetail = /*#__PURE__*/ memo(AssetsDetail);

//# sourceMappingURL=assetsDetail.js.map