import * as React from 'react';
import { MouseEvent, ReactNode, ComponentType, ForwardRefExoticComponent, RefAttributes, Ref, ChangeEvent } from 'react';

interface CommonProperties {
    path?: number[];
    id?: string;
    disabled?: boolean;
}
type RuleType<F extends string = string, O extends string = string, V = any, C extends string = string> = CommonProperties & {
    field: F;
    operator: O;
    value: V;
    valueSource?: ValueSource;
    /**
     * Only used when adding a rule to a query that uses independent combinators
     */
    combinatorPreceding?: C;
};
type RuleGroupType<R extends RuleType = RuleType, C extends string = string> = CommonProperties & {
    combinator: C;
    rules: RuleGroupArray<RuleGroupType<R, C>, R>;
    not?: boolean;
};
type RuleGroupArray<RG extends RuleGroupType = RuleGroupType, R extends RuleType = RuleType> = (R | RG)[];
type UpdateableProperties = Exclude<keyof (RuleType & RuleGroupType), 'id' | 'path' | 'rules'>;
type DefaultRuleGroupArray = RuleGroupArray<DefaultRuleGroupType, DefaultRuleType>;
type DefaultRuleGroupType = RuleGroupType<DefaultRuleType, DefaultCombinatorNameExtended> & {
    rules: DefaultRuleGroupArray;
};
type DefaultRuleType = RuleType<string, DefaultOperatorName>;
type DefaultCombinatorName = 'and' | 'or';
type DefaultCombinatorNameExtended = DefaultCombinatorName | 'xor';
type DefaultOperatorName = '=' | '!=' | '<' | '>' | '<=' | '>=' | 'contains' | 'beginsWith' | 'endsWith' | 'doesNotContain' | 'doesNotBeginWith' | 'doesNotEndWith' | 'null' | 'notNull' | 'in' | 'notIn' | 'between' | 'notBetween';
type DefaultCombinator = Combinator<DefaultCombinatorName>;
type DefaultCombinatorExtended = Combinator<DefaultCombinatorNameExtended>;
type DefaultOperator = Operator<DefaultOperatorName>;

type MAXIMUM_ALLOWED_BOUNDARY$1 = 80;
type MappedTuple<Tuple extends Array<unknown>, Result extends Array<unknown> = [], Count extends ReadonlyArray<number> = []> = Count['length'] extends MAXIMUM_ALLOWED_BOUNDARY$1 ? Result : Tuple extends [] ? [] : Result extends [] ? MappedTuple<Tuple, Tuple, [...Count, 1]> : MappedTuple<Tuple, Result | [...Result, ...Tuple], [...Count, 1]>;

type RuleGroupTypeIC<R extends RuleType = RuleType, C extends string = string> = Omit<RuleGroupType<R, C>, 'combinator' | 'rules'> & {
    rules: RuleGroupICArray<RuleGroupTypeIC<R, C>, R, C>;
    /**
     * Only used when adding a rule to a query that uses independent combinators
     */
    combinatorPreceding?: C;
};
type RuleGroupTypeAny = RuleGroupType | RuleGroupTypeIC;
type RuleGroupICArray<RG extends RuleGroupTypeIC = RuleGroupTypeIC, R extends RuleType = RuleType, C extends string = string> = [R | RG] | [R | RG, ...MappedTuple<[C, R | RG]>] | ((R | RG)[] & {
    length: 0;
});
type RuleOrGroupArray = RuleGroupArray | RuleGroupICArray;
type DefaultRuleGroupICArray = RuleGroupICArray<DefaultRuleGroupTypeIC, DefaultRuleType, DefaultCombinatorName>;
type DefaultRuleOrGroupArray = DefaultRuleGroupArray | DefaultRuleGroupICArray;
interface DefaultRuleGroupTypeIC extends RuleGroupTypeIC {
    rules: DefaultRuleGroupICArray;
}
type DefaultRuleGroupTypeAny = DefaultRuleGroupType | DefaultRuleGroupTypeIC;

interface ValidationResult {
    valid: boolean;
    reasons?: any[];
}
type ValidationMap = Record<string, boolean | ValidationResult>;
type QueryValidator = (query: RuleGroupTypeAny) => boolean | ValidationMap;
type RuleValidator = (rule: RuleType) => boolean | ValidationResult;

type Classname = string | string[] | Record<string, any>;
type ValueSource = 'value' | 'field';
type ValueEditorType = 'text' | 'select' | 'checkbox' | 'radio' | 'textarea' | 'switch' | 'multiselect' | null;
type ValueSources = ['value'] | ['value', 'field'] | ['field', 'value'] | ['field'];
interface Option<N extends string = string> {
    name: N;
    label: string;
    [x: string]: any;
}
/**
 * @deprecated Renamed to `Option`
 */
type NameLabelPair<N extends string = string> = Option<N>;
type OptionGroup<Opt extends Option = Option> = {
    label: string;
    options: Opt[];
};
type OptionList<Opt extends Option = Option> = Opt[] | OptionGroup<Opt>[];
interface HasOptionalClassName {
    className?: Classname;
}
interface Field<FieldName extends string = string, OperatorName extends string = string, ValueName extends string = string, OperatorObj extends Option = Option<OperatorName>, ValueObj extends Option = Option<ValueName>> extends Option<FieldName>, HasOptionalClassName {
    id?: string;
    operators?: OptionList<OperatorObj>;
    valueEditorType?: ValueEditorType | ((operator: OperatorName) => ValueEditorType);
    valueSources?: ValueSources | ((operator: OperatorName) => ValueSources);
    inputType?: string | null;
    values?: OptionList<ValueObj>;
    defaultOperator?: OperatorName;
    defaultValue?: any;
    placeholder?: string;
    validator?: RuleValidator;
    comparator?: string | ((f: Field, operator: string) => boolean);
}
type WithRequired<T, K extends keyof T> = T & {
    [P in K]-?: T[P];
};
type Arity = number | 'unary' | 'binary' | 'ternary';
interface Operator<N extends string = string> extends Option<N>, HasOptionalClassName {
    arity?: Arity;
}
interface Combinator<N extends string = string> extends Option<N>, HasOptionalClassName {
}
type ParseNumbersMethod = boolean | 'strict' | 'native';

type DndDropTargetType = 'rule' | 'ruleGroup' | 'inlineCombinator';
interface DraggedItem {
    path: number[];
}
type DropEffect = 'move' | 'copy';
interface DropResult {
    path: number[];
    type: DndDropTargetType;
    dropEffect?: DropEffect;
}
interface DragCollection {
    isDragging: boolean;
    dragMonitorId: string | symbol;
}
interface DropCollection {
    isOver: boolean;
    dropMonitorId: string | symbol;
    dropEffect?: DropEffect;
}

type RenameToIn<T> = {
    [K in keyof T as K extends `in${Uppercase<string>}${Lowercase<string>}` ? `in` : K]: T[K];
};
/**
 * This is a utility type used below for the "if" operation.
 * Original: https://stackoverflow.com/a/68373774/765987
 */
type MAXIMUM_ALLOWED_BOUNDARY = 80;
type Mapped<Tuple extends unknown[], Result extends unknown[] = [], Count extends ReadonlyArray<number> = []> = Count['length'] extends MAXIMUM_ALLOWED_BOUNDARY ? Result : Tuple extends [] ? [] : Result extends [] ? Mapped<Tuple, Tuple, [...Count, 1]> : Mapped<Tuple, Result | [...Result, ...Tuple], [...Count, 1]>;
/**
 * Used for the "if" operation, which takes an array of odd length
 * and a minimum of three (3) elements.
 */
type AnyArrayOfOddLengthMin3 = [any, ...Mapped<[any, any]>];
type ReservedOperations = 'var' | 'missing' | 'missing_some' | 'if' | '==' | '===' | '!=' | '!==' | '!' | '!!' | 'or' | 'and' | '>' | '>=' | '<' | '<=' | 'max' | 'min' | '+' | '-' | '*' | '/' | '%' | 'map' | 'filter' | 'reduce' | 'all' | 'none' | 'some' | 'merge' | 'in' | 'cat' | 'substr' | 'log';
/**
 * This can be an object with any key except the reserved keys.
 * TODO: Find a way to limit this type to exactly one (1) key, since
 * json-logic-js enforces it. See:
 * https://github.com/jwadhams/json-logic-js/blob/2.0.2/logic.js#L180
 */
