import { jsx as _jsx } from "react/jsx-runtime";
import { Sparkles } from "lucide-react";
/**
 * Context menu factory for text fields (single-line, multi-line)
 * Adds AI Edit option when text is selected
 */
export async function createTextContextMenu(field, editContext) {
    const menuItems = [];
    // Only show AI Edit option when text is selected and AI is licensed
    const selectedRange = editContext.selectedRange;
    if (editContext.configuration.hasAiLicense !== false &&
        selectedRange?.text &&
        selectedRange.fieldId === field.id &&
        selectedRange.itemId === field.descriptor.item.id) {
        menuItems.push({
            id: "ai-edit",
            label: "AI Edit",
            icon: _jsx(Sparkles, { strokeWidth: 1, className: "text-highlight-100 h-4 w-4" }),
            command: async () => {
                // The InlineAiTrigger will handle showing the dialog
                // We just need to ensure the trigger button click is simulated
                // Since we already have the selection, the dialog will open
                // Dispatch a custom event that InlineAiTrigger can listen to
                const event = new CustomEvent("inline-ai-open", {
                    detail: {
                        selectedText: selectedRange.text,
                        fieldId: field.id,
                        itemId: field.descriptor.item.id,
                    },
                });
                document.dispatchEvent(event);
            },
        });
    }
    return menuItems;
}
//# sourceMappingURL=textContextMenuFactory.js.map