"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
Object.defineProperty(exports, "LeverageEditor", {
    enumerable: true,
    get: function() {
        return LeverageEditor;
    }
});
const _jsxruntime = require("react/jsx-runtime");
const _slider = require("../../../slider");
const _react = require("react");
const LeverageEditor = (props)=>{
    // const [maxLeverage, { update, config: leverageLevers }] = useLeverage();
    const { maxLeverage, leverageLevers, onSave } = props;
    const [leverage, setLeverage] = (0, _react.useState)(()=>maxLeverage ?? 0);
    const leverageValue = (0, _react.useMemo)(()=>{
        const index = leverageLevers.findIndex((item)=>item === leverage);
        return index;
    }, [
        leverage,
        leverageLevers
    ]);
    return /*#__PURE__*/ (0, _jsxruntime.jsx)(_slider.Slider, {
        min: 0,
        max: leverageLevers.length - 1,
        color: "primary",
        markLabelVisible: true,
        value: [
            leverageValue
        ],
        showTip: false,
        // markCount={5}
        marks: leverageLevers.map((item)=>({
                value: item,
                label: `${item}x`
            })),
        onValueChange: (value)=>{
            // console.log("value", value);
            const _value = leverageLevers[value[0]];
            setLeverage(_value);
        },
        onValueCommit: (value)=>{
            const _value = leverageLevers[value[0]];
            // setLeverage(_value);
            onSave?.({
                leverage: _value
            }).catch((err)=>{
                setLeverage(maxLeverage ?? 1);
            });
        }
    });
};

//# sourceMappingURL=leverageEditor.js.map