type AdditionalOperation = Partial<Record<ReservedOperations, never>> & {
    [k: string]: any;
};
interface AllReservedOperationsInterface<AddOps extends AdditionalOperation = never> {
    var: RulesLogic<AddOps> | [RulesLogic<AddOps>] | [RulesLogic<AddOps>, any] | [RulesLogic<AddOps>, any];
    missing: RulesLogic<AddOps> | any[];
    missing_some: [RulesLogic<AddOps>, RulesLogic<AddOps> | any[]];
    if: AnyArrayOfOddLengthMin3;
    '==': [any, any];
    '===': [any, any];
    '!=': [any, any];
    '!==': [any, any];
    '!': any;
    '!!': any;
    or: Array<RulesLogic<AddOps>>;
    and: Array<RulesLogic<AddOps>>;
    '>': [RulesLogic<AddOps>, RulesLogic<AddOps>];
    '>=': [RulesLogic<AddOps>, RulesLogic<AddOps>];
    '<': [RulesLogic<AddOps>, RulesLogic<AddOps>] | [RulesLogic<AddOps>, RulesLogic<AddOps>, RulesLogic<AddOps>];
    '<=': [RulesLogic<AddOps>, RulesLogic<AddOps>] | [RulesLogic<AddOps>, RulesLogic<AddOps>, RulesLogic<AddOps>];
    max: Array<RulesLogic<AddOps>>;
    min: Array<RulesLogic<AddOps>>;
    '+': Array<RulesLogic<AddOps>> | RulesLogic<AddOps>;
    '-': Array<RulesLogic<AddOps>> | RulesLogic<AddOps>;
    '*': Array<RulesLogic<AddOps>> | RulesLogic<AddOps>;
    '/': Array<RulesLogic<AddOps>> | RulesLogic<AddOps>;
    '%': [RulesLogic<AddOps>, RulesLogic<AddOps>];
    map: [RulesLogic<AddOps>, RulesLogic<AddOps>];
    filter: [RulesLogic<AddOps>, RulesLogic<AddOps>];
    reduce: [RulesLogic<AddOps>, RulesLogic<AddOps>, RulesLogic<AddOps>];
    all: [Array<RulesLogic<AddOps>>, RulesLogic<AddOps>] | [RulesLogic<AddOps>, RulesLogic<AddOps>];
    none: [Array<RulesLogic<AddOps>>, RulesLogic<AddOps>] | [RulesLogic<AddOps>, RulesLogic<AddOps>];
    some: [Array<RulesLogic<AddOps>>, RulesLogic<AddOps>] | [RulesLogic<AddOps>, RulesLogic<AddOps>];
    merge: Array<Array<RulesLogic<AddOps>> | RulesLogic<AddOps>>;
    inArray: [RulesLogic<AddOps>, Array<RulesLogic<AddOps>>];
    inString: [RulesLogic<AddOps>, RulesLogic<AddOps>];
    cat: Array<RulesLogic<AddOps>>;
    substr: [RulesLogic<AddOps>, RulesLogic<AddOps>] | [RulesLogic<AddOps>, RulesLogic<AddOps>, RulesLogic<AddOps>];
    log: RulesLogic<AddOps>;
}
type JsonLogicVar<AddOps extends AdditionalOperation = never> = Pick<AllReservedOperationsInterface<AddOps>, 'var'>;
type JsonLogicMissing<AddOps extends AdditionalOperation = never> = Pick<AllReservedOperationsInterface<AddOps>, 'missing'>;
type JsonLogicMissingSome<AddOps extends AdditionalOperation = never> = Pick<AllReservedOperationsInterface<AddOps>, 'missing_some'>;
type JsonLogicIf = Pick<AllReservedOperationsInterface, 'if'>;
type JsonLogicEqual = Pick<AllReservedOperationsInterface, '=='>;
type JsonLogicStrictEqual = Pick<AllReservedOperationsInterface, '==='>;
type JsonLogicNotEqual = Pick<AllReservedOperationsInterface, '!='>;
type JsonLogicStrictNotEqual = Pick<AllReservedOperationsInterface, '!=='>;
type JsonLogicNegation = Pick<AllReservedOperationsInterface, '!'>;
type JsonLogicDoubleNegation = Pick<AllReservedOperationsInterface, '!!'>;
type JsonLogicOr<AddOps extends AdditionalOperation = never> = Pick<AllReservedOperationsInterface<AddOps>, 'or'>;
type JsonLogicAnd<AddOps extends AdditionalOperation = never> = Pick<AllReservedOperationsInterface<AddOps>, 'and'>;
type JsonLogicGreaterThan<AddOps extends AdditionalOperation = never> = Pick<AllReservedOperationsInterface<AddOps>, '>'>;
type JsonLogicGreaterThanOrEqual<AddOps extends AdditionalOperation = never> = Pick<AllReservedOperationsInterface<AddOps>, '>='>;
type JsonLogicLessThan<AddOps extends AdditionalOperation = never> = Pick<AllReservedOperationsInterface<AddOps>, '<'>;
type JsonLogicLessThanOrEqual<AddOps extends AdditionalOperation = never> = Pick<AllReservedOperationsInterface<AddOps>, '<='>;
type JsonLogicMax<AddOps extends AdditionalOperation = never> = Pick<AllReservedOperationsInterface<AddOps>, 'max'>;
type JsonLogicMin<AddOps extends AdditionalOperation = never> = Pick<AllReservedOperationsInterface<AddOps>, 'min'>;
type JsonLogicSum<AddOps extends AdditionalOperation = never> = Pick<AllReservedOperationsInterface<AddOps>, '+'>;
type JsonLogicDifference<AddOps extends AdditionalOperation = never> = Pick<AllReservedOperationsInterface<AddOps>, '-'>;
type JsonLogicProduct<AddOps extends AdditionalOperation = never> = Pick<AllReservedOperationsInterface<AddOps>, '*'>;
type JsonLogicQuotient<AddOps extends AdditionalOperation = never> = Pick<AllReservedOperationsInterface<AddOps>, '/'>;
type JsonLogicRemainder<AddOps extends AdditionalOperation = never> = Pick<AllReservedOperationsInterface<AddOps>, '%'>;
type JsonLogicMap<AddOps extends AdditionalOperation = never> = Pick<AllReservedOperationsInterface<AddOps>, 'map'>;
type JsonLogicFilter<AddOps extends AdditionalOperation = never> = Pick<AllReservedOperationsInterface<AddOps>, 'filter'>;
type JsonLogicReduce<AddOps extends AdditionalOperation = never> = Pick<AllReservedOperationsInterface<AddOps>, 'reduce'>;
type JsonLogicAll<AddOps extends AdditionalOperation = never> = Pick<AllReservedOperationsInterface<AddOps>, 'all'>;
type JsonLogicNone<AddOps extends AdditionalOperation = never> = Pick<AllReservedOperationsInterface<AddOps>, 'none'>;
type JsonLogicSome<AddOps extends AdditionalOperation = never> = Pick<AllReservedOperationsInterface<AddOps>, 'some'>;
type JsonLogicMerge<AddOps extends AdditionalOperation = never> = Pick<AllReservedOperationsInterface<AddOps>, 'merge'>;
type JsonLogicInArray<AddOps extends AdditionalOperation = never> = RenameToIn<Pick<AllReservedOperationsInterface<AddOps>, 'inArray'>>;
type JsonLogicInString<AddOps extends AdditionalOperation = never> = RenameToIn<Pick<AllReservedOperationsInterface<AddOps>, 'inString'>>;
type JsonLogicCat<AddOps extends AdditionalOperation = never> = Pick<AllReservedOperationsInterface<AddOps>, 'cat'>;
type JsonLogicSubstr<AddOps extends AdditionalOperation = never> = Pick<AllReservedOperationsInterface<AddOps>, 'substr'>;
type JsonLogicLog<AddOps extends AdditionalOperation = never> = Pick<AllReservedOperationsInterface<AddOps>, 'log'>;
type RulesLogic<AddOps extends AdditionalOperation = never> = boolean | string | number | JsonLogicVar<AddOps> | JsonLogicMissing<AddOps> | JsonLogicMissingSome<AddOps> | JsonLogicIf | JsonLogicEqual | JsonLogicStrictEqual | JsonLogicNotEqual | JsonLogicStrictNotEqual | JsonLogicNegation | JsonLogicDoubleNegation | JsonLogicOr<AddOps> | JsonLogicAnd<AddOps> | JsonLogicGreaterThan<AddOps> | JsonLogicGreaterThanOrEqual<AddOps> | JsonLogicLessThan<AddOps> | JsonLogicLessThanOrEqual<AddOps> | JsonLogicMax<AddOps> | JsonLogicMin<AddOps> | JsonLogicSum<AddOps> | JsonLogicDifference<AddOps> | JsonLogicProduct<AddOps> | JsonLogicQuotient<AddOps> | JsonLogicRemainder<AddOps> | JsonLogicMap<AddOps> | JsonLogicFilter<AddOps> | JsonLogicReduce<AddOps> | JsonLogicAll<AddOps> | JsonLogicNone<AddOps> | JsonLogicSome<AddOps> | JsonLogicMerge<AddOps> | JsonLogicInArray<AddOps> | JsonLogicInString<AddOps> | JsonLogicCat<AddOps> | JsonLogicSubstr<AddOps> | JsonLogicLog<AddOps> | AddOps;

type ExportFormat = 'json' | 'sql' | 'json_without_ids' | 'parameterized' | 'parameterized_named' | 'mongodb' | 'cel' | 'jsonlogic' | 'spel';
interface FormatQueryOptions {
    /**
     * The export format.
     */
    format?: ExportFormat;
    /**
     * This function will be used to process the `value` from each rule
     * for query language formats. If not defined, the appropriate
     * `defaultValueProcessor` for the format will be used.
     */
    valueProcessor?: ValueProcessorLegacy | ValueProcessorByRule;
    /**
     * This function will be used to process each rule for query language
     * formats. If not defined, the appropriate `defaultRuleProcessor`
     * for the format will be used.
     */
    ruleProcessor?: RuleProcessor;
    /**
     * In the "sql"/"parameterized"/"parameterized_named" export formats,
     * field names will be bracketed by this string. If an array of strings
     * is passed, field names will be preceded by the first element and
     * succeeded by the second element. A common value for this option is
     * the backtick ('`').
     *
     * @default '' // the empty string
     *
     * @example
     * formatQuery(query, { format: 'sql', quoteFieldNamesWith: ['[', ']'] })
     * // `[First name] = 'Steve'`
     */
    quoteFieldNamesWith?: string | [string, string];
    /**
     * Validator function for the entire query. Can be the same function passed
     * as `validator` prop to `<QueryBuilder />`.
     */
    validator?: QueryValidator;
    /**
     * This can be the same Field[] passed to <QueryBuilder />, but really
     * all you need to provide is the name and validator for each field.
     */
    fields?: (Pick<Field, 'name' | 'validator'> & Record<string, any>)[];
    /**
     * This string will be inserted in place of invalid groups for non-JSON formats.
     * Defaults to '(1 = 1)' for "sql"/"parameterized"/"parameterized_named",
     * '$and:[{$expr:true}]' for "mongodb".
     */
    fallbackExpression?: string;
    /**
     * This string will be placed in front of named parameters (aka bind variables)
     * when using the "parameterized_named" export format. Default is ":".
     */
    paramPrefix?: string;
    /**
     * Maintains the parameter prefix in the `params` object keys when using the
     * "parameterized_named" export format. Recommended when using SQLite.
     *
     * @default false
     *
     * @example
     * console.log(formatQuery(query, {
     *   format: "parameterized_named",
     *   paramPrefix: "$",
     *   paramsKeepPrefix: true
     * }).params)
     * // { $firstName: "Stev" }
     * // Default (`paramsKeepPrefix` is `false`):
     * // { firstName: "Stev" }
     */
    paramsKeepPrefix?: boolean;
    /**
     * Renders values as either `number`-types or unquoted strings, as
     * appropriate and when possible. Each `string`-type value is passed
     * to `parseFloat` to determine if it can be represented as a plain
     * numeric value.
     */
    parseNumbers?: boolean;
    /**
     * Any rules where the field is equal to this value will be ignored.
     *
     * @default '~'
     */
    placeholderFieldName?: string;
    /**
     * Any rules where the operator is equal to this value will be ignored.
     *
     * @default '~'
     */
    placeholderOperatorName?: string;
}
type ValueProcessorOptions = Pick<FormatQueryOptions, 'parseNumbers' | 'quoteFieldNamesWith'> & {
    escapeQuotes?: boolean;
};
type ValueProcessorByRule = (rule: RuleType, options?: ValueProcessorOptions) => string;
type ValueProcessorLegacy = (field: string, operator: string, value: any, valueSource?: ValueSource) => string;
type ValueProcessor = ValueProcessorLegacy;
type RuleProcessor = (rule: RuleType, options?: ValueProcessorOptions) => any;
interface ParameterizedSQL {
    sql: string;
    params: any[];
}
interface ParameterizedNamedSQL {
    sql: string;
    params: Record<string, any>;
}
interface RQBJsonLogicStartsWith {
    startsWith: [RQBJsonLogic, RQBJsonLogic, ...RQBJsonLogic[]];
}
interface RQBJsonLogicEndsWith {
    endsWith: [RQBJsonLogic, RQBJsonLogic, ...RQBJsonLogic[]];
}
type RQBJsonLogicVar = {
    var: string;
};
type RQBJsonLogic = RulesLogic<RQBJsonLogicStartsWith | RQBJsonLogicEndsWith>;
interface ParserCommonOptions {
    fields?: OptionList<Field> | Record<string, Field>;
    getValueSources?: (field: string, operator: string) => ValueSources;
    listsAsArrays?: boolean;
    independentCombinators?: boolean;
}
interface ParseSQLOptions extends ParserCommonOptions {
    paramPrefix?: string;
    params?: any[] | Record<string, any>;
}
type ParseCELOptions = ParserCommonOptions;
interface ParseJsonLogicOptions extends ParserCommonOptions {
    jsonLogicOperations?: Record<string, (value: any) => RuleType | RuleGroupTypeAny>;
}
type ParseMongoDbOptions = ParserCommonOptions;

