"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
Object.defineProperty(exports, "OrderEditFormSheet", {
    enumerable: true,
    get: function() {
        return OrderEditFormSheet;
    }
});
const _jsxruntime = require("react/jsx-runtime");
const _modal = require("../../../../modal");
const _editorForm = require("./editorForm");
const _types = require("@orderly.network/types");
const _tpslSheet = require("../../../../block/tp_sl/tpslSheet");
const OrderEditFormSheet = (props)=>{
    const { hide, resolve, reject } = (0, _modal.useModal)();
    // const { order, position } = useTPSLOrderRowContext();
    if (!props.order) {
        return null;
    }
    const onEditSubmit = (values)=>{
        return props.editOrder(values).then((res)=>{
            if (res.success) {
                // toast.success("Order placed successfully");
                resolve(res);
                hide();
            // props.onComplete?.(res.data);
            }
        });
    };
    if ("algo_type" in props.order && (props.order.algo_type === _types.AlgoOrderRootType.POSITIONAL_TP_SL || props.order.algo_type === _types.AlgoOrderRootType.TP_SL)) {
        if (!props.position) {
            return null;
        }
        return /*#__PURE__*/ (0, _jsxruntime.jsx)(_tpslSheet.TPSLOrderEditorSheet, {
            order: props.order,
            position: props.position,
            isEditing: true,
            canModifyQty: props.order.algo_type !== _types.AlgoOrderRootType.POSITIONAL_TP_SL
        });
    }
    return /*#__PURE__*/ (0, _jsxruntime.jsx)(_editorForm.OrderEditForm, {
        order: props.order,
        onSubmit: onEditSubmit,
        onCancel: function() {
            reject();
            hide();
        }
    });
};

//# sourceMappingURL=editorSheet.js.map