import { ComponentType, ReactNode } from "react";
import { AnyFieldDefinition, BlockDocument, BlockNode, EntityRef, EntityRef as EntityRef$1, EntityType, EntityType as EntityType$1, FieldBlockDefinition, FieldDefinition as FieldDefinition$1, FieldGroup as FieldGroup$1, FieldPath, FieldType, FieldValue, FieldValue as FieldValue$1, FieldValueMap, FieldValueMap as FieldValueMap$1, FieldsRevision, FieldsRevisionDiff, InlineBlockNode, LegacyFieldDefinition, LegacyFieldDefinition as FieldDefinition, LegacyFieldGroup, LegacyFieldGroup as FieldGroup, LegacyFieldType, OptionsPageDefinition, ResolvedAnyFieldDefinition, ResolvedFieldBlock, ResolvedFieldGroup, ResolvedFieldGroup as ResolvedFieldGroup$1, RuntimeFieldValueMap } from "@platform-modules/fields";
//#region src/client.d.ts
interface FieldsClient {
  getEntityValues(ref: EntityRef$1, opts: {
    subType?: string;
  }): Promise<FieldValueMap$1>;
  setEntityValues(input: {
    ref: EntityRef$1;
    groupId: string;
    values: FieldValueMap$1;
  }): Promise<void>;
  resolveGroups(opts: {
    entityType: EntityType$1;
    subType?: string;
  }): Promise<ResolvedFieldGroup$1[]>;
  listGroups(opts: {
    entityType?: EntityType$1;
    subType?: string;
  }): Promise<ResolvedFieldGroup$1[]>;
  createGroup(g: LegacyFieldGroup): Promise<ResolvedFieldGroup$1>;
  updateGroup(id: string, patch: Partial<LegacyFieldGroup>): Promise<ResolvedFieldGroup$1>;
  deleteGroup(id: string): Promise<void>;
}
//#endregion
//#region src/provider.d.ts
declare function FieldsProvider({ client, children }: {
  client: FieldsClient;
  children: ReactNode;
}): import("react").JSX.Element;
declare function useFieldsClient(): FieldsClient;
//#endregion
//#region src/hooks.d.ts
declare function useFieldValues(ref: EntityRef, opts?: {
  subType?: string;
  initialData?: FieldValueMap;
}): {
  values: FieldValueMap;
  loading: boolean;
  error: Error | null;
  reload: () => void;
};
declare function useEntityFields(ref: EntityRef, opts?: {
  subType?: string;
  initialData?: FieldValueMap;
}): {
  values: FieldValueMap;
  groups: ResolvedFieldGroup[];
  loading: boolean;
  error: Error | null;
  save: (groupId: string, nextValues: FieldValueMap) => Promise<void>;
  reload: () => void;
};
declare function useFieldGroupBuilder(entityType: EntityType, opts?: {
  subType?: string;
}): {
  groups: ResolvedFieldGroup[];
  loading: boolean;
  error: Error | null;
  create: (group: FieldGroup) => Promise<void>;
  update: (id: string, patch: Partial<FieldGroup>) => Promise<void>;
  remove: (id: string) => Promise<void>;
  reload: () => void;
};
//#endregion
//#region src/render.d.ts
interface FieldInputProps<F extends LegacyFieldDefinition = LegacyFieldDefinition> {
  field: F;
  value: FieldValue$1 | undefined;
  onChange: (v: FieldValue$1 | undefined) => void;
  error?: string;
  disabled?: boolean;
}
type FieldInputRegistry = { [T in LegacyFieldType]: ComponentType<FieldInputProps>; };
declare const referenceInputs: FieldInputRegistry;
//#endregion
//#region src/values-form.d.ts
interface FieldValuesFormProps {
  groups: ResolvedFieldGroup[];
  initialValues?: Record<string, FieldValueMap>;
  onSubmit: (groups: {
    groupId: string;
    values: FieldValueMap;
  }[]) => void | Promise<void>;
  disabled?: boolean;
  errors?: Record<string, Record<string, string>>;
}
declare function FieldValuesForm({ groups, initialValues, onSubmit, disabled, errors }: FieldValuesFormProps): import("react").JSX.Element;
//#endregion
//#region src/group-editor.d.ts
interface FieldGroupEditorProps {
  entityType: EntityType$1;
  subType?: string;
}
declare function FieldGroupEditor({ entityType, subType }: FieldGroupEditorProps): import("react").JSX.Element;
//#endregion
//#region src/async-options.d.ts
interface AsyncFieldOption<T = unknown> {
  readonly key: string;
  readonly label: string;
  readonly value: T;
  readonly description?: string;
}
interface AsyncFieldOptionPage<T = unknown> {
  readonly items: readonly AsyncFieldOption<T>[];
  readonly nextCursor: string | null;
}
interface AsyncFieldOptionRequest {
  readonly query: string;
  readonly cursor: string | null;
  readonly limit: number;
  readonly signal: AbortSignal;
}
interface AsyncFieldOptionSource<T = unknown> {
  search(request: AsyncFieldOptionRequest): Promise<AsyncFieldOptionPage<T>>;
}
interface AsyncOptionSearchProps<T = unknown> {
  readonly source: AsyncFieldOptionSource<T>;
  readonly onChoose: (option: AsyncFieldOption<T>) => void;
  readonly selectedKeys?: readonly string[];
  readonly label: string;
  readonly placeholder?: string;
  readonly pageSize?: number;
  readonly minQueryLength?: number;
  readonly disabled?: boolean;
}
declare function AsyncOptionSearch<T>({ source, onChoose, selectedKeys, label, placeholder, pageSize, minQueryLength, disabled }: AsyncOptionSearchProps<T>): import("react").JSX.Element;
//#endregion
//#region src/surface-registry.d.ts
interface ReactFieldSurfaceProps {
  readonly definition: ResolvedAnyFieldDefinition;
  readonly value: unknown;
  readonly onChange: (value: unknown) => void;
  readonly path: FieldPath;
  readonly inputId: string;
  readonly describedBy?: string;
  readonly invalid: boolean;
  readonly disabled: boolean;
  readonly readOnly: boolean;
}
interface ReactFieldReadOnlyProps {
  readonly definition: ResolvedAnyFieldDefinition;
  readonly value: unknown;
  readonly path: FieldPath;
}
interface ReactFieldSurfaceAdapter {
  readonly type: string;
  readonly contractVersion: string;
  readonly editor: ComponentType<ReactFieldSurfaceProps>;
  readonly readOnlyDisplay: ComponentType<ReactFieldReadOnlyProps>;
  readonly focusTarget: (container: HTMLElement) => HTMLElement | null;
  readonly responsive: Readonly<{
    fullWidth: boolean;
    minimumInlineSize?: number;
  }>;
  readonly a11y: Readonly<{
    labelStrategy: 'field' | 'adapter';
    description: string;
  }>;
}
type ReactFieldSurfaceResolution = {
  readonly kind: 'supported';
  readonly adapter: ReactFieldSurfaceAdapter;
} | {
  readonly kind: 'unsupported';
  readonly code: 'unsupported-surface';
  readonly type: string;
};
interface ReactFieldSurfaceRegistry {
  readonly version: string;
  readonly types: readonly string[];
  resolve(type: string): ReactFieldSurfaceResolution;
}
declare function createReactFieldSurfaceRegistry(input?: {
  extensions?: readonly ReactFieldSurfaceAdapter[];
}): ReactFieldSurfaceRegistry;
interface CustomFieldSurfaceProps {
  readonly definition: ResolvedAnyFieldDefinition;
  readonly value: unknown;
  readonly onChange: (value: unknown) => void;
  readonly path: FieldPath;
  readonly errors: readonly FieldValidationIssue[];
  readonly registry?: ReactFieldSurfaceRegistry;
  readonly inputId: string;
  readonly disabled: boolean;
  readonly readOnly: boolean;
}
declare function CustomFieldSurface({ definition, value, onChange, path, errors, registry, inputId, disabled, readOnly }: CustomFieldSurfaceProps): import("react").JSX.Element;
//#endregion
//#region src/complete-editor.d.ts
interface FieldValidationIssue {
  readonly path: FieldPath;
  readonly message: string;
  readonly code?: string;
}
type ReactFieldDefinition = AnyFieldDefinition | ResolvedAnyFieldDefinition;
interface CompleteFieldEditorAdapters {
  readonly createRowId?: () => string;
  readonly surfaceRegistry?: ReactFieldSurfaceRegistry;
  readonly resolveCloneFields?: (definition: FieldDefinition$1<'clone'>) => readonly AnyFieldDefinition[];
}
interface CompleteFieldValuesEditorProps {
  readonly fields: readonly ReactFieldDefinition[];
  readonly value: RuntimeFieldValueMap;
  readonly onChange: (value: RuntimeFieldValueMap) => void;
  readonly errors?: readonly FieldValidationIssue[];
  readonly disabled?: boolean;
  readonly readOnly?: boolean;
  readonly adapters?: CompleteFieldEditorAdapters;
  readonly legend?: string;
  readonly path?: FieldPath;
  readonly idPrefix?: string;
}
declare function CompleteFieldValuesEditor({ fields, value, onChange, errors, disabled, readOnly, adapters, legend, path, idPrefix }: CompleteFieldValuesEditorProps): import("react").JSX.Element;
//#endregion
//#region src/definition-builder.d.ts
declare const COMPLETE_FIELD_TYPES: readonly FieldType[];
declare function FieldDefinitionListBuilder({ value, onChange, disabled, label }: {
  value: readonly AnyFieldDefinition[];
  onChange: (value: readonly AnyFieldDefinition[]) => void;
  disabled?: boolean;
  label?: string;
}): import("react").JSX.Element;
interface FieldGroupDefinitionBuilderProps {
  readonly value: FieldGroup$1;
  readonly onChange: (value: FieldGroup$1) => void;
  readonly disabled?: boolean;
}
declare function FieldGroupDefinitionBuilder({ value, onChange, disabled }: FieldGroupDefinitionBuilderProps): import("react").JSX.Element;
//#endregion
//#region src/options-editor.d.ts
interface OptionsPageDefinitionEditorProps {
  readonly value: OptionsPageDefinition;
  readonly onChange: (value: OptionsPageDefinition) => void;
  readonly availableParents?: readonly Pick<OptionsPageDefinition, 'key' | 'title'>[];
  readonly disabled?: boolean;
}
declare function OptionsPageDefinitionEditor({ value, onChange, availableParents, disabled }: OptionsPageDefinitionEditorProps): import("react").JSX.Element;
interface OptionsPageValuesEditorProps {
  readonly page: Pick<OptionsPageDefinition, 'key' | 'title'>;
  readonly groups: readonly FieldGroup$1[];
  readonly value: Readonly<Record<string, RuntimeFieldValueMap>>;
  readonly onChange: (value: Readonly<Record<string, RuntimeFieldValueMap>>) => void;
  readonly errors?: Readonly<Record<string, readonly FieldValidationIssue[]>>;
  readonly disabled?: boolean;
  readonly readOnly?: boolean;
  readonly adapters?: CompleteFieldEditorAdapters;
}
declare function OptionsPageValuesEditor({ page, groups, value, onChange, errors, disabled, readOnly, adapters }: OptionsPageValuesEditorProps): import("react").JSX.Element;
//#endregion
//#region src/block-editor.d.ts
interface FieldBlockDefinitionEditorProps {
  readonly value: FieldBlockDefinition;
  readonly onChange: (value: FieldBlockDefinition) => void;
  readonly availableGroupKeys?: readonly string[];
  readonly availableBlockKeys?: readonly string[];
  readonly disabled?: boolean;
}
declare function FieldBlockDefinitionEditor({ value, onChange, availableGroupKeys, availableBlockKeys, disabled }: FieldBlockDefinitionEditorProps): import("react").JSX.Element;
interface BlockDefinitionBinding {
  readonly block: FieldBlockDefinition | ResolvedFieldBlock;
  readonly revision: number;
}
interface BlockFieldGroupBinding {
  readonly group: FieldGroup$1;
  readonly revision: number;
}
interface BlockDocumentEditorAdapters extends CompleteFieldEditorAdapters {
  readonly createNodeId?: () => string;
}
interface BlockDocumentEditorProps {
  readonly value: BlockDocument;
  readonly onChange: (value: BlockDocument) => void;
  readonly blocks: readonly BlockDefinitionBinding[];
  readonly groups: readonly BlockFieldGroupBinding[];
  readonly errors?: Readonly<Record<string, readonly FieldValidationIssue[]>>;
  readonly disabled?: boolean;
  readonly readOnly?: boolean;
  readonly adapters?: BlockDocumentEditorAdapters;
}
declare function BlockDocumentEditor({ value, onChange, blocks, groups, errors, disabled, readOnly, adapters }: BlockDocumentEditorProps): import("react").JSX.Element;
interface BlockPreviewAdapter {
  readonly renderInline: (input: {
    node: InlineBlockNode;
    binding: BlockDefinitionBinding;
    children: ReactNode;
  }) => ReactNode;
  readonly renderReusable: (input: {
    node: Extract<BlockNode, {
      kind: 'reusable';
    }>;
  }) => ReactNode;
}
interface BlockDocumentPreviewProps {
  readonly document: BlockDocument;
  readonly blocks: readonly BlockDefinitionBinding[];
  readonly adapter: BlockPreviewAdapter;
}
declare function BlockDocumentPreview({ document, blocks, adapter }: BlockDocumentPreviewProps): import("react").JSX.Element;
//#endregion
//#region src/revision-ui.d.ts
interface FieldValidationSummaryProps {
  readonly issues: readonly FieldValidationIssue[];
  readonly idPrefix?: string;
  readonly title?: string;
}
declare function FieldValidationSummary({ issues, idPrefix, title }: FieldValidationSummaryProps): import("react").JSX.Element | null;
interface FieldsRevisionDiffViewProps {
  readonly diff: FieldsRevisionDiff;
  readonly leftLabel?: string;
  readonly rightLabel?: string;
}
declare function FieldsRevisionDiffView({ diff, leftLabel, rightLabel }: FieldsRevisionDiffViewProps): import("react").JSX.Element;
interface FieldsRevisionRestorePanelProps {
  readonly revision: FieldsRevision;
  readonly diff?: FieldsRevisionDiff;
  readonly onRestore: (revision: FieldsRevision) => void | Promise<void>;
  readonly disabled?: boolean;
  readonly confirmationLabel?: string;
}
declare function FieldsRevisionRestorePanel({ revision, diff, onRestore, disabled, confirmationLabel }: FieldsRevisionRestorePanelProps): import("react").JSX.Element;
//#endregion
export { type AsyncFieldOption, type AsyncFieldOptionPage, type AsyncFieldOptionRequest, type AsyncFieldOptionSource, AsyncOptionSearch, type AsyncOptionSearchProps, type BlockDefinitionBinding, BlockDocumentEditor, type BlockDocumentEditorAdapters, type BlockDocumentEditorProps, BlockDocumentPreview, type BlockDocumentPreviewProps, type BlockFieldGroupBinding, type BlockPreviewAdapter, COMPLETE_FIELD_TYPES, type CompleteFieldEditorAdapters, CompleteFieldValuesEditor, type CompleteFieldValuesEditorProps, CustomFieldSurface, type CustomFieldSurfaceProps, type EntityRef, type EntityType, FieldBlockDefinitionEditor, type FieldBlockDefinitionEditorProps, type FieldDefinition, FieldDefinitionListBuilder, type FieldGroup, FieldGroupDefinitionBuilder, type FieldGroupDefinitionBuilderProps, FieldGroupEditor, type FieldInputProps, type FieldInputRegistry, type FieldValidationIssue, FieldValidationSummary, type FieldValidationSummaryProps, type FieldValue, type FieldValueMap, FieldValuesForm, type FieldsClient, FieldsProvider, FieldsRevisionDiffView, type FieldsRevisionDiffViewProps, FieldsRevisionRestorePanel, type FieldsRevisionRestorePanelProps, OptionsPageDefinitionEditor, type OptionsPageDefinitionEditorProps, OptionsPageValuesEditor, type OptionsPageValuesEditorProps, type ReactFieldDefinition, type ReactFieldReadOnlyProps, type ReactFieldSurfaceAdapter, type ReactFieldSurfaceProps, type ReactFieldSurfaceRegistry, type ReactFieldSurfaceResolution, type ResolvedFieldGroup, createReactFieldSurfaceRegistry, referenceInputs, useEntityFields, useFieldGroupBuilder, useFieldValues, useFieldsClient };