interface ActionProps extends CommonSubComponentProps {
    label?: string;
    handleOnClick(e: MouseEvent): void;
    disabledTranslation?: TranslationWithLabel;
    ruleOrGroup: RuleGroupTypeAny | RuleType;
}
interface ActionWithRulesProps extends ActionProps {
    /**
     * Rules already present for this group
     */
    rules?: RuleOrGroupArray;
}
interface ActionWithRulesAndAddersProps extends ActionWithRulesProps {
    /**
     * Triggers the addition of a new rule or group. The second parameter will
     * be forwarded to the `onAddRule` or `onAddGroup` callback, appropriately.
     */
    handleOnClick(e: MouseEvent, context?: any): void;
}
interface InlineCombinatorProps extends CombinatorSelectorProps {
    component: Schema['controls']['combinatorSelector'];
    independentCombinators?: boolean;
}
interface ValueEditorProps<F extends Field = Field, O extends string = string> extends SelectorOrEditorProps, CommonRuleSubComponentProps {
    field: F['name'];
    operator: O;
    value?: any;
    valueSource: ValueSource;
    fieldData: F;
    type?: ValueEditorType;
    inputType?: string | null;
    values?: any[];
    listsAsArrays?: boolean;
    parseNumbers?: ParseNumbersMethod;
    separator?: ReactNode;
    selectorComponent?: ComponentType<ValueSelectorProps>;
    /**
     * Only pass `true` if the `useValueEditor` hook has already run
     * in a wrapper component. See compatibility packages.
     */
    skipHook?: boolean;
}
interface Controls {
    addGroupAction: ComponentType<ActionWithRulesAndAddersProps>;
    addRuleAction: ComponentType<ActionWithRulesAndAddersProps>;
    cloneGroupAction: ComponentType<ActionWithRulesProps>;
    cloneRuleAction: ComponentType<ActionProps>;
    combinatorSelector: ComponentType<CombinatorSelectorProps>;
    inlineCombinator: ComponentType<InlineCombinatorProps>;
    dragHandle: ForwardRefExoticComponent<DragHandleProps & RefAttributes<any>>;
    fieldSelector: ComponentType<FieldSelectorProps>;
    notToggle: ComponentType<NotToggleProps>;
    operatorSelector: ComponentType<OperatorSelectorProps>;
    lockRuleAction: ComponentType<ActionWithRulesProps>;
    lockGroupAction: ComponentType<ActionWithRulesProps>;
    removeGroupAction: ComponentType<ActionWithRulesProps>;
    removeRuleAction: ComponentType<ActionProps>;
    rule: ComponentType<RuleProps>;
    ruleGroup: ComponentType<RuleGroupProps>;
    valueEditor: ComponentType<ValueEditorProps>;
    valueSourceSelector: ComponentType<ValueSourceSelectorProps>;
}
interface Schema {
    fields: OptionList<Field>;
    fieldMap: Record<string, Field>;
    classNames: Classnames;
    combinators: OptionList<Combinator>;
    controls: Controls;
    createRule(): RuleType;
    createRuleGroup(): RuleGroupTypeAny;
    getOperators(field: string): OptionList<Operator>;
    getValueEditorType(field: string, operator: string): ValueEditorType;
    getValueEditorSeparator(field: string, operator: string): ReactNode;
    getValueSources(field: string, operator: string): ValueSources;
    getInputType(field: string, operator: string): string | null;
    getValues(field: string, operator: string): OptionList;
    getRuleClassname(rule: RuleType): Classname;
    getRuleGroupClassname(ruleGroup: RuleGroupTypeAny): Classname;
    showCombinatorsBetweenRules: boolean;
    showNotToggle: boolean;
    showCloneButtons: boolean;
    showLockButtons: boolean;
    autoSelectField: boolean;
    autoSelectOperator: boolean;
    addRuleToNewGroups: boolean;
    enableDragAndDrop: boolean;
    validationMap: ValidationMap;
    independentCombinators: boolean;
    listsAsArrays: boolean;
    parseNumbers: ParseNumbersMethod;
    disabledPaths: number[][];
}
interface CommonRuleAndGroupProps {
    id?: string;
    path: number[];
    parentDisabled?: boolean;
    translations: Translations;
    schema: Schema;
    actions: QueryActions;
    disabled?: boolean;
    context?: any;
}
interface UseRuleGroupDnD {
    isDragging: boolean;
    dragMonitorId: string | symbol;
    isOver: boolean;
    dropMonitorId: string | symbol;
    previewRef: Ref<HTMLDivElement>;
    dragRef: Ref<HTMLSpanElement>;
    dropRef: Ref<HTMLDivElement>;
    dropEffect?: DropEffect;
}
interface RuleGroupProps extends CommonRuleAndGroupProps, Partial<UseRuleGroupDnD> {
    ruleGroup: RuleGroupTypeAny;
    /**
     * @deprecated Use the `combinator` property of the `ruleGroup` prop instead
     */
    combinator?: string;
    /**
     * @deprecated Use the `rules` property of the `ruleGroup` prop instead
     */
    rules?: RuleOrGroupArray;
    /**
     * @deprecated Use the `not` property of the `ruleGroup` prop instead
     */
    not?: boolean;
}
interface UseRuleDnD {
    isDragging: boolean;
    dragMonitorId: string | symbol;
    isOver: boolean;
    dropMonitorId: string | symbol;
    dragRef: Ref<HTMLSpanElement>;
    dndRef: Ref<HTMLDivElement>;
    dropEffect?: DropEffect;
}
interface RuleProps extends CommonRuleAndGroupProps, Partial<UseRuleDnD> {
    rule: RuleType;
    /**
     * @deprecated Use the `field` property of the `rule` prop instead
     */
    field?: string;
    /**
     * @deprecated Use the `operator` property of the `rule` prop instead
     */
    operator?: string;
    /**
     * @deprecated Use the `value` property of the `rule` prop instead
     */
    value?: any;
    /**
     * @deprecated Use the `valueSource` property of the `rule` prop instead
     */
    valueSource?: ValueSource;
}
interface QueryBuilderContextProps {
    /**
     * Define replacement components.
     */
    controlElements?: Partial<Controls>;
    /**
     * Default is `true`. Set to `false` to avoid calling the onQueryChange
     * callback when the component mounts.
     */
    enableMountQueryChange?: boolean;
    /**
     * This can be used to assign specific CSS classes to various controls
     * that are created by the `<QueryBuilder />`.
     */
    controlClassnames?: Partial<Classnames>;
    /**
     * This can be used to override translatable texts applied to various
     * controls that are created by the `<QueryBuilder />`.
     */
    translations?: Partial<Translations>;
    /**
     * Enables drag-and-drop features
     */
    enableDragAndDrop?: boolean;
    /**
     * Enables debug logging for QueryBuilder and React DnD
     */
    debugMode?: boolean;
}
type QueryBuilderContextProviderProps = QueryBuilderContextProps & {
    children?: ReactNode;
};
type QueryBuilderContextProvider<ExtraProps extends object = Record<string, any>> = ComponentType<QueryBuilderContextProviderProps & ExtraProps>;
type QueryBuilderPropsBase<RG extends RuleGroupType | RuleGroupTypeIC> = (RG extends {
    combinator: string;
} ? {
    independentCombinators?: false;
} : {
    /**
     * Allows independent and/or configuration between rules
     */
    independentCombinators: true;
}) & QueryBuilderContextProps & {
    /**
     * When `debugMode` is `true`, each log object will be passed to
     * this function (otherwise `console.log` is used)
     */
    onLog?(obj: any): void;
    /**
     * The array of fields that should be used. Each field should be an object
     * with {name: String, label: String}
     */
    fields?: OptionList<Field> | Record<string, Field>;
    /**
     * The array of operators that should be used.
     * @default
     * [
     *   { name: '=', label: '=' },
     *   { name: '!=', label: '!=' },
     *   { name: '<', label: '<' },
     *   { name: '>', label: '>' },
     *   { name: '<=', label: '<=' },
     *   { name: '>=', label: '>=' },
     *   { name: 'contains', label: 'contains' },
     *   { name: 'beginsWith', label: 'begins with' },
     *   { name: 'endsWith', label: 'ends with' },
     *   { name: 'doesNotContain', label: 'does not contain' },
     *   { name: 'doesNotBeginWith', label: 'does not begin with' },
     *   { name: 'doesNotEndWith', label: 'does not end with' },
     *   { name: 'null', label: 'is null' },
     *   { name: 'notNull', label: 'is not null' },
     *   { name: 'in', label: 'in' },
     *   { name: 'notIn', label: 'not in' },
     *   { name: 'between', label: 'between' },
     *   { name: 'notBetween', label: 'not between' },
     * ]
     */
    operators?: OptionList<Operator>;
    /**
     * The array of combinators that should be used for RuleGroups.
     * @default
     * [
     *     {name: 'and', label: 'AND'},
     *     {name: 'or', label: 'OR'},
     * ]
     */
    combinators?: OptionList<Combinator>;
    /**
     * The default field for new rules. This can be a string identifying the
     * default field, or a function that returns a field name.
     */
    getDefaultField?: string | ((fieldsData: OptionList<Field>) => string);
    /**
     * The default operator for new rules. This can be a string matching
     * an operator name or a function that returns an operator name.
     */
    getDefaultOperator?: string | ((field: string) => string);
    /**
     * Returns the default value for new rules.
     */
    getDefaultValue?(rule: RuleType): any;
    /**
     * This function should return the list of allowed
     * operators for the given field. If `null` is returned, the default
     * operators are used.
     */
    getOperators?(field: string): OptionList<Operator> | null;
    /**
     * This function should return the type of `ValueEditor`
     * for the given field and operator.
     */
    getValueEditorType?(field: string, operator: string): ValueEditorType;
    /**
     * This function should return the separator element for a given field
     * and operator. The element can be any valid React element, including
     * a bare string (e.g. "and" or "to") or an HTML element like `<span />`.
     * It will be placed in between value editors when multiple are rendered,
     * e.g. when the operator is "between".
     */
    getValueEditorSeparator?(field: string, operator: string): ReactNode;
    /**
     * This function should return the list of valid
     * value sources for a given field and operator. The return value must
     * be an array that includes at least one of the valid value source:
     * "value", "field", or both.
     */
    getValueSources?: (field: string, operator: string) => ValueSources;
    /**
     * This function should return the `type` of `<input />`
     * for the given field and operator (only applicable when
     * `getValueEditorType` returns `"text"` or a falsy value). If no
     * function is provided, `"text"` is used as the default.
     */
    getInputType?(field: string, operator: string): string | null;
    /**
     * This function should return the list of allowed
     * values for the given field and operator (only applicable when
     * `getValueEditorType` returns `"select"` or `"radio"`). If no
     * function is provided, an empty array is used as the default.
     */
    getValues?(field: string, operator: string): OptionList;
    /**
     * The result of this function will be applied as a className on the given rule.
     */
    getRuleClassname?(rule: RuleType): Classname;
    /**
     * The result of this function will be applied as a className on the given group.
     */
    getRuleGroupClassname?(ruleGroup: RG): Classname;
    /**
     * This callback is invoked before a new rule is added. The function should either manipulate
     * the rule and return it, or return `false` to cancel the addition of the rule.
     */
    onAddRule?(rule: RuleType, parentPath: number[], query: RG, context?: any): RuleType | false;
    /**
     * This callback is invoked before a new group is added. The function should either manipulate
     * the group and return it, or return `false` to cancel the addition of the group.
     */
    onAddGroup?(ruleGroup: RG, parentPath: number[], query: RG, context?: any): RG | false;
    /**
     * This callback is invoked before a rule or group is removed. The function should return
     * `true` if the rule or group should be removed or `false` if it should not be removed.
     */
    onRemove?(ruleOrGroup: RuleType | RG, path: number[], query: RG, context?: any): boolean;
    /**
     * This is a callback function that is invoked anytime the query configuration changes.
     */
    onQueryChange?(query: RG): void;
    /**
     * Show the combinators between rules and rule groups instead of at the top of rule groups.
     */
    showCombinatorsBetweenRules?: boolean;
    /**
     * Show the "not" toggle for rule groups.
     */
    showNotToggle?: boolean;
    /**
     * Show the "Clone rule" and "Clone group" buttons
     */
    showCloneButtons?: boolean;
    /**
     * Show the "Lock rule" and "Lock group" buttons
     */
    showLockButtons?: boolean;
    /**
     * Reset the operator and value components when the `field` changes.
     */
    resetOnFieldChange?: boolean;
    /**
     * Reset the value component when the `operator` changes.
     */
    resetOnOperatorChange?: boolean;
    /**
     * Select the first field in the array automatically
     */
    autoSelectField?: boolean;
    /**
     * Select the first operator in the array automatically
     */
    autoSelectOperator?: boolean;
    /**
     * Adds a new default rule automatically to each new group
     */
    addRuleToNewGroups?: boolean;
    /**
     * Store list-type values as native arrays instead of comma-separated strings
     */
    listsAsArrays?: boolean;
    /**
     * Store values as numbers if possible.
     */
    parseNumbers?: ParseNumbersMethod;
    /**
     * Disables the entire query builder if true, or the rules and groups at
     * the specified paths (as well as all child rules/groups and subcomponents)
     * if an array of paths is provided. If the root path is specified (`disabled={[[]]}`),
     * no changes to the query are allowed.
     *
     * @deprecated This prop may be removed in a future major version. Use the `disabled`
     * property on rules and groups within the `query`/`defaultQuery` instead.
     */
    disabled?: boolean | number[][];
    /**
     * Query validation function
     */
    validator?: QueryValidator;
    /**
     * ID generator function.
     *
     * @default () => crypto.randomUUID()
     */
    idGenerator?: () => string;
    /**
     * Container for custom props that are passed to all components
     */
    context?: any;
};
/**
 * Props for the `<QueryBuilder />` component. Note that if `independentCombinators`
 * is `true`, then `query` and `defaultQuery` must be of type `RuleGroupTypeIC`. Otherwise,
 * they must be of type `RuleGroupType`. Only one of `query` or `defaultQuery` can be
 * provided. If `query` is present, then `defaultQuery` must be undefined, and vice versa.
 * If rendered initially with a `query` prop, then `query` must always be defined in every
 * subsequent render or errors will be logged to the console (in "development" mode only).
 */
