import { jsx as _jsx } from "react/jsx-runtime";
import { useEditContext } from "../../client/editContext";
import { SimpleIconButton } from "../../ui/SimpleIconButton";
import { Plus } from "lucide-react";
export function InsertControls() {
    const editContext = useEditContext();
    if (!editContext)
        return null;
    const insertMode = editContext.insertMode;
    const toggleInsertMode = () => {
        editContext.setInsertMode((x) => !x);
    };
    // Get canWriteItem from active slot context if available, fallback to editContext.page
    const activeSlotContext = editContext.getActiveSlotContext();
    const canWriteItem = activeSlotContext?.primaryPageViewContext.page?.item.canWriteItem ??
        activeSlotContext?.item?.canWriteItem ??
        editContext.page?.item.canWriteItem ??
        false;
    return (_jsx(SimpleIconButton, { "data-testid": "insert-component-button", icon: _jsx(Plus, { className: "h-6 w-6 p-1", strokeWidth: 1 }), label: "Add Component", size: "large", selected: insertMode, onClick: toggleInsertMode, disabled: !canWriteItem || editContext.readonly || editContext.mode !== "edit" }));
}
//# sourceMappingURL=InsertControls.js.map