function _array_like_to_array(arr, len) {
    if (len == null || len > arr.length) len = arr.length;
    for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
    return arr2;
}
function _array_with_holes(arr) {
    if (Array.isArray(arr)) return arr;
}
function _define_property(obj, key, value) {
    if (key in obj) {
        Object.defineProperty(obj, key, {
            value: value,
            enumerable: true,
            configurable: true,
            writable: true
        });
    } else {
        obj[key] = value;
    }
    return obj;
}
function _iterable_to_array_limit(arr, i) {
    var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
    if (_i == null) return;
    var _arr = [];
    var _n = true;
    var _d = false;
    var _s, _e;
    try {
        for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
            _arr.push(_s.value);
            if (i && _arr.length === i) break;
        }
    } catch (err) {
        _d = true;
        _e = err;
    } finally{
        try {
            if (!_n && _i["return"] != null) _i["return"]();
        } finally{
            if (_d) throw _e;
        }
    }
    return _arr;
}
function _non_iterable_rest() {
    throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
function _object_spread(target) {
    for(var i = 1; i < arguments.length; i++){
        var source = arguments[i] != null ? arguments[i] : {};
        var ownKeys = Object.keys(source);
        if (typeof Object.getOwnPropertySymbols === "function") {
            ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
                return Object.getOwnPropertyDescriptor(source, sym).enumerable;
            }));
        }
        ownKeys.forEach(function(key) {
            _define_property(target, key, source[key]);
        });
    }
    return target;
}
function ownKeys(object, enumerableOnly) {
    var keys = Object.keys(object);
    if (Object.getOwnPropertySymbols) {
        var symbols = Object.getOwnPropertySymbols(object);
        if (enumerableOnly) {
            symbols = symbols.filter(function(sym) {
                return Object.getOwnPropertyDescriptor(object, sym).enumerable;
            });
        }
        keys.push.apply(keys, symbols);
    }
    return keys;
}
function _object_spread_props(target, source) {
    source = source != null ? source : {};
    if (Object.getOwnPropertyDescriptors) {
        Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
    } else {
        ownKeys(Object(source)).forEach(function(key) {
            Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
        });
    }
    return target;
}
function _object_without_properties(source, excluded) {
    if (source == null) return {};
    var target = {}, sourceKeys, key, i;
    if (typeof Reflect !== "undefined" && Reflect.ownKeys) {
        sourceKeys = Reflect.ownKeys(source);
        for(i = 0; i < sourceKeys.length; i++){
            key = sourceKeys[i];
            if (excluded.indexOf(key) >= 0) continue;
            if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
            target[key] = source[key];
        }
        return target;
    }
    target = _object_without_properties_loose(source, excluded);
    if (Object.getOwnPropertySymbols) {
        sourceKeys = Object.getOwnPropertySymbols(source);
        for(i = 0; i < sourceKeys.length; i++){
            key = sourceKeys[i];
            if (excluded.indexOf(key) >= 0) continue;
            if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
            target[key] = source[key];
        }
    }
    return target;
}
function _object_without_properties_loose(source, excluded) {
    if (source == null) return {};
    var target = {}, sourceKeys = Object.getOwnPropertyNames(source), key, i;
    for(i = 0; i < sourceKeys.length; i++){
        key = sourceKeys[i];
        if (excluded.indexOf(key) >= 0) continue;
        if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
        target[key] = source[key];
    }
    return target;
}
function _sliced_to_array(arr, i) {
    return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
}
function _type_of(obj) {
    "@swc/helpers - typeof";
    return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
}
function _unsupported_iterable_to_array(o, minLen) {
    if (!o) return;
    if (typeof o === "string") return _array_like_to_array(o, minLen);
    var n = Object.prototype.toString.call(o).slice(8, -1);
    if (n === "Object" && o.constructor) n = o.constructor.name;
    if (n === "Map" || n === "Set") return Array.from(n);
    if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
}
import { ConfigProvider } from "antd";
import { Chart as ChartJS, Filler, Legend, LineElement, PointElement, RadialLinearScale, Tooltip } from "chart.js";
import classNames from "classnames";
import React, { useContext, useEffect, useMemo, useRef, useState } from "react";
import { Radar } from "react-chartjs-2";
import ChartStatistic from "../ChartStatistic";
import { ChartContainer, ChartFilter, ChartToolBar, downloadChart } from "../components";
import { defaultColorList } from "../const";
import { hexToRgba, resolveCssVariable } from "../utils";
import { useStyle } from "./style";
var radarChartComponentsRegistered = false;
var RadarChart = function(_0) {
    var data = _0.data, title = _0.title, _0_width = _0.width, width = _0_width === void 0 ? 600 : _0_width, _0_height = _0.height, height = _0_height === void 0 ? 400 : _0_height, className = _0.className, classNamesProp = _0.classNames, toolbarExtra = _0.toolbarExtra, _0_renderFilterInToolbar = _0.renderFilterInToolbar, renderFilterInToolbar = _0_renderFilterInToolbar === void 0 ? false : _0_renderFilterInToolbar, dataTime = _0.dataTime, color = _0.color, statisticConfig = _0.statistic, _0_textMaxWidth = _0.textMaxWidth, textMaxWidth = _0_textMaxWidth === void 0 ? 80 : _0_textMaxWidth, _0_loading = _0.loading, loading = _0_loading === void 0 ? false : _0_loading, props = _object_without_properties(_0, [
        "data",
        "title",
        "width",
        "height",
        "className",
        "classNames",
        "toolbarExtra",
        "renderFilterInToolbar",
        "dataTime",
        "color",
        "statistic",
        "textMaxWidth",
        "loading"
    ]);
    useMemo(function() {
        if (radarChartComponentsRegistered) {
            return undefined;
        }
        if (typeof window === 'undefined') {
            return undefined;
        }
        ChartJS.register(RadialLinearScale, PointElement, LineElement, Filler, Tooltip, Legend);
        radarChartComponentsRegistered = true;
        return undefined;
    }, []);
    var getPrefixCls = useContext(ConfigProvider.ConfigContext).getPrefixCls;
    var prefixCls = getPrefixCls('radar-chart');
    var _useStyle = useStyle(prefixCls), wrapSSR = _useStyle.wrapSSR, hashId = _useStyle.hashId;
    // 处理 ChartStatistic 组件配置
    var statistics = useMemo(function() {
        if (!statisticConfig) return null;
        return Array.isArray(statisticConfig) ? statisticConfig : [
            statisticConfig
        ];
    }, [
        statisticConfig
    ]);
    // 响应式尺寸计算
    var _useState = _sliced_to_array(useState(typeof window !== 'undefined' ? window.innerWidth : 768), 2), windowWidth = _useState[0], setWindowWidth = _useState[1];
    var isMobile = windowWidth <= 768;
    var responsiveWidth = isMobile ? '100%' : width;
    // 雷达图保持正方形比例，移动端使用屏幕宽度的85%，最大400px
    var responsiveHeight = isMobile ? Math.min(windowWidth * 0.85, 400) : height;
    // 监听窗口大小变化
    useEffect(function() {
        var handleResize = function() {
            setWindowWidth(window.innerWidth);
        };
        if (typeof window !== 'undefined') {
            window.addEventListener('resize', handleResize);
            return function() {
                return window.removeEventListener('resize', handleResize);
            };
        }
    }, []);
    // 清理自定义tooltip
    useEffect(function() {
        return function() {
            var tooltipEl = document.getElementById('custom-radar-tooltip');
            if (tooltipEl) {
                document.body.removeChild(tooltipEl);
            }
        };
    }, []);
    var chartRef = useRef(null);
    // 数据安全检查和处理 - 直接处理，不用 useMemo
    var safeData = !data || !Array.isArray(data) ? [] : data.filter(function(item) {
        return item !== null && item !== undefined && (typeof item === "undefined" ? "undefined" : _type_of(item)) === 'object' && 'label' in item;
    });
    // 从扁平化数据中提取分类，添加安全检查
    var categories = Array.from(new Set(safeData.map(function(item) {
        return item === null || item === void 0 ? void 0 : item.category;
    }).filter(function(category) {
        return Boolean(category);
    })));
    // 从数据中提取 filterLabel，过滤掉 undefined 值，添加安全检查
    var validFilterLabels = safeData.map(function(item) {
        return item === null || item === void 0 ? void 0 : item.filterLabel;
    }).filter(function(category) {
        return category !== undefined && category !== null && Boolean(category);
    });
    var filterLabels = validFilterLabels.length > 0 ? Array.from(new Set(validFilterLabels)) : undefined;
    // 状态管理，添加安全检查
    var _useState1 = _sliced_to_array(useState(function() {
        return categories.find(function(cat) {
            return Boolean(cat);
        }) || '';
    }), 2), selectedFilter = _useState1[0], setSelectedFilter = _useState1[1];
    var _useState2 = _sliced_to_array(useState(function() {
        return filterLabels && filterLabels.length > 0 ? filterLabels[0] : undefined;
    }), 2), selectedFilterLabel = _useState2[0], setSelectedFilterLabel = _useState2[1];
    // 根据选定的分类筛选数据，添加安全检查
    var filteredData = safeData.filter(function(item) {
        if (!item) return false; // 额外的安全检查
        if (!selectedFilter) return true;
        var categoryMatch = (item === null || item === void 0 ? void 0 : item.category) === selectedFilter;
        // 如果没有 filterLabels 或 selectedFilterLabel，只按 category 筛选
        if (!filterLabels || !selectedFilterLabel) {
            return categoryMatch;
        }
        // 如果有 filterLabel 筛选，需要同时匹配 category 和 filterLabel
        return categoryMatch && (item === null || item === void 0 ? void 0 : item.filterLabel) === selectedFilterLabel;
    });
    // 提取标签和数据集，添加安全检查
    var labels = Array.from(new Set(filteredData.map(function(item) {
        return item === null || item === void 0 ? void 0 : item.label;
    }).filter(function(label) {
        return Boolean(label);
    })));
    var datasetTypes = Array.from(new Set(filteredData.map(function(item) {
        return item === null || item === void 0 ? void 0 : item.type;
    }).filter(function(type) {
        return Boolean(type);
    })));
    var classNamesObj = classNamesProp;
    // 如果没有有效数据，返回空状态
    if (safeData.length === 0 || labels.length === 0 || datasetTypes.length === 0) {
        var _props_styles;
        return wrapSSR(/*#__PURE__*/ React.createElement(ChartContainer, {
            baseClassName: classNames("".concat(prefixCls, "-container")),
            theme: 'light',
            className: classNames(classNamesObj === null || classNamesObj === void 0 ? void 0 : classNamesObj.root, hashId, className),
            isMobile: isMobile,
            variant: props.variant,
            style: _object_spread({
                width: responsiveWidth,
                height: responsiveHeight
            }, props.style, (_props_styles = props.styles) === null || _props_styles === void 0 ? void 0 : _props_styles.root)
        }, /*#__PURE__*/ React.createElement(ChartToolBar, {
            title: title || '雷达图',
            onDownload: function() {},
            extra: toolbarExtra,
            dataTime: dataTime,
            loading: loading
        }), /*#__PURE__*/ React.createElement("div", {
            className: classNames("".concat(prefixCls, "-empty-wrapper"), hashId),
            style: {
                display: 'flex',
                alignItems: 'center',
                justifyContent: 'center',
                height: responsiveHeight,
                color: '#999',
                fontSize: '14px'
            }
        }, "暂无有效数据")));
    }
    // 构建数据集，添加更强的安全检查
    var datasets = datasetTypes.map(function(type, index) {
        var typeData = filteredData.filter(function(item) {
            return (item === null || item === void 0 ? void 0 : item.type) === type;
        });
        var scores = labels.map(function(label) {
            var item = typeData.find(function(d) {
                return (d === null || d === void 0 ? void 0 : d.label) === label;
            });
            if (!item || item.score === null || item.score === undefined) {
                return 0;
            }
            // 增强的 score 处理
            var score = item.score;
            if (typeof score === 'number') {
                return Number.isFinite(score) && score >= 0 ? score : 0;
            }
            if (typeof score === 'string') {
                var trimmed = score.trim();
                if (trimmed === '' || trimmed === 'null' || trimmed === 'undefined') {
                    return 0;
                }
                var parsed = Number(trimmed);
                return Number.isFinite(parsed) && parsed >= 0 ? parsed : 0;
            }
            return 0;
        });
        // 根据 color prop 选择颜色
        var providedColor = color;
        var baseColor = Array.isArray(providedColor) ? providedColor[index % providedColor.length] : providedColor;
        // 确保颜色数组安全访问
        var safeIndex = Math.max(0, index % defaultColorList.length);
        var safeDefaultColor = defaultColorList[safeIndex] || '#1677ff';
        var finalColor = baseColor || safeDefaultColor;
        // 解析 CSS 变量为实际颜色值（Canvas 需要实际颜色值）
        var resolvedColor = resolveCssVariable(finalColor);
        return {
            label: type || '默认',
            data: scores,
            borderColor: resolvedColor,
            backgroundColor: hexToRgba(resolvedColor, 0.125),
            borderWidth: isMobile ? 1.5 : 2,
            pointBackgroundColor: resolvedColor,
            pointBorderColor: '#fff',
            pointBorderWidth: isMobile ? 1 : 2,
            pointRadius: isMobile ? 3 : 4,
            pointHoverRadius: isMobile ? 5 : 6,
            fill: true
        };
    });
    // 构建当前配置（用于主题等设置）
    var currentConfig = {
        theme: 'light',
        showLegend: true,
        legendPosition: 'right'
    };
    // 筛选器的枚举，添加安全检查
    var filterEnum = categories.length > 0 ? categories.filter(function(category) {
        return Boolean(category);
    }).map(function(category) {
        return {
            label: category,
            value: category
        };
    }) : [];
    // 根据 filterLabel 筛选数据 - 只有当 filterLabels 存在时才生成
    var filteredDataByFilterLabel = filterLabels === null || filterLabels === void 0 ? void 0 : filterLabels.map(function(item) {
        return {
            key: item,
            label: item
        };
    });
    // 处理数据，应用默认颜色和样式，添加最终安全检查
    var processedData = {
        labels: labels.length > 0 ? labels : [
            '默认'
        ],
        datasets: datasets.length > 0 ? datasets : [
            {
                label: '默认',
                data: [
                    0
                ],
                borderColor: defaultColorList[0] || '#1677ff',
                backgroundColor: "".concat(defaultColorList[0] || '#1677ff', "20"),
                borderWidth: isMobile ? 1.5 : 2,
                pointBackgroundColor: defaultColorList[0] || '#1677ff',
                pointBorderColor: '#fff',
                pointBorderWidth: isMobile ? 1 : 2,
                pointRadius: isMobile ? 3 : 4,
                pointHoverRadius: isMobile ? 5 : 6,
                fill: true
            }
        ]
    };
    // 图表配置选项
    var options = {
        responsive: true,
        maintainAspectRatio: false,
        plugins: {
            legend: {
                display: currentConfig.showLegend !== false,
                position: isMobile ? 'bottom' : currentConfig.legendPosition || 'right',
                labels: {
                    color: currentConfig.theme === 'light' ? '#767E8B' : '#fff',
                    font: {
                        size: isMobile ? 10 : 12,
                        weight: 'normal'
                    },
                    padding: isMobile ? 10 : 20,
                    usePointStyle: true,
                    pointStyle: 'rectRounded',
                    generateLabels: function(chart) {
                        var original = ChartJS.defaults.plugins.legend.labels.generateLabels(chart);
                        // 创建一个临时 canvas 来测量文字宽度
                        var canvas = document.createElement('canvas');
                        var ctx = canvas.getContext('2d');
                        if (!ctx) return original;
                        // 设置字体样式与图例相同
                        var fontSize = isMobile ? 10 : 12;
                        ctx.font = "".concat(fontSize, "px 'PingFang SC', sans-serif");
                        return original.map(function(label) {
                            var originalText = label.text;
                            var textWidth = ctx.measureText(originalText).width;
                            if (textWidth <= textMaxWidth) {
                                return label;
                            }
                            // 文字超过最大宽度，需要截断
                            var ellipsis = '...';
                            var ellipsisWidth = ctx.measureText(ellipsis).width;
                            var maxTextWidth = textMaxWidth - ellipsisWidth;
                            var truncatedText = originalText;
                            var truncatedWidth = textWidth;
                            // 逐个字符减少直到宽度符合要求
                            while(truncatedWidth > maxTextWidth && truncatedText.length > 0){
                                truncatedText = truncatedText.slice(0, -1);
                                truncatedWidth = ctx.measureText(truncatedText).width;
                            }
                            return _object_spread_props(_object_spread({}, label), {
                                text: truncatedText + ellipsis
                            });
                        });
                    }
                }
            },
            tooltip: {
                enabled: false,
                external: function(context) {
                    var _dataPoint_label, _dataPoint_dataset_label, _dataPoint_dataset, _dataPoint_dataset_borderColor, _dataPoint_dataset1;
                    var chart = context.chart, tooltip = context.tooltip;
                    // 如果没有 tooltip 数据，隐藏
                    if (tooltip.opacity === 0) {
                        var tooltipEl = document.getElementById('custom-radar-tooltip');
                        if (tooltipEl) {
                            tooltipEl.style.opacity = '0';
                        }
                        return;
                    }
                    // 获取或创建自定义 tooltip 元素
                    var tooltipEl1 = document.getElementById('custom-radar-tooltip');
                    if (!tooltipEl1) {
                        tooltipEl1 = document.createElement('div');
                        tooltipEl1.id = 'custom-radar-tooltip';
                        tooltipEl1.style.position = 'absolute';
                        tooltipEl1.style.pointerEvents = 'none';
                        tooltipEl1.style.transition = 'all 0.1s ease';
                        document.body.appendChild(tooltipEl1);
                    }
                    // 获取数据，添加安全检查
                    if (!tooltip.dataPoints || tooltip.dataPoints.length === 0) {
                        return;
                    }
                    var dataPoint = tooltip.dataPoints[0];
                    if (!dataPoint) {
                        return;
                    }
                    var dimensionTitle = (dataPoint === null || dataPoint === void 0 ? void 0 : (_dataPoint_label = dataPoint.label) === null || _dataPoint_label === void 0 ? void 0 : _dataPoint_label.toString()) || ''; // 维度标题，如"技术"
                    var label = (dataPoint === null || dataPoint === void 0 ? void 0 : (_dataPoint_dataset = dataPoint.dataset) === null || _dataPoint_dataset === void 0 ? void 0 : (_dataPoint_dataset_label = _dataPoint_dataset.label) === null || _dataPoint_dataset_label === void 0 ? void 0 : _dataPoint_dataset_label.toString()) || '数据指标'; // 数据集标签
                    var value = '';
                    try {
                        var _dataPoint_parsed;
                        var rawValue = dataPoint === null || dataPoint === void 0 ? void 0 : (_dataPoint_parsed = dataPoint.parsed) === null || _dataPoint_parsed === void 0 ? void 0 : _dataPoint_parsed.r;
                        if (typeof rawValue === 'number' && Number.isFinite(rawValue)) {
                            value = rawValue.toFixed(1);
                        } else {
                            value = String(rawValue || 0);
                        }
                    } catch (error) {
                        value = '0';
                    }
                    // 获取数据集颜色作为图标颜色
                    var iconColor = (dataPoint === null || dataPoint === void 0 ? void 0 : (_dataPoint_dataset1 = dataPoint.dataset) === null || _dataPoint_dataset1 === void 0 ? void 0 : (_dataPoint_dataset_borderColor = _dataPoint_dataset1.borderColor) === null || _dataPoint_dataset_borderColor === void 0 ? void 0 : _dataPoint_dataset_borderColor.toString()) || '#388BFF';
                    // 创建 HTML 内容
                    var isDark = currentConfig.theme !== 'light';
                    var bgColor = isDark ? 'rgba(0, 0, 0, 0.8)' : 'rgba(255, 255, 255, 0.95)';
                    var labelColor = isDark ? '#fff' : '#767E8B'; // 左边图标信息颜色
                    tooltipEl1.innerHTML = '\n             <div style="\n               background-color: '.concat(bgColor, ";\n               border: 1px solid ").concat(isDark ? 'rgba(255, 255, 255, 0.2)' : 'rgba(0, 16, 32, 0.0627)', ";\n               border-radius: ").concat(isMobile ? '6px' : '8px', ";\n               padding: ").concat(isMobile ? '8px 12px' : '12px 16px', ";\n               font-family: 'PingFang SC', sans-serif;\n               box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);\n               backdrop-filter: blur(10px);\n               display: flex;\n               flex-direction: column;\n               gap: 8px;\n               min-width: 120px;\n             \">\n               <div style=\"\n                 font-family: 'PingFang SC', sans-serif;\n                 font-size: 12px;\n                 font-weight: normal;\n                 line-height: 20px;\n                 text-align: center;\n                 letter-spacing: 0em;\n                 font-variation-settings: 'opsz' auto;\n                 color: #767E8B;\n                 display: flex;\n                 align-items: center;\n                 justify-content: space-between;\n               \">").concat(dimensionTitle, '</div>\n               <div style="\n                 display: flex;\n                 align-items: center;\n                 justify-content: space-between;\n                 gap: 20px;\n               ">\n                 <div style="\n                   display: flex;\n                   align-items: center;\n                   gap: 8px;\n                 ">\n                   <div style="\n                     width: 12px;\n                     height: 12px;\n                     background-color: ').concat(iconColor, ';\n                     border-radius: 2px;\n                     flex-shrink: 0;\n                   "></div>\n                   <span style="\n                     color: ').concat(labelColor, ";\n                     font-size: ").concat(isMobile ? '11px' : '12px', ";\n                     font-weight: 500;\n                     font-family: 'PingFang SC', sans-serif;\n                     white-space: nowrap;\n                   \">").concat(label, "</span>\n                 </div>\n                 <span style=\"\n                   font-family: Rubik, sans-serif;\n                   font-size: 13px;\n                   font-weight: 500;\n                   line-height: 13px;\n                   text-align: center;\n                   letter-spacing: 0.04em;\n                   font-variation-settings: 'opsz' auto;\n                   font-feature-settings: 'kern' on;\n                   color: #343A45;\n                   white-space: nowrap;\n                 \">").concat(value, "</span>\n               </div>\n             </div>\n           ");
                    // 定位 tooltip
                    var position = chart.canvas.getBoundingClientRect();
                    tooltipEl1.style.opacity = '1';
                    tooltipEl1.style.left = position.left + window.pageXOffset + tooltip.caretX + 'px';
                    tooltipEl1.style.top = position.top + window.pageYOffset + tooltip.caretY + 'px';
                    tooltipEl1.style.zIndex = '1000';
                }
            }
        },
        scales: {
            r: {
                beginAtZero: true,
                max: 100,
                min: 0,
                ticks: {
                    stepSize: isMobile ? 25 : 20,
                    color: currentConfig.theme === 'light' ? 'rgba(0, 25, 61, 0.3255)' : '#fff',
                    font: {
                        size: isMobile ? 8 : 10
                    },
                    backdropColor: 'transparent',
                    callback: function callback(value) {
                        // 在每个坐标轴旁边显示刻度值
                        return value;
                    }
                },
                grid: {
                    color: currentConfig.theme === 'light' ? 'rgba(0, 0, 0, 0.1)' : 'rgba(255, 255, 255, 0.2)',
                    lineWidth: 1
                },
                angleLines: {
                    color: currentConfig.theme === 'light' ? 'rgba(0, 0, 0, 0.1)' : 'rgba(255, 255, 255, 0.2)',
                    lineWidth: 1
                },
                pointLabels: {
                    color: currentConfig.theme === 'light' ? 'rgba(0, 25, 61, 0.3255)' : '#fff',
                    font: {
                        size: isMobile ? 10 : 12,
                        weight: 500
                    },
                    padding: isMobile ? 10 : 15
                }
            }
        },
        elements: {
            point: {
                hoverRadius: isMobile ? 4 : 6
            }
        },
        animation: {
            duration: isMobile ? 200 : 400
        }
    };
    var handleDownload = function() {
        try {
            if (chartRef.current) {
                downloadChart(chartRef.current, 'radar-chart');
            }
        } catch (error) {
            console.warn('图表下载失败:', error);
        }
    };
    // 最终渲染，包含错误边界
    try {
        var _props_styles1;
        return wrapSSR(/*#__PURE__*/ React.createElement(ChartContainer, {
            baseClassName: classNames("".concat(prefixCls, "-container")),
            theme: currentConfig.theme,
            className: classNames(classNamesObj === null || classNamesObj === void 0 ? void 0 : classNamesObj.root, hashId, className),
            isMobile: isMobile,
            variant: props.variant,
            style: _object_spread({
                width: responsiveWidth,
                height: responsiveHeight
            }, props.style, (_props_styles1 = props.styles) === null || _props_styles1 === void 0 ? void 0 : _props_styles1.root)
        }, /*#__PURE__*/ React.createElement(ChartToolBar, {
            title: title || '雷达图',
            onDownload: handleDownload,
            extra: toolbarExtra,
            dataTime: dataTime,
            loading: loading,
            filter: renderFilterInToolbar && filterEnum.length > 0 ? /*#__PURE__*/ React.createElement(ChartFilter, _object_spread_props(_object_spread({
                filterOptions: filterEnum,
                selectedFilter: selectedFilter,
                onFilterChange: setSelectedFilter
            }, filterLabels && {
                customOptions: filteredDataByFilterLabel,
                selectedCustomSelection: selectedFilterLabel,
                onSelectionChange: setSelectedFilterLabel
            }), {
                theme: currentConfig.theme,
                variant: "compact"
            })) : undefined
        }), !renderFilterInToolbar && filterEnum.length > 0 && /*#__PURE__*/ React.createElement(ChartFilter, _object_spread_props(_object_spread({
            filterOptions: filterEnum,
            selectedFilter: selectedFilter,
            onFilterChange: setSelectedFilter
        }, filterLabels && {
            customOptions: filteredDataByFilterLabel,
            selectedCustomSelection: selectedFilterLabel,
            onSelectionChange: setSelectedFilterLabel
        }), {
            theme: currentConfig.theme
        })), statistics && /*#__PURE__*/ React.createElement("div", {
            className: classNames("".concat(prefixCls, "-statistic-container"), hashId)
        }, statistics.map(function(config, index) {
            return /*#__PURE__*/ React.createElement(ChartStatistic, _object_spread_props(_object_spread({
                key: index
            }, config), {
                theme: currentConfig.theme
            }));
        })), /*#__PURE__*/ React.createElement("div", {
            className: classNames("".concat(prefixCls, "-chart-wrapper"), hashId)
        }, /*#__PURE__*/ React.createElement(Radar, {
            ref: chartRef,
            data: processedData,
            options: options
        }))));
    } catch (error) {
        var _props_styles2;
        console.error('RadarChart 渲染错误:', error);
        return wrapSSR(/*#__PURE__*/ React.createElement(ChartContainer, {
            baseClassName: classNames("".concat(prefixCls, "-container")),
            theme: 'light',
            className: classNames(classNamesObj === null || classNamesObj === void 0 ? void 0 : classNamesObj.root, hashId, className),
            isMobile: isMobile,
            variant: props.variant,
            style: _object_spread({
                width: responsiveWidth,
                height: responsiveHeight
            }, props.style, (_props_styles2 = props.styles) === null || _props_styles2 === void 0 ? void 0 : _props_styles2.root)
        }, /*#__PURE__*/ React.createElement(ChartToolBar, {
            title: title || '雷达图',
            onDownload: function() {},
            extra: toolbarExtra,
            dataTime: dataTime,
            loading: loading
        }), /*#__PURE__*/ React.createElement("div", {
            className: classNames("".concat(prefixCls, "-error-wrapper"), hashId),
            style: {
                display: 'flex',
                alignItems: 'center',
                justifyContent: 'center',
                height: responsiveHeight,
                color: '#ff4d4f',
                fontSize: '14px'
            }
        }, "图表渲染失败，请检查数据格式")));
    }
};
export default RadarChart;
