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 { ConfigProvider } from "antd";
import React, { useContext } from "react";
import { useEditorStore } from "../../store";
import { EditableTable } from "./EditableTable";
import { ReadonlyTableComponent } from "./ReadonlyTableComponent";
import { TablePropsContext } from "./TableContext";
/**
 * 表格组
 *
 * @param {RenderElementProps} props - 渲染元素的属性。
 *
 * @returns {JSX.Element} 表格组件的 JSX 元素。
 *
 * @component
 *
 * @example
 * ```tsx
 * <Table {...props} />
 * ```
 *
 * @remarks
 * 该组件使用了多个 React 钩子函数，包括 `useState`、`useEffect`、`useCallback` 和 `useRef`。
 *
 * - `useState` 用于管理组件的状态。
 * - `useEffect` 用于处理组件挂载和卸载时的副作用。
 * - `useCallback` 用于优化回调函数的性能。
 * - `useRef` 用于获取 DOM 元素的引用。
 *
 * 组件还使用了 `IntersectionObserver` 来检测表格是否溢出，并相应地添加或移除 CSS 类。
 *
 * @see https://reactjs.org/docs/hooks-intro.html React Hooks
 */ export var SlateTable = function SlateTable(_0) {
    var children = _0.children, props = _object_without_properties(_0, [
        "children"
    ]);
    var _editorProps_tableConfig;
    var _useEditorStore = useEditorStore(), readonly = _useEditorStore.readonly, markdownContainerRef = _useEditorStore.markdownContainerRef, editorProps = _useEditorStore.editorProps;
    var tableCssVariables = editorProps === null || editorProps === void 0 ? void 0 : (_editorProps_tableConfig = editorProps.tableConfig) === null || _editorProps_tableConfig === void 0 ? void 0 : _editorProps_tableConfig.cssVariables;
    var getPrefixCls = useContext(ConfigProvider.ConfigContext).getPrefixCls;
    var tablePath = useContext(TablePropsContext).tablePath;
    var baseCls = getPrefixCls('agentic-md-editor-content-table');
    if (readonly) {
        return /*#__PURE__*/ React.createElement(ReadonlyTableComponent, {
            element: props.element,
            baseCls: baseCls
        }, children);
    }
    return /*#__PURE__*/ React.createElement(EditableTable, {
        baseCls: baseCls,
        tablePath: tablePath,
        tableNode: props.element,
        markdownContainerRef: markdownContainerRef,
        tableCssVariables: tableCssVariables
    }, children);
};
