"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
Object.defineProperty(exports, "default", {
    enumerable: true,
    get: function() {
        return LineTypeSelect;
    }
});
const _jsxruntime = require("react/jsx-runtime");
const _dropdown = require("../../../../dropdown/dropdown");
const _tooltip = require("../../../../tooltip");
const _candles = require("../../../../icon/icons/candles");
const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
const _bar = require("../../../../icon/icons/bar");
const _hollowCandles = require("../../../../icon/icons/hollowCandles");
const _line = require("../../../../icon/icons/line");
const _Area = require("../../../../icon/icons/Area");
const _baseLine = require("../../../../icon/icons/baseLine");
const _css = require("../../../../utils/css");
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 lineTypeList = [
    {
        icon: /*#__PURE__*/ (0, _jsxruntime.jsx)(_bar.BarIcon, {
            fill: "currentColor",
            size: 20
        }),
        label: "Bars",
        value: "0"
    },
    {
        icon: /*#__PURE__*/ (0, _jsxruntime.jsx)(_candles.CandlesIcon, {
            fill: "currentColor",
            size: 20
        }),
        label: "Candles",
        value: "1"
    },
    {
        icon: /*#__PURE__*/ (0, _jsxruntime.jsx)(_hollowCandles.HollowCandlesIcon, {
            fill: "currentColor",
            size: 20
        }),
        label: "Hollow candles",
        value: "9"
    },
    {
        icon: /*#__PURE__*/ (0, _jsxruntime.jsx)(_line.LineIcon, {
            fill: "currentColor",
            size: 20
        }),
        label: "Line",
        value: "2"
    },
    {
        icon: /*#__PURE__*/ (0, _jsxruntime.jsx)(_Area.AreaIcon, {
            fill: "currentColor",
            size: 20
        }),
        label: "Area",
        value: "3"
    },
    {
        icon: /*#__PURE__*/ (0, _jsxruntime.jsx)(_baseLine.BaseLineIcon, {
            fill: "currentColor",
            size: 20
        }),
        label: "Baseline",
        value: "10"
    }
];
function LineTypeSelect({ lineType, changeLineType }) {
    const [open, setOpen] = (0, _react.useState)(false);
    const triggerRef = _react.default.useRef(null);
    const [currentIcon, setCurrentIcon] = (0, _react.useState)(lineTypeList[1].icon);
    (0, _react.useEffect)(()=>{
        ;
        const line = lineTypeList.find((item)=>item.value === lineType);
        if (line) {
            return setCurrentIcon(line.icon);
        }
    }, [
        lineType
    ]);
    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: "orderly-h-[20px]",
                    children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_tooltip.Tooltip, {
                        content: "Line type",
                        className: "orderly-max-w-[200px]",
                        children: /*#__PURE__*/ (0, _jsxruntime.jsx)("button", {
                            className: "orderly-text-base-contrast-54 hover:orderly-text-base-contrast",
                            children: currentIcon
                        })
                    })
                })
            }),
            /*#__PURE__*/ (0, _jsxruntime.jsx)(_dropdown.DropdownMenuContent, {
                align: "start",
                style: {
                    minWidth: "256px",
                    padding: 0,
                    margin: 0
                },
                children: /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
                    className: "orderly-flex orderly-flex-col orderly-p-6 orderly-gap-6",
                    children: lineTypeList.map((item)=>/*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
                            onClick: ()=>changeLineType(item.value),
                            className: (0, _css.cn)("orderly-text-base-contrast-54 hover:orderly-text-base-contrast orderly-cursor-pointer orderly-text-xs orderly-flex orderly-justify-start orderly-items-center orderly-gap-3", lineType === item.value && "orderly-text-base-contrast"),
                            children: [
                                item.icon,
                                item.label
                            ]
                        }, item.value))
                })
            })
        ]
    });
}

//# sourceMappingURL=lineTypeSelect.js.map