"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
Object.defineProperty(exports, "default", {
    enumerable: true,
    get: function() {
        return DisplayControl;
    }
});
const _jsxruntime = require("react/jsx-runtime");
const _tooltip = require("../../../../tooltip");
const _kchart = require("../../../../icon/icons/kchart");
const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
const _dropdown = require("../../../../dropdown/dropdown");
const _css = require("../../../../utils/css");
const _lucidereact = require("lucide-react");
const _switch = require("../../../../switch");
function _getRequireWildcardCache(nodeInterop) {
    if (typeof WeakMap !== "function") return null;
    var cacheBabelInterop = new WeakMap();
    var cacheNodeInterop = new WeakMap();
    return (_getRequireWildcardCache = function(nodeInterop) {
        return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
    })(nodeInterop);
}
function _interop_require_wildcard(obj, nodeInterop) {
    if (!nodeInterop && obj && obj.__esModule) {
        return obj;
    }
    if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
        return {
            default: obj
        };
    }
    var cache = _getRequireWildcardCache(nodeInterop);
    if (cache && cache.has(obj)) {
        return cache.get(obj);
    }
    var newObj = {
        __proto__: null
    };
    var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
    for(var key in obj){
        if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
            var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
            if (desc && (desc.get || desc.set)) {
                Object.defineProperty(newObj, key, desc);
            } else {
                newObj[key] = obj[key];
            }
        }
    }
    newObj.default = obj;
    if (cache) {
        cache.set(obj, newObj);
    }
    return newObj;
}
const DisplayControlMap = [
    {
        label: "Position",
        id: "position"
    },
    // {
    //   label: "Buy/Sell",
    //   id: "buySell",
    // },
    {
        label: "Limit Orders",
        id: "limitOrders"
    },
    {
        label: "Stop orders",
        id: "stopOrders"
    },
    {
        label: "TP/SL",
        id: "tpsl"
    },
    {
        label: "Position TP/SL",
        id: "positionTpsl"
    }
];
function DisplayControl({ displayControlState, changeDisplayControlState }) {
    const [open, setOpen] = (0, _react.useState)(false);
    const triggerRef = _react.default.useRef(null);
    return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_dropdown.DropdownMenu, {
        open: open,
        onOpenChange: setOpen,
        modal: false,
        children: [
            /*#__PURE__*/ (0, _jsxruntime.jsx)(_dropdown.DropdownMenuTrigger, {
                asChild: true,
                children: /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
                    ref: triggerRef,
                    className: (0, _css.cn)("orderly-flex orderly-items-center orderly-justify-center orderly-w-[44px] orderly-h-[36px] orderly-rounded", open && "orderly-bg-base-500"),
                    children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_tooltip.Tooltip, {
                        content: "Display settings",
                        className: "orderly-max-w-[200px]",
                        children: /*#__PURE__*/ (0, _jsxruntime.jsxs)("button", {
                            className: "orderly-flex orderly-items-center orderly-text-base-contrast-54 hover:orderly-text-base-contrast",
                            children: [
                                /*#__PURE__*/ (0, _jsxruntime.jsx)(_kchart.KChartIcon, {
                                    size: 20,
                                    fill: "currentColor"
                                }),
                                /*#__PURE__*/ (0, _jsxruntime.jsx)(_lucidereact.ChevronDown, {
                                    size: 16,
                                    className: (0, _css.cn)("orderly-transition-transform orderly-text-base-contrast-45 hover:orderly-text-base-contrast", open && "orderly-rotate-180")
                                })
                            ]
                        })
                    })
                })
            }),
            /*#__PURE__*/ (0, _jsxruntime.jsx)(_dropdown.DropdownMenuContent, {
                align: "start",
                style: {
                    minWidth: "240px",
                    padding: 0,
                    margin: 0
                },
                children: /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
                    className: "orderly-flex orderly-flex-col orderly-p-6 orderly-gap-6",
                    children: DisplayControlMap.map((item)=>/*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
                            className: "orderly-text-xs orderly-flex orderly-items-center orderly-justify-between orderly-text-base-contrast-54",
                            id: item.id,
                            children: [
                                /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
                                    children: item.label
                                }),
                                /*#__PURE__*/ (0, _jsxruntime.jsx)(_switch.Switch, {
                                    id: `orderly-display-control-${item.id}`,
                                    color: "primary",
                                    checked: displayControlState[item.id],
                                    onCheckedChange: (checked)=>{
                                        changeDisplayControlState({
                                            ...displayControlState,
                                            [item.id]: checked
                                        });
                                    }
                                })
                            ]
                        }))
                })
            })
        ]
    });
}

//# sourceMappingURL=displayControl.js.map