"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FloatingPlusControl = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const react_1 = require("react");
const FloatingPlusButton_1 = require("../FloatingPlusButton/index.js");
exports.FloatingPlusControl = (0, react_1.memo)(function YfmTableRowFloatingPlusControl({ type, index, cellElem, tableElem, onClick }) {
    const anchor = (0, react_1.useMemo)(() => ({
        contextElement: tableElem,
        getBoundingClientRect() {
            const cellRect = cellElem.getBoundingClientRect();
            const tableRect = tableElem.getBoundingClientRect();
            return type === 'row'
                ? {
                    x: tableRect.x,
                    y: cellRect.y,
                    width: tableRect.width,
                    height: cellRect.height,
                    top: cellRect.top,
                    left: tableRect.left,
                    right: tableRect.right,
                    bottom: cellRect.top,
                }
                : {
                    x: cellRect.x,
                    y: tableRect.y,
                    width: cellRect.width,
                    height: tableRect.height,
                    top: tableRect.top,
                    left: cellRect.left,
                    right: cellRect.right,
                    bottom: tableRect.top,
                };
        },
    }), [cellElem, tableElem, type]);
    return (0, jsx_runtime_1.jsx)(FloatingPlusButton_1.FloatingPlusButton, { anchor: anchor, type: type, onClick: () => onClick(index) });
});
//# sourceMappingURL=FloatingPlusControl.js.map
