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";
/** 根容器内边距（与 ant-agentic-plugin-mermaid 设计一致） */ var MERMAID_ROOT_PADDING_PX = 8;
/** 左上角工具栏占位，避免与流程图节点重叠 */ var MERMAID_TOOLBAR_RESERVE_INLINE = 72;
var genStyle = function genStyle(token) {
    return _define_property({}, token.componentCls, {
        marginBottom: '0.75em',
        cursor: 'default',
        userSelect: 'none',
        padding: MERMAID_ROOT_PADDING_PX,
        borderRadius: '1em',
        maxWidth: '800px',
        border: "1px solid ".concat(token.colorBorder),
        backgroundColor: token.colorBgContainer,
        minWidth: '240px',
        minHeight: 'auto',
        display: 'flex',
        justifyContent: 'center',
        alignItems: 'stretch',
        flexDirection: 'column',
        position: 'relative',
        overflow: 'hidden',
        transition: 'height 0.3s ease, min-height 0.3s ease',
        '&-toolbar-float': {
            position: 'absolute',
            top: MERMAID_ROOT_PADDING_PX,
            insetInlineStart: MERMAID_ROOT_PADDING_PX,
            insetInlineEnd: 'auto',
            zIndex: 10,
            display: 'flex',
            alignItems: 'center',
            gap: token.paddingXXS,
            pointerEvents: 'auto'
        },
        /**
       * 不用 flex:1 撑满父级，避免矮图下方大块留白；
       * 内边距为工具栏与四周安全区，内容 flex 居中。
       */ '&-viewport': {
            width: '100%',
            minHeight: 120,
            boxSizing: 'border-box',
            paddingBlock: token.paddingLG,
            paddingInlineStart: token.paddingLG + MERMAID_TOOLBAR_RESERVE_INLINE,
            paddingInlineEnd: token.paddingLG,
            overflow: 'auto',
            position: 'relative',
            touchAction: 'auto',
            cursor: 'default',
            display: 'flex',
            flexDirection: 'column',
            justifyContent: 'center',
            alignItems: 'center'
        },
        '& [data-mermaid-container="true"]': {
            zIndex: 0,
            width: '100%',
            maxWidth: '100%',
            minHeight: 0,
            display: 'flex',
            flexDirection: 'column',
            justifyContent: 'center',
            alignItems: 'center',
            position: 'relative',
            overflow: 'visible',
            transition: 'opacity 0.3s ease, height 0.3s ease, min-height 0.3s ease, max-height 0.3s ease'
        },
        /**
       * 须为确定宽度，子 SVG 的 width:100% 才能按 viewBox 算出高度；
       * 使用 max-content 时百分比参照异常，易出现「有 DOM 但看不见」。
       */ '& [data-mermaid-wrapper]': {
            position: 'relative',
            width: '100%',
            maxWidth: '100%',
            boxSizing: 'border-box',
            overflow: 'visible',
            display: 'block',
            minHeight: 0,
            marginInline: 'auto'
        },
        '& [data-mermaid-svg="true"]': {
            display: 'block',
            width: '100%',
            maxWidth: '100%',
            height: 'auto',
            overflow: 'visible'
        },
        '&-error': {
            textAlign: 'center',
            color: token.colorError,
            padding: '0.5rem',
            flex: 1,
            position: 'relative',
            zIndex: 1,
            wordBreak: 'break-word',
            maxWidth: '100%',
            height: '100%',
            width: '100%',
            animation: 'agenticMermaidFadeIn 0.3s ease'
        },
        '&-empty': {
            textAlign: 'left',
            color: token.colorTextSecondary,
            padding: '0.75rem 1.5rem',
            position: 'relative',
            zIndex: 1,
            flex: 1,
            height: '100%',
            width: '100%',
            fontFamily: "ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace",
            fontSize: '0.875em',
            lineHeight: 1.7,
            animation: 'agenticMermaidFadeIn 0.3s ease'
        },
        '@keyframes agenticMermaidFadeIn': {
            from: {
                opacity: 0
            },
            to: {
                opacity: 1
            }
        },
        '& svg': {
            '& foreignObject': {
                overflow: 'visible'
            },
            '& foreignObject div': {
                overflow: 'visible'
            },
            '& .node': {
                '& rect, & circle, & ellipse, & polygon': {
                    stroke: token.colorBorder,
                    strokeWidth: '1px',
                    fill: token.colorBgContainer
                }
            },
            /**
         * 勿改 text-anchor / dominant-baseline：Mermaid 11 用 y、tspan 定位，
         * 全局 middle 会把流程图标签挪出框外，看起来像空白。
         */ '& text': {
                fill: "".concat(token.colorText, " !important")
            },
            '& tspan': {
                fill: "".concat(token.colorText, " !important")
            },
            '& .nodeLabel': {
                fontWeight: 500,
                fill: "".concat(token.colorText, " !important")
            },
            '& .edgeLabel': {
                fill: "".concat(token.colorTextSecondary, " !important")
            },
            '& .flowchart-label': {
                fill: "".concat(token.colorText, " !important")
            },
            '& .label': {
                fill: "".concat(token.colorText, " !important")
            }
        }
    });
};
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)
        ];
    });
}