type QueryBuilderProps<RG extends RuleGroupType | RuleGroupTypeIC = RuleGroupType> = (QueryBuilderPropsBase<RG> & {
    /**
     * Initial query object for uncontrolled components
     */
    defaultQuery?: RG;
    query?: never;
}) | (QueryBuilderPropsBase<RG> & {
    defaultQuery?: never;
    /**
     * Query object for controlled components
     */
    query?: RG;
});

interface CommonSubComponentProps {
    /**
     * CSS classNames to be applied
     *
     * This is `string` and not `Classname` because the Rule and RuleGroup
     * components run clsx() to produce the className that gets passed to
     * each subcomponent.
     */
    className?: string;
    /**
     * Path to this sub-component's Rule or RuleGroup
     */
    path: number[];
    /**
     * The level of the current group
     */
    level: number;
    /**
     * The title for this control
     */
    title?: string;
    /**
     * Disables the control
     */
    disabled?: boolean;
    /**
     * Container for custom props that are passed to all components
     */
    context?: any;
    /**
     * Validation result of the parent component
     */
    validation?: boolean | ValidationResult;
    /**
     * Test ID for this component
     */
    testID?: string;
    /**
     * All subcomponents receive the schema as a prop
     */
    schema: Schema;
}
interface SelectorOrEditorProps extends CommonSubComponentProps {
    value?: string;
    handleOnChange(value: any): void;
}
interface CommonRuleSubComponentProps {
    rule: RuleType;
}
interface BaseSelectorProps<OptType extends Option = Option> extends SelectorOrEditorProps {
    options: OptionList<OptType>;
}
interface ValueSelectorProps<OptType extends Option = Option> extends BaseSelectorProps<OptType> {
    multiple?: boolean;
    listsAsArrays?: boolean;
}
interface NotToggleProps extends CommonSubComponentProps {
    checked?: boolean;
    handleOnChange(checked: boolean): void;
    label?: string;
    ruleGroup: RuleGroupTypeAny;
}
interface CombinatorSelectorProps extends BaseSelectorProps<Combinator> {
    rules?: RuleOrGroupArray;
}
interface FieldSelectorProps extends BaseSelectorProps<Field>, CommonRuleSubComponentProps {
    operator?: string;
}
interface OperatorSelectorProps extends BaseSelectorProps<Operator>, CommonRuleSubComponentProps {
    field: string;
    fieldData: Field;
}
type ValueSourceOption = Option<ValueSource>;
interface ValueSourceSelectorProps extends BaseSelectorProps<ValueSourceOption>, CommonRuleSubComponentProps {
    field: string;
    fieldData: Field;
}
type VersatileSelectorProps = ValueSelectorProps & Partial<FieldSelectorProps> & Partial<OperatorSelectorProps> & Partial<CombinatorSelectorProps>;
interface DragHandleProps extends CommonSubComponentProps {
    label?: string;
    ruleOrGroup: RuleGroupTypeAny | RuleType;
}
interface Classnames {
    /**
     * Root `<div>` element
     */
    queryBuilder: Classname;
    /**
     * `<div>` containing the RuleGroup
     */
    ruleGroup: Classname;
    /**
     * `<div>` containing the RuleGroup header controls
     */
    header: Classname;
    /**
     * `<div>` containing the RuleGroup child rules/groups
     */
    body: Classname;
    /**
     * `<select>` control for combinators
     */
    combinators: Classname;
    /**
     * `<button>` to add a Rule
     */
    addRule: Classname;
    /**
     * `<button>` to add a RuleGroup
     */
    addGroup: Classname;
    /**
     * `<button>` to clone a Rule
     */
    cloneRule: Classname;
    /**
     * `<button>` to clone a RuleGroup
     */
    cloneGroup: Classname;
    /**
     * `<button>` to remove a RuleGroup
     */
    removeGroup: Classname;
    /**
     * `<div>` containing the Rule
     */
    rule: Classname;
    /**
     * `<select>` control for fields
     */
    fields: Classname;
    /**
     * `<select>` control for operators
     */
    operators: Classname;
    /**
     * `<input>` for the field value
     */
    value: Classname;
    /**
     * `<button>` to remove a Rule
     */
    removeRule: Classname;
    /**
     * `<label>` on the "not" toggle
     */
    notToggle: Classname;
    /**
     * `<span>` handle for dragging rules/groups
     */
    dragHandle: Classname;
    /**
     * `<button>` to lock (i.e. disable) a Rule
     */
    lockRule: Classname;
    /**
     * `<button>` to lock (i.e. disable) a RuleGroup
     */
    lockGroup: Classname;
    /**
     * Value source selector
     */
    valueSource: Classname;
}
interface QueryActions {
    onGroupAdd(group: RuleGroupTypeAny, parentPath: number[], context?: any): void;
    onGroupRemove(path: number[]): void;
    onPropChange(prop: Exclude<keyof RuleType | keyof RuleGroupType, 'id' | 'path'>, value: any, path: number[]): void;
    onRuleAdd(rule: RuleType, parentPath: number[], context?: any): void;
    onRuleRemove(path: number[]): void;
    moveRule(oldPath: number[], newPath: number[], clone?: boolean): void;
}
interface Translation {
    title?: string;
}
interface TranslationWithLabel extends Translation {
    label?: string;
}
interface TranslationWithPlaceholders extends Translation {
    /**
     * Value for the placeholder field option if autoSelectField is false,
     * or the placeholder operator option if autoSelectOperator is false.
     */
    placeholderName?: string;
    /**
     * Label for the placeholder field option if autoSelectField is false,
     * or the placeholder operator option if autoSelectOperator is false.
     */
    placeholderLabel?: string;
    /**
     * Label for the placeholder field optgroup if autoSelectField is false,
     * or the placeholder operator optgroup if autoSelectOperator is false.
     */
    placeholderGroupLabel?: string;
}
interface Translations {
    fields: TranslationWithPlaceholders;
    operators: TranslationWithPlaceholders;
    value: Translation;
    removeRule: TranslationWithLabel;
    removeGroup: TranslationWithLabel;
    addRule: TranslationWithLabel;
    addGroup: TranslationWithLabel;
    combinators: Translation;
    notToggle: TranslationWithLabel;
    cloneRule: TranslationWithLabel;
    cloneRuleGroup: TranslationWithLabel;
    dragHandle: TranslationWithLabel;
    lockRule: TranslationWithLabel;
    lockGroup: TranslationWithLabel;
    lockRuleDisabled: TranslationWithLabel;
    lockGroupDisabled: TranslationWithLabel;
    valueSourceSelector: Translation;
}
type TranslationsFull = {
    [K in keyof Translations]: {
        [T in keyof Translations[K]]-?: string;
    };
};

