'use client';
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
/**
 * HazoValidationRuleEditor - Main component for managing document validation rules.
 *
 * Features:
 * - Left sidebar with rules grouped by document type
 * - Right panel with rule editor (basic, prompt, clarification tabs)
 * - CRUD via hazo_connect SQLite API
 * - Prompt editor with / commands and @ variables
 * - Clarification settings per rule
 */
import { useState, useEffect } from 'react';
import { cn } from '../../utils/cn.js';
import { EditorThemeProvider } from '../shared/editor_theme/index.js';
import { ValidationRuleEditorProvider } from './context.js';
import { RuleList } from './components/rule_list.js';
import { RuleEditor } from './components/rule_editor.js';
function ValidationRuleEditorInner({ className }) {
    // Defer render to avoid flushSync-during-lifecycle warnings in React 19.
    // Radix UI's dispatchDiscreteCustomEvent calls flushSync which conflicts
    // with React 19's stricter lifecycle enforcement when rendered synchronously.
    const [mounted, set_mounted] = useState(false);
    useEffect(() => { set_mounted(true); }, []);
    if (!mounted) {
        return (_jsx("div", { className: cn('cls_validation_rule_editor flex h-full border rounded-lg overflow-hidden bg-background', className) }));
    }
    return (_jsxs("div", { className: cn('cls_validation_rule_editor flex h-full border rounded-lg overflow-hidden bg-background', className), children: [_jsx(RuleList, { className: "w-72 flex-shrink-0" }), _jsx(RuleEditor, { className: "flex-1 min-w-0" })] }));
}
export function HazoValidationRuleEditor({ api_base_url, table_name, scope_id, className, theme, prompt_config, form_field_variables, read_only, available_document_types, available_response_sets, include_globals, on_clone_to_override, }) {
    return (_jsx(ValidationRuleEditorProvider, { api_base_url: api_base_url, table_name: table_name, scope_id: scope_id, prompt_config: prompt_config, form_field_variables: form_field_variables, read_only: read_only, available_document_types: available_document_types, available_response_sets: available_response_sets, include_globals: include_globals, on_clone_to_override: on_clone_to_override, children: _jsx(EditorThemeProvider, { theme: theme, children: _jsx(ValidationRuleEditorInner, { className: className }) }) }));
}
//# sourceMappingURL=validation_rule_editor.js.map