"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
Object.defineProperty(exports, "TPSLOrderEditButton", {
    enumerable: true,
    get: function() {
        return TPSLOrderEditButton;
    }
});
const _jsxruntime = require("react/jsx-runtime");
const _react = require("react");
const _popover = require("../../popover");
const _utils = require("../../utils");
const _types = require("@orderly.network/types");
const _tp_sl_editor = require("../../block/tp_sl/tp_sl_editor");
const _button = require("../../button/button");
const TPSLOrderEditButton = (props)=>{
    const { order, maxQty, position, disabled } = props;
    const [open, setOpen] = (0, _react.useState)(false);
    // const { base, quote, symbol } = useSymbolContext();
    // const onConfirm = () => {
    //   return onSubmit().then(
    //     (res) => {
    //       setOpen(false);
    //     },
    //     (error: Error) => {
    //       toast.error(error.message);
    //     }
    //   );
    // };
    const onClose = ()=>{
        setOpen(false);
    };
    return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_popover.Popover, {
        onOpenChange: setOpen,
        open: open,
        children: [
            /*#__PURE__*/ (0, _jsxruntime.jsx)(_popover.PopoverTrigger, {
                asChild: true,
                children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_button.Button, {
                    size: "small",
                    variant: "outlined",
                    color: "tertiary",
                    className: (0, _utils.cn)("orderly-flex-1", {
                        "orderly-text-base-contrast-80 orderly-border-base-contrast-80": open
                    }),
                    children: props.label
                })
            }),
            /*#__PURE__*/ (0, _jsxruntime.jsx)(_popover.PopoverContent, {
                align: "end",
                side: "top",
                className: "orderly-w-[375px] orderly-ui-tp_sl-poper",
                onOpenAutoFocus: (e)=>{
                    e.preventDefault();
                },
                children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_tp_sl_editor.TPSLEditor, {
                    maxQty: Number(maxQty),
                    symbol: order.symbol,
                    onCancel: onClose,
                    onSuccess: onClose,
                    order: order,
                    position: position,
                    canModifyQty: order.algo_type !== _types.AlgoOrderRootType.POSITIONAL_TP_SL,
                    isEditing: props.isEditing
                })
            })
        ]
    });
};

//# sourceMappingURL=tpslOrderEditButton.js.map