/**
 * BaseFieldLayout - Shared JSX wrapper for form field components.
 *
 * Every form component renders an identical layout skeleton:
 *   CollabFormFieldContainer
 *     CollabFormFieldLabel
 *     div.flex.items-start.gap-2  (input wrapper)
 *       div.flex-1               (width constraint)
 *         {children}              (THE ONLY UNIQUE PART)
 *       UnifiedFieldControls
 *     CollabFormAddEntryIcon      (conditional)
 *     CollabFormDeleteEntryIcon   (conditional)
 *     CollabFormFieldReferenceTag
 *     CollabFormFieldError
 *     CollabFormFileUploadSection
 *
 * This component accepts the result from use_base_form_field and renders
 * everything except the unique input element, which is passed as children.
 */
'use client';
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { cn } from '../../utils/cn.js';
import { CollabFormFieldContainer, CollabFormFieldLabel, CollabFormFieldError, CollabFormFieldReferenceTag, CollabFormFileUploadSection, CollabFormAddEntryIcon, CollabFormDeleteEntryIcon, } from '../hazo_collab_form_base.js';
import { UnifiedFieldControls } from './unified_field_controls/index.js';
import { use_field_action_slot } from './use_field_action_slot.js';
/**
 * Standard form field layout used by inputbox, textarea, date, and combo.
 * Checkbox and radio have slightly different layouts so they use this
 * component partially or override sections.
 */
export function BaseFieldLayout({ base, wrapper_class_name, wrapper_extra_class_name, wrapper_flex_class = 'flex items-start gap-2', force_full_row = false, children, }) {
    const { container_props, label_props, controls_props, file_upload_props, reference_tag_props, error_props, entry_props, is_hidden, user_role, field_width_class_name, } = base;
    // Per-field action slots (only fire inside HazoCollabFormView; absent
    // when this layout is reused by HazoCollabFormView or other contexts).
    const { row_end, row_below } = use_field_action_slot(base.entry_props.field_id);
    return (_jsxs(CollabFormFieldContainer, { ...container_props, force_full_row: force_full_row, children: [_jsx(CollabFormFieldLabel, { ...label_props }), _jsxs("div", { className: cn(wrapper_class_name, wrapper_flex_class, wrapper_extra_class_name, is_hidden && user_role === 'author' && 'opacity-50'), suppressHydrationWarning: true, children: [_jsx("div", { className: cn(field_width_class_name || 'flex-1', field_width_class_name && 'flex-shrink-0'), children: children }), _jsx(UnifiedFieldControls, { ...controls_props }), row_end] }), row_below && _jsx("div", { className: "cls_field_action_below", children: row_below }), entry_props.show_add_entry && (_jsx(CollabFormAddEntryIcon, { label: entry_props.label, field_id: entry_props.field_id, on_add_entry: entry_props.on_add_entry, borderless: entry_props.action_buttons_borderless })), entry_props.is_additional_entry && entry_props.on_delete_entry && (_jsx(CollabFormDeleteEntryIcon, { label: entry_props.label, field_id: entry_props.field_id, on_delete_entry: entry_props.on_delete_entry })), _jsx(CollabFormFieldReferenceTag, { ...reference_tag_props }), _jsx(CollabFormFieldError, { ...error_props }), _jsx(CollabFormFileUploadSection, { ...file_upload_props })] }));
}
//# sourceMappingURL=base_field_layout.js.map