declare const ActionElement: {
    ({ className, handleOnClick, label, title, disabled, disabledTranslation, testID, }: ActionProps): React.JSX.Element;
    displayName: string;
};

declare const DragHandle: React.ForwardRefExoticComponent<DragHandleProps & React.RefAttributes<HTMLSpanElement>>;

declare const InlineCombinator: {
    ({ component: CombinatorSelectorComponent, independentCombinators: _independentCombinators, ...props }: InlineCombinatorProps): React.JSX.Element;
    displayName: string;
};

declare const NotToggle: {
    ({ className, handleOnChange, title, label, checked, disabled, testID, }: NotToggleProps): React.JSX.Element;
    displayName: string;
};

declare const QueryBuilder: {
    <RG extends RuleGroupType | RuleGroupTypeIC>(props: QueryBuilderProps<RG>): React.JSX.Element;
    displayName: string;
};

declare const QueryBuilderContext: React.Context<QueryBuilderContextProps>;

declare const useQueryBuilder: <RG extends RuleGroupType | RuleGroupTypeIC>(props: QueryBuilderProps<RG>) => {
    actions: QueryActions;
    query: RG;
    queryDisabled: boolean;
    rqbContext: {
        controlClassnames: Classnames;
        controlElements: Controls;
        debugMode: boolean;
        enableDragAndDrop: boolean;
        enableMountQueryChange: boolean;
        translations: TranslationsFull;
    };
    schema: Schema;
    translations: TranslationsFull;
    wrapperClassName: string;
};

declare const useRule: (props: RuleProps) => {
    classNames: {
        dragHandle: string;
        fields: string;
        operators: string;
        valueSource: string;
        value: string;
        cloneRule: string;
        lockRule: string;
        removeRule: string;
    };
    cloneRule: (_event?: any, _context?: any) => void;
    disabled: boolean;
    dndRef: React.Ref<HTMLDivElement>;
    dragMonitorId: string | symbol;
    dragRef: React.Ref<HTMLSpanElement>;
    dropMonitorId: string | symbol;
    fieldData: Field<string, string, string, Option<string>, Option<string>>;
    generateOnChangeHandler: (prop: Exclude<keyof RuleType, 'id' | 'path'>) => (value: any, _context?: any) => void;
    hideValueControls: boolean;
    inputType: string | null;
    operators: OptionList<Operator<string>>;
    outerClassName: string;
    removeRule: (_event?: any, _context?: any) => void;
    rule: RuleType;
    toggleLockRule: (_event?: any, _context?: any) => void;
    validationResult: boolean | ValidationResult;
    valueEditorSeparator: React.ReactNode;
    valueEditorType: ValueEditorType;
    values: Option<string>[] | OptionGroup<Option<string>>[];
    valueSourceOptions: {
        name: "value" | "field";
        label: "value" | "field";
    }[];
    valueSources: ValueSources;
};

declare const useRuleGroup: (props: RuleGroupProps) => {
    addGroup: (_event?: any, context?: any) => void;
    addRule: (_event?: any, context?: any) => void;
    classNames: {
        header: string;
        dragHandle: string;
        combinators: string;
        notToggle: string;
        addRule: string;
        addGroup: string;
        cloneGroup: string;
        lockGroup: string;
        removeGroup: string;
        body: string;
    };
    cloneGroup: (_event?: any, _context?: any) => void;
    combinator: string;
    disabled: boolean;
    dragMonitorId: string | symbol;
    dragRef: React.Ref<HTMLSpanElement>;
    dropMonitorId: string | symbol;
    dropRef: React.Ref<HTMLDivElement>;
    isDragging: boolean;
    isOver: boolean;
    onCombinatorChange: (value: any, _context?: any) => void;
    onGroupAdd: (group: RuleGroupTypeAny, parentPath: number[], context?: any) => void;
    onIndependentCombinatorChange: (value: any, index: number, _context?: any) => void;
    onNotToggleChange: (checked: boolean, _context?: any) => void;
    outerClassName: string;
    parentDisabled: boolean | undefined;
    previewRef: React.Ref<HTMLDivElement>;
    removeGroup: (_event?: any, _context?: any) => void;
    ruleGroup: RuleGroupTypeAny;
    toggleLockGroup: (_event?: any, _context?: any) => void;
    validationClassName: string;
    validationResult: boolean | ValidationResult;
};

interface UseSelectElementChangeHandlerParams {
    onChange: (v: string | string[]) => void;
    multiple?: boolean;
}
/**
 * Returns a memoized change handler for HTML select elements.
 */
declare const useSelectElementChangeHandler: ({ multiple, onChange, }: UseSelectElementChangeHandlerParams) => (e: ChangeEvent<HTMLSelectElement>) => void;

type EventMethod = (event: MouseEvent, context?: any) => void;
type MethodObject<Keys extends string> = {
    [Key in Keys]: EventMethod;
};
declare const useStopEventPropagation: <Keys extends string>(methods: MethodObject<Keys>) => MethodObject<Keys>;

type UseValueEditorParams = Pick<ValueEditorProps, 'handleOnChange' | 'inputType' | 'operator' | 'value' | 'listsAsArrays' | 'type' | 'values' | 'parseNumbers' | 'skipHook'>;
/**
 * This effect is primarily concerned with multi-value editors like date range
 * pickers, editors for 'in' and 'between' operators, etc.
 *
 * @returns The value as an array (`valueAsArray`) and a change handler for
 * series of editors (`multiValueHandler`).
 *
 * **NOTE:** The following logic only applies if `skipHook` is not `true`. To avoid
 * automatically updating the `value`, pass `{ skipHook: true }`.
 *
 * If the `value` is an array and the `operator` is _not_ one of the known multi-value
 * operators ("between", "notBetween", "in", "notIn"), then the `value` will be set to
 * the first element of the array, i.e. `value[0]`.
 *
 * The same thing will happen if `inputType` is "number" and `value` is a string
 * containing a comma, since `<input type="number">` doesn't handle commas.
 *
 * @example
 * // Consider the following rule:
 * `{ field: "f1", operator: "in", value: ["twelve","fourteen"] }`
 * // If `operator` changes to "=", the value will be reset to "twelve".
 *
 * @example
 * // Consider the following rule:
 * `{ field: "f1", operator: "between", value: "12,14" }`
 * // If `operator` changes to "=", the value will be reset to "12".
 */
declare const useValueEditor: ({ handleOnChange, inputType, operator, value, listsAsArrays, parseNumbers, values, type, skipHook, }: UseValueEditorParams) => {
    /**
     * Array of values for when the main value represents a list, e.g. when operator
     * is "between" or "in".
     */
    valueAsArray: any[];
    /**
     * An update handler for a series of value editors, e.g. when operator is "between".
     * Calling this function will update a single element of the value array and leave
     * the rest of the array as is.
     *
     * @param {string} val The new value for the editor
     * @param {number} idx The index of the editor (and the array element to update)
     */
    multiValueHandler: (v: any, i: number) => void;
};

type UseValueSelectorParams = Pick<ValueSelectorProps, 'handleOnChange' | 'listsAsArrays' | 'multiple' | 'value'>;
/**
 * Transforms a value into an array when appropriate and provides
 * a memoized change handler.
 */
declare const useValueSelector: ({ handleOnChange, listsAsArrays, multiple, value, }: UseValueSelectorParams) => {
    /**
     * Memoized change handler for value selectors
     */
    onChange: (v: string | string[]) => void;
    /**
     * The value as provided or, if appropriate, as an array
     */
    val: string | any[] | undefined;
};

declare const Rule: {
    (props: RuleProps): React.JSX.Element;
    displayName: string;
};
declare const RuleComponents: (r: RuleProps & ReturnType<typeof useRule>) => React.JSX.Element;

declare const RuleGroup: {
    (props: RuleGroupProps): React.JSX.Element;
    displayName: string;
};
declare const RuleGroupHeaderComponents: (rg: RuleGroupProps & ReturnType<typeof useRuleGroup>) => React.JSX.Element;
declare const RuleGroupBodyComponents: (rg: RuleGroupProps & ReturnType<typeof useRuleGroup>) => React.JSX.Element;

declare const ValueEditor: {
    ({ operator, value, handleOnChange, title, className, type, inputType, values, listsAsArrays, parseNumbers, fieldData, disabled, separator, skipHook, testID, selectorComponent: SelectorComponent, ...props }: ValueEditorProps): React.JSX.Element | null;
    displayName: string;
};

declare const ValueSelector: {
    ({ className, handleOnChange, options, title, value, multiple, listsAsArrays, disabled, testID, }: ValueSelectorProps): React.JSX.Element;
    displayName: string;
};

declare const defaultControlElements: Controls;

declare const errorDeprecatedRuleGroupProps: string;
declare const errorDeprecatedRuleProps: string;
declare const errorBothQueryDefaultQuery: string;
declare const errorUncontrolledToControlled: string;
declare const errorControlledToUncontrolled: string;
declare const errorEnabledDndWithoutReactDnD: string;

declare const messages_errorBothQueryDefaultQuery: typeof errorBothQueryDefaultQuery;
declare const messages_errorControlledToUncontrolled: typeof errorControlledToUncontrolled;
declare const messages_errorDeprecatedRuleGroupProps: typeof errorDeprecatedRuleGroupProps;
declare const messages_errorDeprecatedRuleProps: typeof errorDeprecatedRuleProps;
declare const messages_errorEnabledDndWithoutReactDnD: typeof errorEnabledDndWithoutReactDnD;
declare const messages_errorUncontrolledToControlled: typeof errorUncontrolledToControlled;
declare namespace messages {
  export {
    messages_errorBothQueryDefaultQuery as errorBothQueryDefaultQuery,
    messages_errorControlledToUncontrolled as errorControlledToUncontrolled,
    messages_errorDeprecatedRuleGroupProps as errorDeprecatedRuleGroupProps,
    messages_errorDeprecatedRuleProps as errorDeprecatedRuleProps,
    messages_errorEnabledDndWithoutReactDnD as errorEnabledDndWithoutReactDnD,
    messages_errorUncontrolledToControlled as errorUncontrolledToControlled,
  };
}

