"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
Object.defineProperty(exports, "TabBarExtraNode", {
    enumerable: true,
    get: function() {
        return TabBarExtraNode;
    }
});
const _jsxruntime = require("react/jsx-runtime");
const _react = require("react");
const _checkbox = require("../../../../../checkbox");
const _label = require("../../../../../label");
const _hooks = require("@orderly.network/hooks");
const _tabContext = require("../../../../../tab/tabContext");
const _reactdropdownmenu = require("@radix-ui/react-dropdown-menu");
const _divider = require("../../../../../divider");
const _decimalPrecisionCheckBox = require("./decimalPrecisionCheckBox");
const _unPnlPriceBasisCheckBox = require("./unPnlPriceBasisCheckBox");
const _icon = require("../../../../../icon");
const TabBarExtraNode = (props)=>{
    const [showAllSymbol, setShowAllSymbol] = (0, _hooks.useSessionStorage)("showAllSymbol_position", true);
    const { updateData } = (0, _tabContext.useTabContext)();
    // const [symbol, setSymbol] = useState(() =>
    //   showAllSymbol ? "" : context.symbol
    // );
    const onShowAllSymbolChange = (isAll)=>{
        // setSymbol(isAll ? "" : context.symbol);
        setShowAllSymbol(isAll);
        updateData("showAllSymbol", isAll);
    };
    (0, _react.useEffect)(()=>updateData("showAllSymbol", showAllSymbol), []);
    // const onChecked = (checked: boolean) => {
    //   console.log(checked);
    // };
    return /*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
        className: "orderly-flex orderly-items-center orderly-gap-2",
        children: [
            /*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
                className: "orderly-flex orderly-items-center orderly-gap-2",
                children: [
                    /*#__PURE__*/ (0, _jsxruntime.jsx)(_checkbox.Checkbox, {
                        id: "showAll",
                        checked: showAllSymbol,
                        onCheckedChange: onShowAllSymbolChange
                    }),
                    /*#__PURE__*/ (0, _jsxruntime.jsx)(_label.Label, {
                        htmlFor: "showAll",
                        className: "orderly-text-base-contrast-54 orderly-text-3xs",
                        children: "Show all instruments"
                    })
                ]
            }),
            /*#__PURE__*/ (0, _jsxruntime.jsx)(SettingIcon, {
                ...props
            })
        ]
    });
};
const SettingIcon = (props)=>{
    const [open, setOpen] = (0, _react.useState)(false);
    const { updateData } = (0, _tabContext.useTabContext)();
    const onDecimalPrecisionChanged = (0, _react.useCallback)((type)=>{
        var value = 0;
        switch(type){
            case _decimalPrecisionCheckBox.DecimalPrecisionType.ZERO:
                value = 0;
                break;
            case _decimalPrecisionCheckBox.DecimalPrecisionType.ONE:
                value = 1;
                break;
            case _decimalPrecisionCheckBox.DecimalPrecisionType.TWO:
                value = 2;
                break;
        }
        updateData("pnlNotionalDecimalPrecision", value);
        props.setDecimalPrecision(type);
    }, [
        props.decimalPrecision
    ]);
    const onUnPnlPriceBasisChanged = (0, _react.useCallback)((type)=>{
        var value = 0;
        switch(type){
            case _unPnlPriceBasisCheckBox.UnPnlPriceBasisType.MARKET_PRICE:
                value = 0;
                break;
            case _unPnlPriceBasisCheckBox.UnPnlPriceBasisType.LAST_PRICE:
                value = 1;
                break;
        }
        updateData("unPnlPriceBasis", value);
        props.setUnPnlPriceBasic(type);
    }, [
        props.unPnlPriceBasis
    ]);
    return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_reactdropdownmenu.DropdownMenu, {
        open: open,
        onOpenChange: setOpen,
        children: [
            /*#__PURE__*/ (0, _jsxruntime.jsx)(_reactdropdownmenu.DropdownMenuTrigger, {
                children: /*#__PURE__*/ (0, _jsxruntime.jsx)("button", {
                    className: "orderly-pb-[1px] orderly-h-[48px] orderly-text-base-contrast-80 orderly-cursor-pointer orderly-fill-base-contrast-54 hover:orderly-fill-base-contrast",
                    children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_icon.SettingsIcon, {
                        fill: "currnet",
                        fillOpacity: 1
                    })
                })
            }),
            /*#__PURE__*/ (0, _jsxruntime.jsx)(_reactdropdownmenu.DropdownMenuContent, {
                align: "end",
                className: "orderly-bg-base-800 orderly-rounded orderly-rounded-borderRadius orderly-w-[280px] orderly-p-4 orderly-rounded-borderRadius orderly-shadow-[0px_12px_20px_0px_rgba(0,0,0,0.25)] orderly-z-40",
                onCloseAutoFocus: (e)=>e.preventDefault(),
                children: /*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
                    className: "orderly-flex orderly-flex-col orderly-text-3xs",
                    children: [
                        /*#__PURE__*/ (0, _jsxruntime.jsx)("span", {
                            className: "orderly-text-xs orderly-pb-3",
                            children: "Portfolio Settings"
                        }),
                        /*#__PURE__*/ (0, _jsxruntime.jsx)(_divider.Divider, {}),
                        /*#__PURE__*/ (0, _jsxruntime.jsx)("span", {
                            className: "orderly-pb-3 orderly-text-base-contrast-54 orderly-mt-2",
                            children: "Decimal Precision for PnL & Notional"
                        }),
                        /*#__PURE__*/ (0, _jsxruntime.jsx)(_decimalPrecisionCheckBox.DecimalPrecisionCheckbox, {
                            value: props.decimalPrecision,
                            onValueChange: onDecimalPrecisionChanged
                        }),
                        /*#__PURE__*/ (0, _jsxruntime.jsx)(_divider.Divider, {
                            className: "orderly-my-3"
                        }),
                        /*#__PURE__*/ (0, _jsxruntime.jsx)("span", {
                            className: "orderly-pb-3 orderly-text-base-contrast-54 orderly-mt-2",
                            children: "Unrealized PnL Price Basis"
                        }),
                        /*#__PURE__*/ (0, _jsxruntime.jsx)(_unPnlPriceBasisCheckBox.UnPnlPriceBasisCheckBox, {
                            value: props.unPnlPriceBasis,
                            onValueChange: onUnPnlPriceBasisChanged
                        })
                    ]
                })
            })
        ]
    });
};

//# sourceMappingURL=tabbarExtraNode.js.map