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 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;
}
import { useEditorStyleRegister } from "../../Hooks/useStyle";
var genStyle = function genStyle(token) {
    return _define_property({}, token.componentCls, {
        // 主容器样式
        marginBottom: '0.75em',
        cursor: 'default',
        userSelect: 'none',
        padding: '0.75rem 0',
        borderRadius: '1em',
        maxWidth: '800px',
        border: '1px solid #e8e8e8',
        backgroundColor: '#fff',
        minWidth: '240px',
        minHeight: '200px',
        display: 'flex',
        justifyContent: 'center',
        alignItems: 'center',
        flexDirection: 'column',
        // 增加隔离：防止内容溢出影响其他元素
        position: 'relative',
        isolation: 'isolate',
        contain: 'layout style paint',
        overflow: 'hidden',
        // 渲染容器样式
        '& [data-mermaid-container="true"]': {
            width: '100%',
            display: 'flex',
            justifyContent: 'center',
            // 增加隔离样式
            position: 'relative',
            isolation: 'isolate',
            contain: 'layout style paint',
            overflow: 'hidden'
        },
        // SVG 包装器样式（用于动态创建的 wrapper）
        '& [data-mermaid-wrapper]': {
            position: 'relative',
            width: '100%',
            maxWidth: '100%',
            overflow: 'hidden',
            isolation: 'isolate',
            contain: 'layout style paint',
            display: 'flex',
            justifyContent: 'center',
            alignItems: 'center',
            minHeight: '200px'
        },
        // SVG 元素样式
        '& [data-mermaid-svg="true"]': {
            maxWidth: '100%',
            height: 'auto',
            overflow: 'hidden'
        },
        // SVG 内部元素样式
        '& [data-mermaid-internal="true"]': {
        },
        // 加载状态样式
        '&-loading': {
            textAlign: 'center',
            color: '#6B7280',
            padding: '0.5rem',
            position: 'relative',
            zIndex: 1,
            width: '100%',
            display: 'flex',
            justifyContent: 'center',
            alignItems: 'center',
            minHeight: '200px',
            // Skeleton 样式优化
            '& .ant-skeleton': {
                width: '100%',
                maxWidth: '800px'
            },
            '& .ant-skeleton-image': {
                width: '100%',
                minHeight: '200px',
                borderRadius: '12px'
            }
        },
        // 错误状态样式
        '&-error': {
            textAlign: 'center',
            color: 'rgba(239, 68, 68, 0.8)',
            padding: '0.5rem',
            flex: 1,
            // 错误信息也增加隔离
            position: 'relative',
            zIndex: 1,
            wordBreak: 'break-word',
            maxWidth: '100%',
            height: '100%',
            width: '100%'
        },
        // 空状态样式
        '&-empty': {
            textAlign: 'center',
            color: '#6B7280',
            backgroundColor: '#fff',
            borderRadius: '12px',
            border: '1px solid #e1e5e9',
            padding: '0.5rem',
            position: 'relative',
            zIndex: 1,
            flex: 1,
            height: '100%',
            width: '100%'
        },
        // Fallback 组件样式
        '&-fallback': {
            marginBottom: '0.75em',
            padding: '0.75rem 0',
            display: 'flex',
            justifyContent: 'center',
            alignItems: 'center',
            color: '#6B7280',
            width: '100%',
            minHeight: '200px',
            // Skeleton 样式优化
            '& .ant-skeleton': {
                width: '100%',
                maxWidth: '800px'
            },
            '& .ant-skeleton-image': {
                width: '100%',
                minHeight: '200px',
                borderRadius: '12px'
            }
        },
        // SVG 渲染优化样式
        '& svg': {
            // 节点样式
            '& .node': {
                '& rect, & circle, & ellipse, & polygon': {
                    stroke: '#333',
                    strokeWidth: '1px',
                    fill: '#fff'
                }
            },
            // 强制设置所有文字样式
            '& text': {
                // 确保文字不会被裁剪
                dominantBaseline: 'middle',
                textAnchor: 'middle'
            },
            // 节点标签 - 更大的字体
            '& .nodeLabel': {
                fontWeight: 500,
                fill: '#333 !important'
            },
            // 边标签 - 稍小一些但仍然清晰
            '& .edgeLabel': {
                fill: '#666 !important'
            },
            // 专门针对流程图的文字
            '& .flowchart-label': {
                fill: '#333 !important'
            },
            // 针对不同类型的标签
            '& .label': {
                fill: '#333 !important'
            }
        }
    });
};
/**
 * Mermaid 插件样式 Hook
 * @param prefixCls - 样式类名前缀
 * @returns 样式相关的 wrapSSR 和 hashId
 */ export function useStyle(prefixCls) {
    return useEditorStyleRegister('agentic-plugin-mermaid', function(token) {
        var editorToken = _object_spread_props(_object_spread({}, token), {
            componentCls: ".".concat(prefixCls)
        });
        return [
            genStyle(editorToken)
        ];
    });
}
