"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
Object.defineProperty(exports, "ChartView", {
    enumerable: true,
    get: function() {
        return ChartView;
    }
});
const _jsxruntime = require("react/jsx-runtime");
const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
const _tab = require("../../../../../tab");
const _tradeHistory = require("./tradeHistory");
const _tradeData = require("./tradeData");
const _tradingView = require("../../../../../block/tradingView");
const _lucidereact = require("lucide-react");
const _hooks = require("@orderly.network/hooks");
const _provider = require("../../../../../provider");
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 ChartView = (props)=>{
    const { symbol, tradingViewConfig } = props;
    const [activeTab, setActiveTab] = (0, _react.useState)("tradingView");
    const apiBaseUrl = (0, _hooks.useConfig)("apiBaseUrl");
    const [collapsed, setCollapsed] = (0, _hooks.useLocalStorage)("orderly:chart:collapsed", true);
    return /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
        id: "orderly-chart-view-tabs",
        className: "orderly-text-3xs",
        children: /*#__PURE__*/ (0, _jsxruntime.jsxs)(_tab.Tabs, {
            showIdentifier: false,
            value: activeTab,
            onTabChange: setActiveTab,
            tabBarClassName: "orderly-h-[40px]",
            collapsed: collapsed,
            // @ts-ignore
            onToggleCollapsed: ()=>setCollapsed((prev)=>!prev),
            tabBarExtra: (context)=>{
                return /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
                    className: "orderly-flex orderly-items-center",
                    children: /*#__PURE__*/ (0, _jsxruntime.jsx)("button", {
                        className: "orderly-px-5",
                        onClick: ()=>{
                            context.toggleContentVisible();
                        },
                        children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_lucidereact.ChevronDown, {
                            size: 18,
                            className: (0, _css.cn)("orderly-transition-transform orderly-text-base-contrast/50", context.contentVisible ? "orderly-rotate-180" : "orderly-rotate-0")
                        })
                    })
                });
            },
            children: [
                /*#__PURE__*/ (0, _jsxruntime.jsx)(_tab.TabPane, {
                    title: "Chart",
                    value: "tradingView",
                    children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_tradingView.TradingView, {
                        theme: "dark",
                        symbol: symbol,
                        autosize: false,
                        // @ts-ignore
                        apiBaseUrl: apiBaseUrl,
                        ...tradingViewConfig
                    })
                }),
                /*#__PURE__*/ (0, _jsxruntime.jsx)(_tab.TabPane, {
                    title: "Trade",
                    value: "tradeHistory",
                    children: /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
                        className: "orderly-h-[240px] orderly-overflow-y-auto",
                        children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_provider.SymbolProvider, {
                            symbol: symbol,
                            children: /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
                                className: "orderly-px-[16px]",
                                children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_tradeHistory.TradeHistoryPane, {
                                    symbol: symbol
                                })
                            })
                        })
                    })
                }),
                /*#__PURE__*/ (0, _jsxruntime.jsx)(_tab.TabPane, {
                    title: "Data",
                    value: "tradeData",
                    children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_provider.SymbolProvider, {
                        symbol: symbol,
                        children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_tradeData.TradeData, {
                            symbol: symbol
                        })
                    })
                })
            ]
        })
    });
};

//# sourceMappingURL=index.js.map