declare const defaultPlaceholderFieldName = "~";
declare const defaultPlaceholderFieldLabel = "------";
declare const defaultPlaceholderFieldGroupLabel = "------";
declare const defaultPlaceholderOperatorName = "~";
declare const defaultPlaceholderOperatorLabel = "------";
declare const defaultPlaceholderOperatorGroupLabel = "------";
declare const defaultJoinChar = ",";
declare const defaultTranslations: TranslationsFull;
declare const defaultOperators: DefaultOperator[];
declare const defaultOperatorNegationMap: Record<DefaultOperatorName, DefaultOperatorName>;
declare const defaultCombinators: DefaultCombinator[];
declare const defaultCombinatorsExtended: DefaultCombinatorExtended[];
declare const standardClassnames: {
    readonly queryBuilder: "queryBuilder";
    readonly ruleGroup: "ruleGroup";
    readonly header: "ruleGroup-header";
    readonly body: "ruleGroup-body";
    readonly combinators: "ruleGroup-combinators";
    readonly addRule: "ruleGroup-addRule";
    readonly addGroup: "ruleGroup-addGroup";
    readonly cloneRule: "rule-cloneRule";
    readonly cloneGroup: "ruleGroup-cloneGroup";
    readonly removeGroup: "ruleGroup-remove";
    readonly notToggle: "ruleGroup-notToggle";
    readonly rule: "rule";
    readonly fields: "rule-fields";
    readonly operators: "rule-operators";
    readonly value: "rule-value";
    readonly removeRule: "rule-remove";
    readonly betweenRules: "betweenRules";
    readonly valid: "queryBuilder-valid";
    readonly invalid: "queryBuilder-invalid";
    readonly dndDragging: "dndDragging";
    readonly dndOver: "dndOver";
    readonly dndCopy: "dndCopy";
    readonly dragHandle: "queryBuilder-dragHandle";
    readonly disabled: "queryBuilder-disabled";
    readonly lockRule: "rule-lock";
    readonly lockGroup: "ruleGroup-lock";
    readonly valueSource: "rule-valueSource";
    readonly valueListItem: "rule-value-list-item";
    readonly branches: "queryBuilder-branches";
};
declare const defaultControlClassnames: Classnames;
declare const groupInvalidReasons: {
    readonly empty: "empty";
    readonly invalidCombinator: "invalid combinator";
    readonly invalidIndependentCombinators: "invalid independent combinators";
};
declare const TestID: {
    readonly rule: "rule";
    readonly ruleGroup: "rule-group";
    readonly inlineCombinator: "inline-combinator";
    readonly addGroup: "add-group";
    readonly removeGroup: "remove-group";
    readonly cloneGroup: "clone-group";
    readonly cloneRule: "clone-rule";
    readonly addRule: "add-rule";
    readonly removeRule: "remove-rule";
    readonly combinators: "combinators";
    readonly fields: "fields";
    readonly operators: "operators";
    readonly valueEditor: "value-editor";
    readonly notToggle: "not-toggle";
    readonly dragHandle: "drag-handle";
    readonly lockRule: "lock-rule";
    readonly lockGroup: "lock-group";
    readonly valueSourceSelector: "value-source-selector";
};
declare const LogType: {
    readonly parentPathDisabled: "action aborted: parent path disabled";
    readonly pathDisabled: "action aborted: path is disabled";
    readonly queryUpdate: "query updated";
    readonly onAddRuleFalse: "onAddRule callback returned false";
    readonly onAddGroupFalse: "onAddGroup callback returned false";
    readonly onRemoveFalse: "onRemove callback returned false";
    readonly add: "rule or group added";
    readonly remove: "rule or group removed";
    readonly update: "rule or group updated";
    readonly move: "rule or group moved";
};

/**
 * Splits a string by a given character (default ','). Escaped characters (characters
 * preceded by a backslash) will not apply to the split, and the backslash will be
 * removed in the array element. Inverse of `joinWith`.
 *
 * @example
 * splitBy('this\\,\\,that,,the other,,,\\,')
 * // or
 * splitBy('this\\,\\,that,,the other,,,\\,', ',')
 * // would return
 * ['this,,that', '', 'the other', '', '', ',']
 */
declare const splitBy: (str?: string, splitChar?: string) => string[];
/**
 * Joins an array of strings using the given character (default ','). When the given
 * character appears in an array element, a backslash will be added just before it to
 * distinguish it from the join character. Inverse of `splitBy`.
 *
 * @example
 * joinWith(['this,,that', '', 'the other', '', '', ','])
 * // would return
 * 'this\\,\\,that,,the other,,,\\,'
 */
declare const joinWith: (strArr: any[], joinChar?: string) => string;
/**
 * Trims the value if it is a string. Otherwise returns value as-is.
 */
declare const trimIfString: (val: any) => any;
/**
 * Splits strings by comma and trims each element. Arrays are returned as-is but
 * any string elements are trimmed.
 */
declare const toArray: (v: any) => any[];
declare const nullFreeArray: <T>(arr: T[]) => arr is Exclude<T, null>[];

declare const convertFromIC: <RG extends RuleGroupType = RuleGroupType>(rg: RuleGroupTypeIC) => RG;
declare const convertToIC: <RGIC extends RuleGroupTypeIC = RuleGroupTypeIC>(rg: RuleGroupType) => RGIC;
declare function convertQuery(query: RuleGroupType): RuleGroupTypeIC;
declare function convertQuery(query: RuleGroupTypeIC): RuleGroupType;

/**
 * This is an example validation function you can pass to QueryBuilder in the
 * `validator` prop. It assumes that you want to validate groups, and has a no-op
 * for validating rules which you should replace with your own implementation.
 */
declare const defaultValidator: QueryValidator;

declare const filterFieldsByComparator: (field: Field, fields: OptionList<Field>, operator: string) => Field<string, string, string, Option<string>, Option<string>>[] | {
    options: Field<string, string, string, Option<string>, Option<string>>[];
    label: string;
}[];

declare const defaultRuleProcessorCEL: RuleProcessor;

declare const defaultRuleProcessorMongoDB: RuleProcessor;

declare const defaultRuleProcessorSpEL: RuleProcessor;

declare const defaultValueProcessorByRule: ValueProcessorByRule;

declare const defaultRuleProcessorJsonLogic: RuleProcessor;

type DefaultRuleProcessorSqlParams = ValueProcessorOptions & {
    valueProcessor?: ValueProcessorByRule;
    quoteFieldNamesWith?: string | [string, string];
};
declare const defaultRuleProcessorSQL: (rule: RuleType, { parseNumbers, escapeQuotes, quoteFieldNamesWith, valueProcessor, }?: DefaultRuleProcessorSqlParams) => string;

/**
 * Generates a formatted (indented two spaces) JSON string from a query object.
 */
declare function formatQuery(ruleGroup: RuleGroupTypeAny): string;
/**
 * Generates a {@link ParameterizedSQL} object from a query object.
 */
declare function formatQuery(ruleGroup: RuleGroupTypeAny, options: 'parameterized' | (Omit<FormatQueryOptions, 'format'> & {
    format: 'parameterized';
})): ParameterizedSQL;
/**
 * Generates a {@link ParameterizedNamedSQL} object from a query object.
 */
declare function formatQuery(ruleGroup: RuleGroupTypeAny, options: 'parameterized_named' | (Omit<FormatQueryOptions, 'format'> & {
    format: 'parameterized_named';
})): ParameterizedNamedSQL;
/**
 * Generates a {@link JsonLogic} object from a query object.
 */
declare function formatQuery(ruleGroup: RuleGroupTypeAny, options: 'jsonlogic' | (Omit<FormatQueryOptions, 'format'> & {
    format: 'jsonlogic';
})): RQBJsonLogic;
/**
 * Generates a formatted (indented two spaces) JSON string from a query object.
 */
declare function formatQuery(ruleGroup: RuleGroupTypeAny, options: Omit<FormatQueryOptions, 'format'>): string;
/**
 * Generates a query string in the requested format.
 */
declare function formatQuery(ruleGroup: RuleGroupTypeAny, options: Exclude<ExportFormat, 'parameterized' | 'parameterized_named' | 'jsonlogic'>): string;
/**
 * Generates a query string in the requested format.
 */
declare function formatQuery(ruleGroup: RuleGroupTypeAny, options: Omit<FormatQueryOptions, 'format'> & {
    format: Exclude<ExportFormat, 'parameterized' | 'parameterized_named' | 'jsonlogic'>;
}): string;

/**
 * Register these operators with jsonLogic before applying the
 * result of formatQuery(query, 'jsonlogic').
 *
 * @example
 * ```
 * for (const [op, func] of Object.entries(jsonLogicAdditionalOperators)) {
 *   jsonLogic.add_operation(op, func);
 * }
 * jsonLogic.apply({ "startsWith": [{ "var": "firstName" }, "Stev"] }, data);
 * ```
 */
declare const jsonLogicAdditionalOperators: Record<'startsWith' | 'endsWith', (...args: any[]) => boolean>;

declare const defaultValueProcessor: ValueProcessorLegacy;
/**
 * @deprecated Prefer `defaultRuleProcessorMongoDB`.
 */
declare const defaultMongoDBValueProcessor: ValueProcessorLegacy;
/**
 * @deprecated Prefer `defaultRuleProcessorCEL`.
 */
declare const defaultCELValueProcessor: ValueProcessorLegacy;
/**
 * @deprecated Prefer `defaultRuleProcessorSpEL`.
 */
declare const defaultSpELValueProcessor: ValueProcessorLegacy;

/**
 * @deprecated Renamed to "defaultRuleProcessorCEL".
 */
declare const defaultValueProcessorCELByRule: RuleProcessor;
/**
 * @deprecated Renamed to "defaultRuleProcessorMongoDB".
 */
declare const defaultValueProcessorMongoDBByRule: RuleProcessor;
/**
 * @deprecated Renamed to "defaultRuleProcessorSpEL".
 */
declare const defaultValueProcessorSpELByRule: RuleProcessor;

/**
 * Generates a valid v4 UUID, i.e. matching this regex:
 * ```
 * /^[0-9A-F]{8}-[0-9A-F]{4}-[4][0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i
 * ```
 * @returns Valid v4 UUID
 */
declare let generateID: () => string;

