import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { checkBlockHasDefaultProp, checkBlockTypeHasDefaultProp, } from "@endexai/blocknote-core";
import { useComponentsContext } from "../../../../editor/ComponentsContext.js";
import { useBlockNoteEditor } from "../../../../hooks/useBlockNoteEditor.js";
import { ColorPicker } from "../../../ColorPicker/ColorPicker.js";
export const BlockColorsItem = (props) => {
    const Components = useComponentsContext();
    const editor = useBlockNoteEditor();
    if (!checkBlockTypeHasDefaultProp("textColor", props.block.type, editor) &&
        !checkBlockTypeHasDefaultProp("backgroundColor", props.block.type, editor)) {
        return null;
    }
    return (_jsxs(Components.Generic.Menu.Root, { position: "right", sub: true, children: [_jsx(Components.Generic.Menu.Trigger, { sub: true, children: _jsx(Components.Generic.Menu.Item, { className: "bn-menu-item", subTrigger: true, children: props.children }) }), _jsx(Components.Generic.Menu.Dropdown, { sub: true, className: "bn-menu-dropdown bn-color-picker-dropdown", children: _jsx(ColorPicker, { iconSize: 18, text: checkBlockTypeHasDefaultProp("textColor", props.block.type, editor) && checkBlockHasDefaultProp("textColor", props.block, editor)
                        ? {
                            color: props.block.props.textColor,
                            setColor: (color) => editor.updateBlock(props.block, {
                                type: props.block.type,
                                props: { textColor: color },
                            }),
                        }
                        : undefined, background: checkBlockTypeHasDefaultProp("backgroundColor", props.block.type, editor) &&
                        checkBlockHasDefaultProp("backgroundColor", props.block, editor)
                        ? {
                            color: props.block.props.backgroundColor,
                            setColor: (color) => editor.updateBlock(props.block, {
                                props: { backgroundColor: color },
                            }),
                        }
                        : undefined }) })] }));
};
//# sourceMappingURL=BlockColorsItem.js.map