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 { ConfigProvider } from "antd";
import classNames from "clsx";
import React, { createElement, useContext } from "react";
import { useEditorStore } from "../../store";
/**
 * 列表组件，用于渲染有序或无序列表。
 *
 * @param {ElementProps<ListNode>} props - 组件的属性。
 * @param {ListNode} props.element - 列表节点元素，包含列表的相关信息。
 * @param {React.HTMLAttributes<HTMLDivElement>} props.attributes - 传递给列表容器的属性。
 * @param {React.ReactNode} props.children - 列表项的子元素。
 *
 * @returns {JSX.Element} 渲染的列表组件。
 *
 * @component
 * @example
 * ```tsx
 * <List element={element} attributes={attributes} children={children} />
 * ```
 */ export var List = function List(param) {
    var element = param.element, attributes = param.attributes, children = param.children;
    var _useEditorStore = useEditorStore(), store = _useEditorStore.store, markdownContainerRef = _useEditorStore.markdownContainerRef;
    var context = useContext(ConfigProvider.ConfigContext);
    var baseCls = context.getPrefixCls('agentic-md-editor-list');
    var listContent = React.useMemo(function() {
        // 支持新的列表类型和向后兼容
        var isOrdered = element.type === 'numbered-list' || element.type === 'list' && element.order === true;
        var task = element.task;
        var start = isOrdered ? element.start : undefined;
        var tag = isOrdered ? 'ol' : 'ul';
        return /*#__PURE__*/ React.createElement("div", _object_spread_props(_object_spread({
            className: classNames("".concat(baseCls, "-container"), 'relative'),
            "data-be": 'list'
        }, attributes), {
            onDragStart: function onDragStart(e) {
                store.dragStart(e, markdownContainerRef.current);
            }
        }), /*#__PURE__*/ createElement(tag, _object_spread({
            className: classNames(baseCls, isOrdered ? 'ol' : 'ul')
        }, start !== undefined && {
            start: start
        }, task && {
            'data-task': 'true'
        }), children));
    }, [
        element.type,
        element.order,
        element.task,
        element.start,
        element.children,
        baseCls,
        attributes,
        children,
        store,
        markdownContainerRef
    ]);
    return listContent;
};