type GetCompatContextProviderProps = Pick<QueryBuilderContextProps, 'controlClassnames' | 'controlElements'> & {
    key: string;
};
declare const getCompatContextProvider: ({ key, controlClassnames: compatClassnames, controlElements: compatElements, }: GetCompatContextProviderProps) => QueryBuilderContextProvider;

declare const getValidationClassNames: (validationResult: boolean | ValidationResult) => "" | "queryBuilder-valid" | "queryBuilder-invalid";

declare const getValueSourcesUtil: (fieldData: Field, operator: string, getValueSources?: ((field: string, operator: string) => ValueSources) | undefined) => ValueSources;

interface UseControlledOrUncontrolledParams {
    defaultQuery?: RuleGroupTypeAny;
    queryProp?: RuleGroupTypeAny;
    isFirstRender: boolean;
}
/**
 * Log errors when the component changes from controlled to uncontrolled,
 * vice versa, or both query and defaultQuery are provided.
 */
declare const useControlledOrUncontrolled: ({ defaultQuery, queryProp, isFirstRender, }: UseControlledOrUncontrolledParams) => void;

declare const useDeprecatedProps: (type: 'rule' | 'ruleGroup', newPropPresent: boolean) => void;

type UseMergedContextProps = WithRequired<QueryBuilderContextProps, 'translations'>;
/**
 * Inherit context, but props take precedence
 */
declare const useMergedContext: (props: UseMergedContextProps) => {
    controlClassnames: Classnames;
    controlElements: Controls;
    debugMode: boolean;
    enableDragAndDrop: boolean;
    enableMountQueryChange: boolean;
    translations: TranslationsFull;
};

declare const usePreferProp: (def: boolean, prop?: boolean, context?: boolean) => boolean;

declare const usePrevious: <T>(value: T) => T | null;

declare const useReactDndWarning: (enableDragAndDrop: boolean, dndRefs: boolean) => void;

/**
 * Determines if this is either a RuleGroupType or RuleGroupTypeIC.
 * `'rules' in query` can be used as an alternative.
 */
declare const isRuleGroup: (rg: any) => rg is RuleGroupTypeAny;
declare const isRuleGroupType: (rg: RuleType | RuleGroupTypeAny) => rg is RuleGroupType;
declare const isRuleGroupTypeIC: (rg: RuleType | RuleGroupTypeAny) => rg is RuleGroupTypeIC;

declare const isValidationResult: (vr?: ValidationResult) => vr is ValidationResult;
declare const isRuleOrGroupValid: (rg: RuleType | RuleGroupTypeAny, validationResult?: boolean | ValidationResult, validator?: RuleValidator) => boolean;

declare const mergeClassnames: (...args: (Partial<Classnames> | undefined)[]) => Classnames;

declare const numericRegex: RegExp;
declare const isPojo: (obj: any) => obj is Record<string, any>;

/**
 * A strongly-typed version of `Object.keys()`.
 *
 * [Original source](https://github.com/sindresorhus/ts-extras/blob/44f57392c5f027268330771996c4fdf9260b22d6/source/object-keys.ts)
 */
declare const objectKeys: <Type extends object>(value: Type) => Exclude<keyof Type, symbol>[];
/**
 * A strongly-typed version of `Object.entries()`.
 *
 * [Original source](https://github.com/sindresorhus/ts-extras/blob/44f57392c5f027268330771996c4fdf9260b22d6/source/object-entries.ts)
 */
declare const objectEntries: <Type extends Record<PropertyKey, unknown>>(value: Type) => [Exclude<keyof Type, symbol>, Type[Exclude<keyof Type, symbol>]][];

declare const isOptionGroupArray: (arr: Field['values']) => arr is OptionGroup[];
declare const getOption: <OptType extends Option<string> = Option<string>>(arr: OptionList<OptType>, name: string) => OptType | undefined;
declare const getFirstOption: (arr?: OptionList) => string | null;

/**
 * Converts a CEL string expression into a query suitable for
 * the QueryBuilder component's `query` or `defaultQuery` props.
 */
declare function parseCEL(cel: string): DefaultRuleGroupType;
declare function parseCEL(cel: string, options: Omit<ParseCELOptions, 'independentCombinators'> & {
    independentCombinators?: false;
}): DefaultRuleGroupType;
declare function parseCEL(cel: string, options: Omit<ParseCELOptions, 'independentCombinators'> & {
    independentCombinators: true;
}): DefaultRuleGroupTypeIC;

/**
 * Converts a JsonLogic object into a query suitable for
 * the QueryBuilder component's `query` or `defaultQuery` props.
 */
declare function parseJsonLogic(rqbJsonLogic: string | RQBJsonLogic): DefaultRuleGroupType;
declare function parseJsonLogic(rqbJsonLogic: string | RQBJsonLogic, options: Omit<ParseJsonLogicOptions, 'independentCombinators'> & {
    independentCombinators?: false;
}): DefaultRuleGroupType;
declare function parseJsonLogic(rqbJsonLogic: string | RQBJsonLogic, options: Omit<ParseJsonLogicOptions, 'independentCombinators'> & {
    independentCombinators: true;
}): DefaultRuleGroupTypeIC;

/**
 * Converts a MongoDB query object or parseable string into a query suitable for
 * the QueryBuilder component's `query` or `defaultQuery` props.
 */
declare function parseMongoDB(mongoDbRules: string | Record<string, any>): DefaultRuleGroupType;
declare function parseMongoDB(mongoDbRules: string | Record<string, any>, options: Omit<ParseMongoDbOptions, 'independentCombinators'> & {
    independentCombinators?: false;
}): DefaultRuleGroupType;
declare function parseMongoDB(mongoDbRules: string | Record<string, any>, options: Omit<ParseMongoDbOptions, 'independentCombinators'> & {
    independentCombinators: true;
}): DefaultRuleGroupTypeIC;

interface ParseNumberOptions {
    parseNumbers?: ParseNumbersMethod;
}
declare const parseNumber: (v: any, { parseNumbers }: ParseNumberOptions) => any;

/**
 * Converts a SQL `SELECT` statement into a query suitable for
 * the QueryBuilder component's `query` or `defaultQuery` props.
 */
declare function parseSQL(sql: string): DefaultRuleGroupType;
declare function parseSQL(sql: string, options: Omit<ParseSQLOptions, 'independentCombinators'> & {
    independentCombinators?: false;
}): DefaultRuleGroupType;
declare function parseSQL(sql: string, options: Omit<ParseSQLOptions, 'independentCombinators'> & {
    independentCombinators: true;
}): DefaultRuleGroupTypeIC;

type FindPathReturnType = RuleGroupTypeAny | RuleType | null;
declare const findPath: (path: number[], query: RuleGroupTypeAny) => FindPathReturnType;
declare const getParentPath: (path: number[]) => number[];
declare const pathsAreEqual: (path1: number[], path2: number[]) => boolean;
declare const isAncestor: (maybeAncestor: number[], path: number[]) => boolean;
declare const getCommonAncestorPath: (path1: number[], path2: number[]) => number[];
declare const pathIsDisabled: (path: number[], query: RuleGroupTypeAny) => boolean;

interface PreparerOptions {
    idGenerator?: () => string;
}
/**
 * Generates a valid rule
 */
declare const prepareRule: (rule: RuleType, { idGenerator }?: PreparerOptions) => RuleType;
/**
 * Generates a valid rule group
 */
declare const prepareRuleGroup: <RG extends RuleGroupTypeAny>(queryObject: RG, { idGenerator }?: PreparerOptions) => RG;
/**
 * Generates a valid rule or group
 */
declare const prepareRuleOrGroup: <RG extends RuleGroupTypeAny>(rg: RuleType | RG, { idGenerator }?: PreparerOptions) => RuleType | RG;

interface AddOptions {
    /**
     * If the query is of type `RuleGroupTypeIC` (i.e. the query builder used
     * `independentCombinators`), then the first combinator in this list will be
     * inserted before the new rule/group if the parent group is not empty. This
     * option is overridden by `combinatorPreceding`.
     */
    combinators?: OptionList;
    /**
     * If the query is of type `RuleGroupTypeIC` (i.e. the query builder used
     * `independentCombinators`), then this combinator will be inserted before
     * the new rule/group if the parent group is not empty. This option will
     * supersede `combinators`.
     */
    combinatorPreceding?: string;
    /**
     * ID generator.
     */
    idGenerator?: () => string;
}
/**
 * Adds a rule or group to a query.
 * @param query - The query to update
 * @param ruleOrGroup - The rule or group to add
 * @param parentPath - Path of the group to add to
 * @param options -
 * @returns The full query with the new rule or group added
 */
declare const add: <RG extends RuleGroupTypeAny>(query: RG, ruleOrGroup: RuleType | RG, parentPath: number[], { combinators, combinatorPreceding, idGenerator, }?: AddOptions) => RG;
interface UpdateOptions {
    /**
     * When updating the `field` of a rule, the rule's `operator`, `value`, and `valueSource`
     * will be reset to their respective defaults. Defaults to `true`.
     */
    resetOnFieldChange?: boolean;
    /**
     * When updating the `operator` of a rule, the rule's `value` and `valueSource`
     * will be reset to their respective defaults. Defaults to `false`.
     */
    resetOnOperatorChange?: boolean;
    /**
     * Determines the default operator name for a given field.
     */
    getRuleDefaultOperator?: (field: string) => string;
    /**
     * Determines the valid value sources for a given field and operator.
     */
    getValueSources?: (field: string, operator: string) => ValueSources;
    /**
     * Gets the default value for a given rule, in case the value needs to be reset.
     */
    getRuleDefaultValue?: (rule: RuleType) => any;
}
/**
 * Updates a property of a rule or group within a query.
 * @param query - The query to update
 * @param prop - The name of the property to update
 * @param value - The new value of the property
 * @param path - The path of the rule or group to update
 * @param options -
 * @returns The updated query
 */
declare const update: <RG extends RuleGroupTypeAny>(query: RG, prop: UpdateableProperties, value: any, path: number[], { resetOnFieldChange, resetOnOperatorChange, getRuleDefaultOperator, getValueSources, getRuleDefaultValue, }?: UpdateOptions) => RG;
/**
 * Removes a rule or group from a query.
 * @param query - The query to update
 * @param path - Path of the rule or group to remove
 * @returns The updated query
 */
