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 _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 _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;
}
import classNames from "clsx";
import React from "react";
import ChartErrorBoundary from "./ChartErrorBoundary";
import { useStyle } from "./style";
/**
 * ChartContainer 组件 - 图表容器组件
 *
 * 该组件用于统一管理图表组件的 className 逻辑，包括 baseClassName、hashId 和自定义 className 的组合。
 * 提供一致的样式管理、SSR 支持和错误边界保护。
 *
 * @component
 * @description 图表容器组件，统一管理图表组件的样式类名和错误处理
 * @param {ChartContainerProps} props - 组件属性
 * @param {string} props.baseClassName - 基础类名
 * @param {string} [props.className] - 自定义CSS类名
 * @param {React.ReactNode} props.children - 子元素
 * @param {React.CSSProperties} [props.style] - 样式对象
 * @param {'light' | 'dark'} [props.theme='light'] - 图表主题
 * @param {boolean} [props.isMobile=false] - 是否为移动端
 * @param {object} [props.errorBoundary] - 错误边界配置
 * @param {boolean} [props.errorBoundary.enabled=true] - 是否启用错误边界
 * @param {React.ReactNode} [props.errorBoundary.fallback] - 错误时的回退UI
 * @param {function} [props.errorBoundary.onError] - 错误回调函数
 * @param {boolean} [props.errorBoundary.showError] - 是否显示错误详情
 *
 * @example
 * ```tsx
 * // 基础使用
 * <ChartContainer
 *   baseClassName="area-chart-container"
 *   className="custom-chart"
 *   theme="light"
 *   isMobile={false}
 *   style={{ width: 600, height: 400 }}
 * >
 *   <div>图表内容</div>
 * </ChartContainer>
 *
 * // 自定义错误边界
 * <ChartContainer
 *   baseClassName="line-chart-container"
 *   errorBoundary={{
 *     enabled: true,
 *     fallback: <div>自定义错误提示</div>,
 *     onError: (error, errorInfo) => {
 *       console.error('图表错误:', error);
 *       // 上报错误到监控系统
 *     },
 *     showError: true
 *   }}
 * >
 *   <MyChart />
 * </ChartContainer>
 *
 * // 禁用错误边界
 * <ChartContainer
 *   baseClassName="pie-chart-container"
 *   errorBoundary={{ enabled: false }}
 * >
 *   <PieChart />
 * </ChartContainer>
 * ```
 *
 * @returns {React.ReactElement} 渲染的图表容器组件
 *
 * @remarks
 * - 自动处理 baseClassName、hashId 和自定义 className 的组合
 * - 提供 SSR 支持
 * - 支持样式隔离
 * - 统一的样式管理
 * - 内置错误边界保护，防止图表错误影响整个应用
 * - 错误边界默认启用，可通过配置禁用或自定义
 */ var ChartContainer = function ChartContainer(_0) {
    var baseClassName = _0.baseClassName, className = _0.className, children = _0.children, style = _0.style, classNamesProp = _0.classNames, stylesProp = _0.styles, _0_theme = _0.theme, theme = _0_theme === void 0 ? 'light' : _0_theme, _0_variant = _0.variant, variant = _0_variant === void 0 ? 'default' : _0_variant, _0_isMobile = _0.isMobile, isMobile = _0_isMobile === void 0 ? false : _0_isMobile, _0_errorBoundary = _0.errorBoundary, errorBoundary = _0_errorBoundary === void 0 ? {
        enabled: true
    } : _0_errorBoundary, restProps = _object_without_properties(_0, [
        "baseClassName",
        "className",
        "children",
        "style",
        "classNames",
        "styles",
        "theme",
        "variant",
        "isMobile",
        "errorBoundary"
    ]);
    var _useStyle = useStyle(baseClassName), wrapSSR = _useStyle.wrapSSR, hashId = _useStyle.hashId;
    // 构建动态类名
    var combinedClassName = classNames(baseClassName, hashId, theme === 'light' && "".concat(baseClassName, "-light-theme"), theme === 'dark' && "".concat(baseClassName, "-dark-theme"), isMobile && "".concat(baseClassName, "-mobile"), !isMobile && "".concat(baseClassName, "-desktop"), variant === 'outline' && "".concat(baseClassName, "-outline"), variant === 'borderless' && "".concat(baseClassName, "-borderless"), className, classNamesProp === null || classNamesProp === void 0 ? void 0 : classNamesProp.root);
    var combinedStyle = _object_spread({}, style, stylesProp === null || stylesProp === void 0 ? void 0 : stylesProp.root);
    var containerContent = /*#__PURE__*/ React.createElement("div", _object_spread({
        className: combinedClassName,
        style: combinedStyle
    }, restProps), children);
    // 如果启用了错误边界，则包装内容
    if ((errorBoundary === null || errorBoundary === void 0 ? void 0 : errorBoundary.enabled) !== false) {
        return wrapSSR(/*#__PURE__*/ React.createElement(ChartErrorBoundary, {
            fallback: errorBoundary === null || errorBoundary === void 0 ? void 0 : errorBoundary.fallback,
            onError: errorBoundary === null || errorBoundary === void 0 ? void 0 : errorBoundary.onError
        }, containerContent));
    }
    return wrapSSR(containerContent);
};
export default ChartContainer;
