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 { ExportOutlined } from "@ant-design/icons";
import React, { useMemo } from "react";
import { Node } from "slate";
import { debugInfo } from "../../../../Utils/debugUtils";
import { useEditorStore } from "../../store";
export var FootnoteDefinition = function FootnoteDefinition(props) {
    debugInfo('FootnoteDefinition - 渲染脚注定义', {
        identifier: props.element.identifier,
        url: props.element.url
    });
    var _useEditorStore = useEditorStore(), store = _useEditorStore.store, readonly = _useEditorStore.readonly, markdownContainerRef = _useEditorStore.markdownContainerRef;
    var element = props.element;
    useMemo(function() {
        debugInfo('FootnoteDefinition - 更新脚注定义映射', {
            identifier: element.identifier
        });
        store.footnoteDefinitionMap = store.footnoteDefinitionMap.set(element.identifier, element);
    }, [
        element
    ]);
    return React.useMemo(function() {
        var str = Node.string(props.element);
        debugInfo('FootnoteDefinition - useMemo 渲染', {
            identifier: element.identifier,
            strLength: str.length,
            readonly: readonly
        });
        return /*#__PURE__*/ React.createElement("div", _object_spread_props(_object_spread({}, props.attributes), {
            style: {
                fontSize: '12px',
                margin: '5px 0',
                display: 'flex',
                gap: 4
            },
            "data-be": 'footnoteDefinition',
            "data-drag-el": true,
            className: !str ? 'empty' : undefined,
            onDragStart: function onDragStart(e) {
                store.dragStart(e, markdownContainerRef.current);
            }
        }), element.identifier, ".", /*#__PURE__*/ React.createElement("span", {
            style: {
                display: 'flex',
                alignItems: 'center',
                gap: 2
            }
        }, props.children, readonly ? /*#__PURE__*/ React.createElement(ExportOutlined, null) : null));
    }, [
        props.element.children
    ]);
};