declare const remove: <RG extends RuleGroupTypeAny>(query: RG, path: number[]) => RG;
interface MoveOptions {
    /**
     * When `true`, the source rule/group will not be removed from its original path.
     */
    clone?: boolean;
    /**
     * If the query is of type `RuleGroupTypeIC` (i.e. the query builder used
     * `independentCombinators`), then the first combinator in this list will be
     * inserted before the rule/group if necessary.
     */
    combinators?: OptionList;
    /**
     * ID generator.
     */
    idGenerator?: () => string;
}
/**
 * Moves a rule or group from one path to another. In the options parameter, pass
 * `{ clone: true }` to copy instead of move.
 * @param query - The query to update
 * @param oldPath - Original path of the rule or group to move
 * @param newPath - Path to move the rule or group to
 * @param options -
 * @returns The updated query
 */
declare const move: <RG extends RuleGroupTypeAny>(query: RG, oldPath: number[], newPath: number[], { clone, combinators, idGenerator }?: MoveOptions) => RG;

interface RegenerateIdOptions {
    idGenerator?: () => string;
}
/**
 * Generates new `id` property for a rule.
 */
declare const regenerateID: (rule: RuleType, { idGenerator }?: RegenerateIdOptions) => RuleType;
/**
 * Recursively generates new `id` properties for all objects in a rule group.
 */
declare const regenerateIDs: (ruleOrGroup: RuleGroupType | RuleGroupTypeIC, { idGenerator }?: RegenerateIdOptions) => RuleGroupType | RuleGroupTypeIC;

declare const toOptions: (arr?: OptionList) => React.JSX.Element[] | null;

/**
 * Options object for {@link transformQuery}.
 */
interface TransformQueryOptions<RG extends RuleGroupTypeAny = RuleGroupType> {
    /**
     * When a rule is encountered in the hierarchy, it will be replaced
     * with the result of this function.
     *
     * @defaultValue `r => r`
     */
    ruleProcessor?: (rule: RuleType) => any;
    /**
     * When a group is encountered in the hierarchy, it will be replaced
     * with the result of this function. Note that the `rules` property from
     * the original group will be processed as normal and reapplied to the
     * new group object.
     *
     * @defaultValue `rg => rg`
     */
    ruleGroupProcessor?: (ruleGroup: RG) => Record<string, any>;
    /**
     * For each rule and group in the query, any properties matching a key
     * in this object will be renamed to the corresponding value. To retain both
     * the new _and_ the original properties, set `deleteRemappedProperties`
     * to `false`.
     *
     * If a key has a value of `false`, the corresponding property will be removed
     * without being copied to a new property name. (Warning: `{ rules: false }`
     * will prevent recursion and only return the processed root group.)
     *
     * @defaultValue `{}`
     *
     * @example
     * ```
     *   transformQuery(
     *     { combinator: 'and', not: true, rules: [] },
     *     { propertyMap: { combinator: 'AndOr', not: false } }
     *   )
     *   // Returns: { AndOr: 'and', rules: [] }
     * ```
     */
    propertyMap?: Record<string, string | false>;
    /**
     * Any combinator values (including independent combinators) will be translated
     * from the key in this object to the value.
     *
     * @defaultValue `{}`
     *
     * @example
     * ```
     *   transformQuery(
     *     { combinator: 'and', rules: [] },
     *     { combinatorMap: { and: '&&', or: '||' } }
     *   )
     *   // Returns: { combinator: '&&', rules: [] }
     * ```
     */
    combinatorMap?: Record<string, string>;
    /**
     * Any operator values will be translated from the key in this object to the value.
     *
     * @defaultValue `{}`
     *
     * @example
     * ```
     *   transformQuery(
     *     { combinator: 'and', rules: [{ field: 'name', operator: '=', value: 'Steve Vai' }] },
     *     { operatorMap: { '=': 'is' } }
     *   )
     *   // Returns:
     *   // {
     *   //   combinator: 'and',
     *   //   rules: [{ field: 'name', operator: 'is', value: 'Steve Vai' }]
     *   // }
     * ```
     */
    operatorMap?: Record<string, string>;
    /**
     * Prevents the `path` property (see {@link Path}) from being added to each
     * rule and group in the hierarchy.
     *
     * @defaultValue `false`
     */
    omitPath?: boolean;
    /**
     * Original properties remapped according to the `propertyMap` option will be removed.
     *
     * @defaultValue `true`
     *
     * @example
     * ```
     *   transformQuery(
     *     { combinator: 'and', rules: [] },
     *     { propertyMap: { combinator: 'AndOr' }, deleteRemappedProperties: false }
     *   )
     *   // Returns: { combinator: 'and', AndOr: 'and', rules: [] }
     * ```
     */
    deleteRemappedProperties?: boolean;
}
/**
 * Recursively process a query heirarchy using this versatile utility function.
 *
 * [Documentation](https://react-querybuilder.js.org/docs/utils/misc#transformquery)
 */
declare function transformQuery(query: RuleGroupType, options?: TransformQueryOptions<RuleGroupType>): any;
/**
 * Recursively process a query heirarchy with independent combinators using this
 * versatile utility function.
 *
 * [Documentation](https://react-querybuilder.js.org/docs/utils/misc#transformquery)
 */
declare function transformQuery(query: RuleGroupTypeIC, options?: TransformQueryOptions<RuleGroupTypeIC>): any;

declare const uniqByName: <T extends {
    name: string;
}>(originalArray: T[]) => T[];
declare const uniqOptGroups: <T extends Option<string>>(originalArray: OptionGroup<T>[]) => OptionGroup<T>[];

export { ActionElement, ActionProps, ActionWithRulesAndAddersProps, ActionWithRulesProps, AddOptions, Arity, BaseSelectorProps, Classname, Classnames, Combinator, CombinatorSelectorProps, CommonRuleSubComponentProps, CommonSubComponentProps, Controls, DefaultCombinator, DefaultCombinatorExtended, DefaultCombinatorName, DefaultCombinatorNameExtended, DefaultOperator, DefaultOperatorName, DefaultRuleGroupArray, DefaultRuleGroupICArray, DefaultRuleGroupType, DefaultRuleGroupTypeAny, DefaultRuleGroupTypeIC, DefaultRuleOrGroupArray, DefaultRuleType, DndDropTargetType, DragCollection, DragHandle, DragHandleProps, DraggedItem, DropCollection, DropEffect, DropResult, ExportFormat, Field, FieldSelectorProps, FindPathReturnType, FormatQueryOptions, GetCompatContextProviderProps, InlineCombinator, InlineCombinatorProps, JsonLogicAnd, JsonLogicDoubleNegation, JsonLogicEqual, JsonLogicGreaterThan, JsonLogicGreaterThanOrEqual, JsonLogicInArray, JsonLogicInString, JsonLogicLessThan, JsonLogicLessThanOrEqual, JsonLogicNegation, JsonLogicNotEqual, JsonLogicOr, ReservedOperations as JsonLogicReservedOperations, RulesLogic as JsonLogicRulesLogic, JsonLogicStrictEqual, JsonLogicStrictNotEqual, JsonLogicVar, LogType, MoveOptions, NameLabelPair, NotToggle, NotToggleProps, Operator, OperatorSelectorProps, Option, OptionGroup, OptionList, ParameterizedNamedSQL, ParameterizedSQL, ParseCELOptions, ParseJsonLogicOptions, ParseMongoDbOptions, ParseNumberOptions, ParseNumbersMethod, ParseSQLOptions, PreparerOptions, QueryActions, QueryBuilder, QueryBuilderContext, QueryBuilderContextProps, QueryBuilderContextProvider, QueryBuilderContextProviderProps, QueryBuilderProps, QueryValidator, RQBJsonLogic, RQBJsonLogicEndsWith, RQBJsonLogicStartsWith, RQBJsonLogicVar, RegenerateIdOptions, Rule, RuleComponents, RuleGroup, RuleGroupArray, RuleGroupBodyComponents, RuleGroupHeaderComponents, RuleGroupICArray, RuleGroupProps, RuleGroupType, RuleGroupTypeAny, RuleGroupTypeIC, RuleOrGroupArray, RuleProcessor, RuleProps, RuleType, RuleValidator, Schema, SelectorOrEditorProps, TestID, TransformQueryOptions, Translation, TranslationWithLabel, TranslationWithPlaceholders, Translations, TranslationsFull, UpdateOptions, UpdateableProperties, UseControlledOrUncontrolledParams, UseMergedContextProps, UseRuleDnD, UseRuleGroupDnD, UseValueEditorParams, UseValueSelectorParams, ValidationMap, ValidationResult, ValueEditor, ValueEditorProps, ValueEditorType, ValueProcessor, ValueProcessorByRule, ValueProcessorLegacy, ValueProcessorOptions, ValueSelector, ValueSelectorProps, ValueSource, ValueSourceSelectorProps, ValueSources, VersatileSelectorProps, WithRequired, add, convertFromIC, convertQuery, convertToIC, QueryBuilder as default, defaultCELValueProcessor, defaultCombinators, defaultCombinatorsExtended, defaultControlClassnames, defaultControlElements, defaultJoinChar, defaultMongoDBValueProcessor, defaultOperatorNegationMap, defaultOperators, defaultPlaceholderFieldGroupLabel, defaultPlaceholderFieldLabel, defaultPlaceholderFieldName, defaultPlaceholderOperatorGroupLabel, defaultPlaceholderOperatorLabel, defaultPlaceholderOperatorName, defaultRuleProcessorCEL, defaultRuleProcessorJsonLogic, defaultRuleProcessorMongoDB, defaultRuleProcessorSQL, defaultRuleProcessorSpEL, defaultSpELValueProcessor, defaultTranslations, defaultValidator, defaultValueProcessor, defaultValueProcessorByRule, defaultValueProcessorCELByRule, defaultValueProcessorMongoDBByRule, defaultValueProcessorSpELByRule, filterFieldsByComparator, findPath, formatQuery, generateID, getCommonAncestorPath, getCompatContextProvider, getFirstOption, getOption, getParentPath, getValidationClassNames, getValueSourcesUtil, groupInvalidReasons, isAncestor, isOptionGroupArray, isPojo, isRuleGroup, isRuleGroupType, isRuleGroupTypeIC, isRuleOrGroupValid, isValidationResult, joinWith, jsonLogicAdditionalOperators, mergeClassnames, messages, move, nullFreeArray, numericRegex, objectEntries, objectKeys, parseCEL, parseJsonLogic, parseMongoDB, parseNumber, parseSQL, pathIsDisabled, pathsAreEqual, prepareRule, prepareRuleGroup, prepareRuleOrGroup, regenerateID, regenerateIDs, remove, splitBy, standardClassnames, toArray, toOptions, transformQuery, trimIfString, uniqByName, uniqOptGroups, update, useControlledOrUncontrolled, useDeprecatedProps, useMergedContext, usePreferProp, usePrevious, useQueryBuilder, useReactDndWarning, useRule, useRuleGroup, useSelectElementChangeHandler, useStopEventPropagation, useValueEditor, useValueSelector };
